I develop a game that will have to load jpg images that now i just put in the same folder where swf file is, in order to load them when it is needed. Is there a way to somehow embed all this stuf in the swf so that i will have to deliver only the swf file?
+1
A:
Yes use the embed metatag :
[Embed(source="myImg.jpg")]
private var myImg : Class;
//...
var pic:DisplayObject = new myImg() as DisplayObject;
addChild(pic);
Patrick
2010-02-28 17:53:22
flash cs4 prompts to add flex sdk but i have not installed this library. Do everyone that needs to run the swf have to install the flex sdk?
Ponty
2010-02-28 18:08:21
No it s only used when compiling the swf. The part of flex sdk used is installed with cs4. The path used is : $(AppConfig)/ActionScript 3.0/libs/flex_sdk_3/
Patrick
2010-02-28 18:26:21
The warning means that you are using the embed tag [Embed] and flash compiler doent's support this, so it tells you that you need to compile the project with flex sdk. It's a just a different way to compile the swf, take a look into this page it you want to take this approach: http://www.adobe.com/devnet/flash/articles/embed_metadata.htmlIf you don't use the flex compiler it wouldn't prompt users for the library, it would simply not compile properly.
dome
2010-02-28 18:27:37
+1
A:
If you are using Flash IDE (I presume you use cs4 after your comment) you just need to import your images to library and export to actionscript.
// myBitmapData is the class name for the BitmapData symbol in the library
// Create a new myBitmapData object instance called myBitmapDataObject
var myBitmapDataObject:myBitmapData = new myBitmapData(100, 100);
// Create a bitmap object instance called myImage to contain the bitmap data
var myImage:Bitmap = new Bitmap(myBitmapDataObject);
// Add myImage to the display list of the current Timeline
addChild(myImage);
Take a look into this document for more details:
http://www.adobe.com/devnet/flash/quickstart/loading_images_library_as3/#c
This way the image can be used with actionscript as Bitmapdata.
dome
2010-02-28 18:17:42