Tuesday 19 February 2008

AS3 -AttachMovieClip is no more!!

yea, it always sounded old, AS3 works without it. A common way of including an graphical object to the stage follows. I include a way of embedding an image straight away:

package {
import flash.display.MovieClip;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
public class Test extends MovieClip {
// be sure this is pointing to an image in your hardrive
[Embed(source='\images\whatsup.jpg')] public var MyImage:Class;
public function Test() {
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
var img:MyImage = new MyImage();
addChild(img);
}
}
}

Just attaching a symbol from the Library to the stage here:

package {
import flash.display.MovieClip;
public class Test extends MovieClip {
public var MyLibrarySymbol:MovieClip;
public function Test() {
var mc:MyLibrarySymbol= new MyLibrarySymbol();
addChild(mc);
}
}
}

No comments: