Archive

Archive for the ‘Flex’ Category

Hello World JPG Encoding with Apollo

March 19th, 2007

I downloaded the Apollo Alpha today and it’s really fun; I can’t wait until I bring my mac to its knees!!!

So what I did was play around with writing an image file to my system. It’s incredibly simple. All I’m doing is creating a Label component with text “HELLO WORLD”, drawing the label on a BitmapData Object, encoding a .jpg using JPGEncoder in Adobe’s corelib. and writing the resultant ByteArray to a file on my desktop named helloworld.jpg.

It’s that simple! Now, go check out Joa Ebert’s Image Processing Library and make Photoshop on top of Apollo. Now.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?xml version="1.0" encoding="utf-8"?>
<mx:ApolloApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
 
	<mx:Label text="HELLO WORLD" id="helloText" fontSize="36" horizontalCenter="0" verticalCenter="0"/>
 
	<mx:Script>
		<![CDATA[
 
			import com.adobe.images.*;
			import flash.filesystem.*;
 
			private function init() : void
			{
 
				var bitmap:BitmapData = new BitmapData( helloText.width, helloText.height, false, 0xececed );	
				bitmap.draw( helloText, new Matrix() );
 
				var encoder:JPGEncoder = new JPGEncoder();
				var encoded:ByteArray = encoder.encode( bitmap );
 
				var file:File = File.desktopDirectory.resolve( "helloworld.jpg" );
				var stream:FileStream = new FileStream();
				stream.open( file, FileMode.WRITE );
				stream.writeBytes( encoded );
 
			}
		]]>
	</mx:Script>
 
</mx:ApolloApplication>

drew ActionScript 3.0, Flex

Introduction to Flex 2

March 13th, 2007

A Short Cuts release from O’Reilly by my boy, Roger Braunstein: it’s 10 USD and doesn’t hurt trees.

drew ActionScript 3.0, Flex