With Actionscript 2.0 you could ' attach ' an image from the library using the loadBitmap method of the BitmapData class.
In Actionscript 3.0 this method has been removed, given the implementation of the Bitmap class.
So, let see how to load an image from the gallery ...
I create an FLA that I save as ' attacca_immagine.fla ' .
I import an image from the gallery ( file>import>import to library and browse until I find the image I wish to use ). I create the Document Class, an AS file that I save as ' AttaccaImmagine.as ' and implemented like so:
Code:
package
{
import flash.display.MovieClip;
import flash.display.Bitmap;
public class AttaccaImmagine extends MovieClip
{
public function AttaccaImmagine()
{
attacca();
}
private function attacca():void
{
var immagine:Immagine=new Immagine();
var bitmap:Bitmap=new Bitmap(immagine);
addChild(bitmap);
}
}
}
Now I create another class, another AS file that I save as ' Immagine.as ' :
Code:
package
{
import flash.display.BitmapData;
public class Immagine extends BitmapData
{
public function Immagine()
{
super(0,0);
}
}
}
I go back to the FLA, I select the image in the gallery and right click>linkage and in the Class field of the newly opened window, I insert ' Immagine '.
Now I can launch the SWF noticing the image on stage :)
Source files:
Bookmarks