Tuesday, May 26, 2009

Ditect loader dimension after loading a movie or an Image

1. save ur FLA file and place an image in the same folder.
2. rename the image as "5A.jpg". ( As im using in the example)
3. paste the following code in ur action script panel.

//----------------------------------------------------------------------------

var loader:Loader = new Loader()
var url:URLRequest = new URLRequest("5A.jpg")

loader.load(url);

loader.contentLoaderInfo.addEventListener(Event.INIT, getWidth)

function getWidth(e:Event){

loader.x = (stage.stageWidth - loader.width)/2
loader.y = (stage.stageHeight - loader.height)/2
addChild(loader)
}
//----------------------------------------------------------------------------

No comments: