PDA

View Full Version : Help!


Pandan
08-26-2005, 04:40 PM
I have a problem!
I want to move a movieClip after it been loaded.
But my problem is that I can assign a dynamic value and then get it in the onLoadComplete function. se the red comments

var clip = game.clip;
var mclTempContainer:MovieClipLoader = new MovieClipLoader(); // the loader

var listener:Object = new Object(); // the listener
// The event handler
listener.onLoadComplete = function ( targ:MovieClip ):Void{
trace(targ.nHeight )//<- this trace undefined
targ._y = - (100 + targ.nHeight );


};

var mcTempContainer:MovieClip = clip["t"+i]createEmptyMovieClip("mcTempContainer",1);
mcTempContainer.nHeight = 33; //Here I set the value
mclTempContainer.loadClip(selectedFurniture+".swf",mcTempContainer);

IceCo
08-27-2005, 08:13 PM
There are two problems here:

a) Use onLoadInit instead of onLoadComplete here....
b) The targ.nHeight undefined problem is probably caused by the fact that : 1) you are using a dynamically variables (which I won't recon you to do so since it is a bad practice in software engineering) and then 2) you load a mc into that movieClip, which replace all the properties in it

A much better way to approach this would be using local variables, which a nested function can have access to:

var clip:MovieClip = game.clip;
var mclTempContainer:MovieClipLoader = new MovieClipLoader(); // the loader

var listener:Object = new Object(); // the listener
// The event handler
var nHeight:Number = 33; //Here I set the value
listener.onLoadInit = function ( targ:MovieClip ):Void{
trace(nHeight )//<- this trace undefined
targ._y = - (100 + nHeight );


};

var mcTempContainer:MovieClip = clip["t"+i]createEmptyMovieClip("mcTempContainer",1);
mclTempContainer.loadClip(selectedFurniture+".swf",mcTempContainer);