Some people have no clue how they can make use of my favorite Flash CS3 feature so here is a little walkthrough. It is about creating assets inside Flash CS3 and then using them inside FlexBuilder in a very easy way.
I will show you an example how you can easily import a graphic in Flash and then use that graphic in FlexBuilder. First you have to create a new ActionScript 3.0 file. Then press Ctrl+R and import a graphic. Hit Ctrl+L to open the library and right-click on the graphics. Select “Linkage…” and check the “Export for ActionScript” box. Give it a class name. I used “Magneto“. The base class should be BitmapData. That is fine for us. Click on “Ok” and ignore the warning.
Now you have an asset in your library which is a simple graphic. Hit Ctrl+Shift+Alt+S to export and pick a destination of your choice. In the next window make sure to check the “Export SWC” box. This is the most important step.
We are done now with Flash. Open FlexBuilder and create a new ActionScript project. Give it a name and do NOT hit the “Finish” button. Click next and switch to the “Library Path” tab. Click on “Add SWC” and go the the location where you saved your SWF. You should find an SWC file there. Now you may click on “Finish”.
The SWC has been added to your project and embedded. This means it will not be preloaded. I think I could make another post out of that. For now you have now the library of Flash embedded in your FlexBuilder application. Remember the class name I gave my asset in Flash? It was Magneto. If I start typing “new M” I will get syntax completion for that asset. Pretty nice, huh? If I want to show the graphic now I just do this:
[as]var test: Bitmap = new Bitmap( new Magneto( 0, 0 ) );
addChild( test );[/as]
Unfortunately I have no idea what the two parameters are good for. Anyways I hope this helps :)




thank you!
this was extremely helpful…
but can you talk a little more on
other types? such as movieClips,
or even more indeph such as the
fl.* libaries that arnt accessable
in flex… thanx!
keep it up!