To place an asset on the stage (display an image, video, or play music), an asset library must first be created.
- Right click and save this image () as star.png in the src directory. On my machine, the full path is:
/home/kca/workspace/hello_world/src/
- Copy and paste this XML into asset.xml in the src directory
- At the command prompt, run this command in the src directory:
swfmill simple asset.xml asset.swf
- If you have swfmill installed correctly, a new SWF file should now exist in the src directory called asset.swf. This is the asset library.
- Return to Eclipse and right click on your project name, e.g., hello_world. Select Properties
- On the left, select AS2 Builder; on the right, select the entry for Application
- Click Edit
- Enter src/asset.swf in the Input SWF box
- Click OK to return to the Properties dialog
- Click OK to return to the Eclipse editor
- Double click source file Application.as to edit
- At the bottom of the class constructor, add this code:
var my_star:MovieClip = attachMovie("asset_star", "my_star", this.getNextHighestDepth()) ;
my_star._x = 250 ;
my_star._y = 50 ;
my_star._xscale = 400 ;
my_star._yscale = 400 ;
- Save the file, and the SWF file is automatically rebuilt by Eclipse. Click to see a star image in the top right of the Flash demo.
A few important notes:
- Inside the asset.xml file, the movie width, height, and framerate are inherited by the SWF file output by your project. Some might call this a weakness of the Eclipse integration or MTASC. This may change in the future, but be aware of it now. This can be difficult to debug if you forget!
- Assets are not limited to a single placement. They may be placed zero, one, or many times. Only the MovieClip name, e.g., my_star, must be different for each instance.
- Currently, MTASC is limited to one asset library, but it may be possible to merge multiple asset libraries using swfmill.
- Read more about swfmill here.
1 comment:
Your link to google code is broken.
Thanks for this great tutorial series.
VirtualFlavius
Post a Comment