• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Strange way of animating a movieclip

Community Beginner ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

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.

TOPICS
ActionScript

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 21, 2014 Apr 21, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

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".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

That's not hard to believe - it could be used for anything.  So does that answer your question?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

No, but I keep telling you, if you could see it yourself it would be better.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

Put a breakpoint on the line where animationStep is set, then use step into to see where things go when that variable changes.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

You only mentioned that once, so I don't see where that amounts to "keep telling you".  Most people including myself won't download files from these forums. 

Maybe it's time to ask your question again because you seem to have answered the only question I could find in your original posting.  You asked what makes Flash know that animationStep is a way of animating, and your last answer indicated it has nothing to do with animating... so that question doesn't need to be asked.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

Is it possible there is something else, like a controller or something further up the Display List, that could be watching that MC and telling it to change frames based on that value?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 22, 2014 Apr 22, 2014

Copy link to clipboard

Copied

Yup... I am imagining it might have to do with changing the appearance of the object as its health declines as opposed to actually animating anything... as in shifting to a different set of animation frames/visuals where the characater looks more or less fatigued depending on how the health is going.  But it could be anything. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 23, 2014 Apr 23, 2014

Copy link to clipboard

Copied

No, I mean that literally some piece of code could be using an ENTER_FRAME or timer handler to check that variable and then execute the goToAndStop or something.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 23, 2014 Apr 23, 2014

Copy link to clipboard

Copied

Yup... I already touched on the various possibilities of what it might be used for... it could be anything we might imagine.  I'm just trying to get michaeljose to find that out by looking for it.

The only thing shown of that variable so far is one line.  It has to exist elsewhere, but nothing has been shown for that. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Copy link to clipboard

Copied

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

                    }

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 27, 2014 Apr 27, 2014

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Copy link to clipboard

Copied

I see they're making the total movieclip's frames to the value of a new variable, and then they increase the index by, may this be the animation? I jusk keep saying, if u put a variable inside the body and you just use it like it was a default class propertie, like gotandplay, who do flash knows it is representing the fraames of that, movieclip, believe me, there's not more code to chek out.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 27, 2014 Apr 27, 2014

Copy link to clipboard

Copied

I'm a bit mystified how that blitting code is even working--I think it could possibly work in FP 9, but in FP 10+ I'd expect that you would need to wait for the RENDER event before your draw() would get the contents of the frame. Not that this has anything to do with your question...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 27, 2014 Apr 27, 2014

Copy link to clipboard

Copied

the animationStep is representing the frame, and as I said before it is doing it with an odd method.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 28, 2014 Apr 28, 2014

Copy link to clipboard

Copied

What grep tools have you used to try to find where it's referenced? Maybe you need to try a different one.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 28, 2014 Apr 28, 2014

Copy link to clipboard

Copied

Grep tools, what's that?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 28, 2014 Apr 28, 2014

Copy link to clipboard

Copied

LATEST

https://www.google.com/search?btnG=1&pws=0&q=grep+tools#pws=0&q=grep+tools

Note that if you're using Flash builder, you can right-click on a Class member and see where it is being used by selecting "References".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines