Skip to main content
January 18, 2007
Question

time based quirk

  • January 18, 2007
  • 3 replies
  • 232 views
Hi,
In a time base function if load a MC it fails to be clickable (but the MC appears). If I load it outside the time base function it works fine and is clickable.

I don't get this ? I spent ages trying to find out why it fails and it comes down to a time based quirk it seems. is there anything I can do ?


var aval:Array= new Array();
aval.push("98img1.jpg");
aval.push("50img2.jpg");

function createShifters():Void{
this.attachMovie("move1","mc4",this.getNextHighest Depth());
mc4._x=300;
mc4._y=200;
}

function main():Void
{
if (aval.length>0)
{
// createShifters(); failed
clearInterval(timeINum);
createShifters(); //fails to be clickable but loads the image
}
}

var timeINum:Number=setInterval(main,1000);
createShifters(); //works outside of the time limit


mc4.onPress = function () :Void
{
...
}
This topic has been closed for replies.

3 replies

kglad
Community Expert
Community Expert
January 19, 2007
it doesn't get any easier than swapDepths() and it's the only way to control the depth using actionscript.

in the authoring environment you can use layers to control the apparent depth of objects (and flash converts assigns the object depths in accord with your layers).
January 19, 2007
Ok i found this out aftyer i posted as well.
How can I make a MC always be on top of the others. Do I need to use a swapdepth or is there an easier way.
kglad
Community Expert
Community Expert
January 19, 2007
you can't define your onPress handler for mc4 BEFORE mc4 exists and expect it to work.

ie, put your onPress handler below the code that creates mc4 in createShifters().