Good morning,
I'm new to flash and actionscript and I have this project for school. I have some little games, and in one of them the users must click on berries growing on a bush before the berry falls into the ground.
now I have this:
http://www.villa-kenya.com/brol/struiktest.swf
But, if the berries fall into the ground it's still possible to click them away, what's not the intention of the game.
In code it looks like this:
Each time the timer ticks, the function "voegDruifToe" is executed, when this hapens there is added a child "druif" and an eventlistener to remove the berry.
public function voegDruifToe():void
{
var druifruifje = new Druifje();
//druif.x word random geregeld
//druif.y word random geregeld
druif.addEventListener(MouseEvent.CLICK, verwijderDruif);
struikContainer.addChild(druif);
druif.buttonMode= true;
TweenLite.to(druif, 3, {y:200, ease:Bounce.easeOut, delay: (timerInterval/1000) +1, onComplete:druifTimeOut});
}
public function druifTimeOut():void{
trace("klaar met vallen");
druif.removeEventListener(MouseEvent.CLICK, verwijderDruif);
removeChild(druif);
}
public function verwijderDruif(evt:MouseEvent):void
{
evt.target.parent.removeChild(evt.target);
}
When I use removeChild in another function (called by the onComplete in the tweenlite), it won't work, because he don't know which berry to remove..
If somebody can help me, this would be very usefull for me,
thanks in advance!
Laurent


Reply With Quote

Bookmarks