PDA

View Full Version : call function scripted on tween complete



GrndMasterFlash
September 14th, 2007, 04:14 PM
im trying to make an event listener for a when a tween completes, and im not having any luck, any advise

my script

function startmove(event:KeyboardEvent) {
switch (event.keyCode) {
case 17 :
if ((blasts>0) && (blown)) {
blasts -= 1;
updateblasts();
blown = false;
blastx = ship.x;
blasty = ship.y-(ship.height/2);
bomb = bhold.addChild(new blast());
bomb.name = bomb;
bomb.x = blastx;
//bomb.addEventListener(Event.ENTER_FRAME, dropbomb);
bombtween:Tween = new Tween(bomb, "y", null, blasty, blasty-200, .5, true);
}
break;
}
}

bombtween.addEventListener(Event.COMPLETE, removebomb);

how can i make it call the removebomb function after the tween is completed???

:ponder:

SlowRoasted
September 14th, 2007, 05:56 PM
I have been using Cuarina to tween lately, but I remember having this problem. I think your listener needs to be set like this:

bombtween.addEventListener(TweenEvent.COMPLETE, removebomb);

function removebomb(e:TweenEvent) {

}

You may have to import flash.events.TweenEvent

DarkGloveLove
January 13th, 2008, 11:33 AM
Am trying to do the same thing....

Did this work for you?

I didn't have any luck.

Felixz
January 13th, 2008, 05:13 PM
u are adding that listener before instantiating

bombtween:Tween = new Tween(bomb, "y", null, blasty, blasty-200, .5, bombtween.addEventListener(Event.COMPLETE, removebomb);

thomasagarcia
March 13th, 2009, 05:47 AM
import fl.transitions.TweenEvent;

var bombtween:Tween = new Tween(bomb, "y", null, blasty, blasty-200, .5, true);

bombtween.addEventListener(TweenEvent.MOTION_FINIS H, dropbomb);

function dropbomb(e:Event):void
{
//Insert your action here ?? remove.Child ?? not sure what you want here.
}

Hope this helps. I found it here... http://www.flashandmath.com/intermediate/tricks/example3.html