Sunday, November 30, 2008

Embedding pictures in flashmovies using FlashDevelop

Embedding resources such as pictures,sounds & even other swf files was one of the first issues when I started looking into writing actionscript 3 using Flexbuilder (and now later FlashDevelop) having no previous flash experience it was a shot in the dark, but luck behold, embedding resources in actionscript 3 is just as easy as scratching your bum :)

have a look at the following code:

package
{
import flash.display.Bitmap;
import flash.display.Sprite;
/**
* ...
* @author Kenneth Christensen
*/
[SWF(width = '640', height = '480', backgroundColor = '#ffffff', framerate = '25')]
public class Main extends Sprite
{
[Embed(source = "..\\picture.png")]
private var pictureclass:Class;

public function Main():void
{
// lets declare a new bitmap based in the pictureclass above
var mypicture:Bitmap = new pictureclass();

// add it to the current stage.
this.addChild(mypicture);

// that's it really .. pretty easy no ? ;)
}
}
}


Pretty easy stuff eh ? the metadata statements in the Actionscript 3 really makes it easy for an old developer like me.

Regarding the use of FlashDevelop, a HUGE thanks flies out to Laurence Muller for posting his quickguide on developing flash 10 with debugger in FlashDevelop




I'm currently reading up on the Flash 10 3d features, and hopefully doing this week i'll be posting a few examples..




..Kenneth Christensen

No comments: