Skip to main content
Known Participant
October 22, 2010
Answered

How to animate objects on screen on certain events

  • October 22, 2010
  • 1 reply
  • 547 views

I want to make the clown dance when he catches a hat (I have a tween for that) who otherwise will be simply standing, Basically I need to animate objects on certain events and then stop, I see so many game makers doing that, I know nothing about it, tried a lot on my own but with no success

This topic has been closed for replies.
Correct answer

a simple sample:

you can download it here: http://www.flashdersi.com/flash/diger/adobeforum/hittest.fla

import flash.events.Event;

addEventListener(Event.ENTER_FRAME,fCheck);
var bMove:Boolean = false;
function fCheck(evt:Event)
{
if (! bMove)
{
  if (mcHandClown.hitTestObject(mcHat))
  {
   bMove = true;
   mcClown.gotoAndPlay(2);

  }
}
if(mcClown.currentFrame==1)
{
  bMove = false;
}

}


mcHat.startDrag(true);

1 reply

Correct answer
October 22, 2010

a simple sample:

you can download it here: http://www.flashdersi.com/flash/diger/adobeforum/hittest.fla

import flash.events.Event;

addEventListener(Event.ENTER_FRAME,fCheck);
var bMove:Boolean = false;
function fCheck(evt:Event)
{
if (! bMove)
{
  if (mcHandClown.hitTestObject(mcHat))
  {
   bMove = true;
   mcClown.gotoAndPlay(2);

  }
}
if(mcClown.currentFrame==1)
{
  bMove = false;
}

}


mcHat.startDrag(true);

fopgamesAuthor
Known Participant
October 22, 2010

Thank you very much, I didn't know that method at all

October 22, 2010

You are welcome.