Tuesday, September 11, 2007
private function loadViewElements():voidThis works just fine, but wondering if I should set up private variables to hold those objects for easy access later on in my document class above the constructor and in the complete event, like so:
{
var module1Loader:Loader = new Loader();
module1Loader.contentLoaderInfo.addEventListener(
Event.COMPLETE, completeEvent );
module1Loader.contentLoaderInfo.addEventListener(
IOErrorEvent.IO_ERROR, ioError );
// Create and load the Views
NUMBERPAD = new MovieClip();
addChild( NUMBERPAD );
NUMBERPAD.addChild( module1Loader );
var moduleURL:URLRequest = new URLRequest( "views/view.swf" );
module1Loader.load( moduleURL );
}
private function completeEvent( event:Event ):void
{
var foo:Object = NUMBERPAD.getChildAt(0);
trace( foo.numChildren ); // 1
trace( foo.getChildAt(0).iam ); // iam
}
private var NUMBERPAD_CONTENTS:Object;Just to make things clearer and much easier to access. Or is there a much more simple way of approaching this?
// within compete event below:
NUMBERPAD_CONTENTS = foo.getChildAt(0);
trace( NUMBERPAD_CONTENTS.iam ); // iam
Update:
trace( event.target.content.iam );Well, that out to do it ;) BUT, how can I get the name of the mc that the loader is inside... so I can use a generic loader and assign vars to certain things?
3 Comments:
-
Muzak said...
-
“To get to the loaded content, use LoaderInfo.content (as you already figured out).
To get to the movieclip that holds the Loader, use the class member, NUMBERPAD.” -
Tom said...
-
“I know this is probably very simple, but how do I call stop(); or play(); on a loaded SWF? (Working in the Flash CS3 IDE--no Flex)
I've tried this.mcLoader_mc.content.stop();, but get compiler errors.
Thanks!
Tom” -
e.dolecki said...
-
“Tom,
Your code doesn't look correct. It should be something more like: event.target.content.stop(); within the Loader event.”








