bedsingar
asked on
Flash CS5 AS3 Looping
Hello,
I'm trying to set up a loop using actionscript 3 that will call a function to check if a token has been dropped on any of the 40 boxes on my stage. Each box has its own instance ID of target1, target2 etc...
The script is as follows at the moment, but currently it only completes the trace() for target40.
Can somebody explain to me why this is / what I've got to do to make the hittestobject script work across all 40 boxes?
EE Stuff link as can't load flash attachments here.
Thanks
I'm trying to set up a loop using actionscript 3 that will call a function to check if a token has been dropped on any of the 40 boxes on my stage. Each box has its own instance ID of target1, target2 etc...
The script is as follows at the moment, but currently it only completes the trace() for target40.
Can somebody explain to me why this is / what I've got to do to make the hittestobject script work across all 40 boxes?
EE Stuff link as can't load flash attachments here.
Thanks
for(var j:uint = 1; j <= 40; j++){
var targetid:SimpleButton = getChildByName("target" + j) as SimpleButton;
var tstring:String = new String("Target " + j);
if(targetid != null){
targetid.tabIndex = j;
targetid.addEventListener(Event.ENTER_FRAME,
function(yourEvent:Event):void{
if (Token.hitTestObject(targetid)){
trace(tstring);
}
})
};
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Solution worked perfectly & I can follow the logic so thanks for your help!
ASKER
So if I want to trigger the follow URL code for the box that the token is dropped on, I can add this code to the onTokenRelease function right?
Thanks for your help!