Embedding or loading assets in flash

The best way to get at a bitmap is to upload the bitmap in your SWF, which is handled
in two different techniques, based on your compiler. First, if you are using Fold Designer, the
mxmlc compiler through the control range, or the Fold compiler as an option in the Flash
IDE, you can use the upload metatag to upload your bitmap resource, as was mentioned in the
“Introducing Bitmap” area previously this part.

If you are using the Present IDE, you can transfer the bitmap into your collection and move it for
ActionScript (in this situation, perhaps as the category LogoImage). As these two techniques are not
consistent for all conditions, we will not use them in the illustrations in this publication. Please
see the Fold or Present certification for further details on these techniques.

No issue your strategy of option for embedding, you can instantiate the bitmap using the
class constructor and thrown it as a Bitmap. Since Bitmap is a DisplayObject, you can then add
it immediately to the display record for rendering:

var logo:Bitmap=new LogoImage as Bitmap;
addChild(logo);
The strategy we will use to accessibility bitmaps in our illustrations, and the one you saw in the
previous part, is to use the Loading machine category to fill in a bitmap at playback. This performs the
same no issue your compiler or progression atmosphere. Generally, Loading machine, which is a
DisplayObject itself, is a wrapper that you can add to the present record and location, range,
rotate, set awareness, and so on, while it a lot displayable information, like a SWF or bitmap graphic,
asynchronously behind the curtain.
var loader:Loader=new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,imageloaded);
loader.load(new URLRequest(imagePath));
However, we will not be including the Launching machine to the present record in our illustrations, although you
certainly could (if all you are doing is loading and showing, there is no purpose why not).
We will need use of the hidden bitmap if you want to accessibility its bitmap information, so it is
best to pick up this from the Launching machine example once the bitmap completely a lot and add this directly
to the present list:
private function imageloaded(evt:Event)
{
var loaderinfo:LoaderInfo=evt.target as LoaderInfo;
var bitmap:Bitmap=LoaderInfo.content as Bitmap;
bitmap.x=100;
bitmap.y=100;
addChild(bitmap);
}

Popular posts from this blog

how to load a bitmap and cut into pieces using ationscript 3.0

You want to store information in memmory using flash sharedObject