Skip to main content
Known Participant
April 22, 2014
Question

Strange way of animating a movieclip

  • April 22, 2014
  • 2 replies
  • 2637 views

I have analized all the code of a project, in one of it's classes there's a propertie(variable) that increments within a function, it is actually an animation step, and the only ways to play a movieclip's next frame is using gotoAndPlay, gotoAndStop, prevFrame and nextFrame, but in the class it is just this..

   public function hurt(_damage:Number):void

   {

       //trace("hurt", health, _damage)

       health-=_damage

       if(health <= 0)

       {

            kill=true

            health=0

       }

       animationStep=5 - health

       trace(animationStep);

}

So what makes flash know that animationStep is a way of animating a movieclip if it's only an interger variable declared inside the class body? I mean you would put this.. gotoAndPlay(2); for example, and not "animationStep=5 - health. As far as I know the compiler doesn't know that animationStep is a propertie of the movieclip class. It is just an interger variable. And as I said I analized all the code and there's nothing that proves that the compiler will know that "animationStep" is a propertie of the movieclip class, thanks in advance.

Any help would be very appreciated.

This topic has been closed for replies.

2 replies

Amy Blankenship
Legend
April 22, 2014

Is there a setter for animationStep?

Look for something like:

public function set animationStep(value:int):void {

     if (value != _animationStep) {

          _animationStep = value;

          //do something else here

     }

}

If you can set up the project in Flash Builder, then just click animationStep in the code and press F3, and it will take you to its definition. However, it's not a trivial thing if you don't already know how to set up a project properly. If you don't know how to do this, try searching on "set animationStep".

Known Participant
April 22, 2014

I get what you guys say, but it doesn't answers to my question, If we could talk on inbox I would understand better, or even i could zip the project to you to see it, what do you think?

Known Participant
April 22, 2014

If your question was "So what makes flash know that animationStep is a way of animating a movieclip if it's only an interger variable declared inside the class body?"

Flash doesn't know and doesn't need to know what a variable does, it just needs to process that variable per the coding instructions provided by the programmer.  Somewhere the variable is used, and it is up to you to figure out where that is and how it is used.  Have you tracked it down yet?  See where and how it is used will lead to you determining how it fits into any animation it might be involved in, if it is.


Believe it or not, that variable isn't involver into anything that could lead to an animation.

Ned Murphy
Legend
April 22, 2014

The animationStep variable is declared somewhere, and that is how the compiler comes to know of it.  You will need to track down where and how animationStep gets used.  It might be used to limit the amount of movement an object makes, or it might be an adjustment to a new frame of an animation that gradually shows the object becoming weaker in some way as health decreases, or it might be used some other way.