Still new to AS3 - I've been futzying with this for a while and can't figure out why it will not display the loaded SWF (it loads it I can see that via trace, but addChild in the onCompleteHandler does nothing. Either I don't have a handle to the loaded childSWF or I'm totally lost. No error msg is displayed, but the trace does show that "this" is not the stage or anything displayable, its the Util class instance.
What im trying to do is load an external swf onto a template swf file and then manipulate the loaded swf via AS3 (provided it has instance names on all the things I want to mainipulate like text fields and titles and buttons)
package com.foo.flashas3
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.text.TextField;
import fl.motion.MotionEvent;
public class Main extends MovieClip
{
public var childSWF:MovieClip;
public var swfURL:URLRequest = new URLRequest("some.swf");
public var util:Utils=new Utils();
public function Main()
{
// constructor code
trace("Entering Main");
trace(this);
initSplash();
}
public function initSplash():void
{
util.getSubClip(swfURL);
}
}
}
package com.foo.flashas3
{
import flash.display.Loader;
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ProgressEvent;
import flash.net.URLRequest;
import flash.text.TextField;
public class Utils extends MovieClip
{
private var mLoader:Loader;
public var mContent:MovieClip;
public function Utils (){
trace("Utils Constructor")
}
public function getSubClip(mRequest:URLRequest)
{
trace ("In getSubClip")
mLoader = new Loader();
mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);
}
private function onProgressHandler(mProgress:ProgressEvent)
{
var percent:Number = mProgress.bytesLoaded / mProgress.bytesTotal;
trace(percent);
}
private function onCompleteHandler(loadEvent:Event)
{
trace("In onCompleteHandler")
mContent = MovieClip(mLoader.contentLoaderInfo.content);
trace(mContent.totalFrames);
trace(this)
trace(this.parent)
addChild(mContent);
}
}