Domanda

I'm not finding much documentation on embeding images in .as files. Really, I'd like to have some theory on it. So far from what I got reading here and there:

I placed an image in Assets folder inside src. Then right-clicked the image and clicked "Generate embed code", then this code line appears where the cursor was [Embed(source="fluffybunny.png")] what now? How do I assign it to a variable or something... I really didn't find it out there.

Instead of given object using .graphic atribbutes I want to use an image.

Also, does it have to be an .SWF?

È stato utile?

Soluzione

There are quite a few resources on this (when you search for "as3 use embed tag"). Some of them are really helpful: http://www.bit-101.com/blog/?p=853 http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf680e1-7ffe.html

The most basic thing is that you declare a variable of some type. And you use the [Embed] tag before the variable declaration. It's some kind of weird association. Something like:

[Embed(source="image.jpg")]
public var imageClass:Bitmap;

// later on you can instantiate it and use:
addChild(new imageClass()); // creates and adds new image

This is just a sample - there are a lot of types and ways to do it - give a shot the Adobe reference, there are tons of samples.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top