I’m making a game where little parcels appear and if they aren’t dragged to the correct zone within 5 seconds, they disappear and the player loses points.
The problem i’m having is that i’m generating the movieclip parcel objects as follows:
var mcObj:Object = null;
mcObj = getDefinitionByName(id.toString());
return (new mcObj()) as MovieClip;
Then creating the movieclip and adding it to the screen depending on certain conditions as follows:
mc = generateMCByString(currentParcel); mc.value = currentParcel; addChild(mc); mc.x = 386.9; mc.y = -100; mc.addEventListener(MouseEvent.MOUSE_DOWN, dragStarter); mc.addEventListener(MouseEvent.MOUSE_UP, dragStopper); tweenMove0 = new Tween(mc, "y", None.easeOut, -100, 238, 3, true);
currentParcel is 1 of 3 (randomly selected) movieclip names (redParcel, yellowParcel and orangeParcel).
What I need to do is add some code to say “after a movieclip has been generated…if it is still here in 5 seconds time…”
It sounds simple but I can’t figure it out for the life of me! I’ve tried setInterval with something like:
timedProcess = setInterval(timeCheck, 5000);
but how can I pass the actual movieclip “handle” along with the function so that timeCheck knows which movieclip to delete?
Any suggestions gratefully received!