Reputation: 21
I'm using a Loader object to load an external swf:
var swfLoader:Loader = new Loader();
stage.addChild(swfLoader);
var bgURL:URLRequest = new URLRequest("sometestfile.swf");
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadProdComplete);
swfLoader.x = 240;
swfLoader.y = 210;
// Resize here?
swfLoader.load(bgURL);
function loadProdComplete(e:Event):void
{
trace("File loaded");
}
This works fine until I try to set swfLoader.width or .height (as I do when I want to resize loaded images), but in this case the swf isn't displayed anymore. (It's running anyway as I receive traces from sometestfile.swf)
I've resolved my error, using swfLoader.content.width in the Complete event works.
Upvotes: 2
Views: 1713
Reputation: 3575
You should add stage.addChild(swfLoader);
and swfLoader.x = 240;
swfLoader.y = 210;
and the height and width settings to the loadProdComplete()
Upvotes: 1
Reputation: 27045
The loader will have zero width/height until the COMPLETE
event fires, so wait until then to set the size. That may solve your problem.
Upvotes: 2