Record21: Loading and ImageViewer class
(a) ImageViewer.as file
class ImageViewer
{
private var container_mc:MovieClip;
public function ImageViewer(target:MovieClip,depth:Number,x:Number,y:Number)
{
container_mc=target.createEmptyMovieClip("container_mc"+depth,depth);
container_mc._x=x;
container_mc._y=y;
}
public function loadImage(URL:String):Void
{
container_mc.loadMovie(URL);
}
}
------------------------------------------------------------------------------
(b) ImageViewer.fla file
-----------------------------------------------------------------------------
var viewer:ImageViewer=new ImageViewer(this,1,100,100);
viewer.loadImage("Sunset.jpg");
------------------------------------------------------------------------------