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?

Ned Murphy
Legend
April 27, 2014

at all this, is all about blitting animation, yeah Ned the object looks damaged when it has been hit, they make that variable an offset of the next frame, but the question now is, how do they represent that variable as a frame? now im suspecting about this code

public function blitClip(_clip:MovieClip):BitmapData

                    {

                              // make it the length of the clip

                              var totalFrames:int=_clip.totalFrames

                              var width:int=Math.floor(_clip.width * GameData.Instance.RENDER_SCALE)

                              var height:int=Math.floor(_clip.height * GameData.Instance.RENDER_SCALE)

                              //                              trace("BLIT SIZE:" + width, height, "totalFrames:" + totalFrames)

                              var _bmpd:BitmapData=new BitmapData(width * totalFrames, height, true, 0)

                              for(var i:int=0; i < totalFrames; i++)

                              {

                                        renderMatrix.identity()

                                        renderMatrix.scale(GameData.Instance.RENDER_SCALE, GameData.Instance.RENDER_SCALE)

                                        renderMatrix.translate(width * .5 + width * i, height * .5)

                                        _clip.gotoAndStop(i + 1)

                                        _bmpd.draw(_clip, renderMatrix, null, null, null, true)

                              }

                              return _bmpd

                    }


If your concerns are about the variable "animationStep" then you should be presenting code that references it, meaning code that includes it somewhere.

As far as the new code you show, what are you suspecting about it?  You should start a new posting for each new piece of code that has you questioning it.

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.