Journal Entries

 

Aug 9, 2006

Flash components are like bratty children


Ever try to initialize a Loader component via actionscript with 2 or more dynamically created movieclips as parents? Yeah. Didn’t work for you either, huh?

Try the following code as a solution and I’ll try to explain why I think it’s happening below.


private function makeContainer( mc:MovieClip ):Void {

	__myContainer_mc = mc.createEmptyMovieClip( "myContainer" );

	createLoader( mc, 0 );

}

private function createLoader( mc:MovieClip, depth:Number ):Void {

		__myLoader = mc[ 'myContainer' ].createClassObject( Loader, “myLoader”, depth );

}

See what’s happening? Instead of using variables as references to movieclips, to create the Loader we must identify the movieclip by the name is was assigned when it was created. In this case __myContainer_mc.createClassObject() will not give us a functioning Loader. But mc[ 'myContainer' ].createClassObject() will. This strikes me as odd because I always understood that __myContainer_mc = mc[ 'myContainer' ].

Obviously, that is not the case. My guess? The Loader is addicted to negative attention and enjoys watching me anthropomorphize the computer by repeatedly and angrily yelling at it to “Tell me why it has to be such an ass?”

 

Comments are closed.