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.
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.
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".
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?
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.
Copy link to clipboard
Copied
Believe it or not, that variable isn't involver into anything that could lead to an animation.
Copy link to clipboard
Copied
That's not hard to believe - it could be used for anything. So does that answer your question?
Copy link to clipboard
Copied
No, but I keep telling you, if you could see it yourself it would be better.
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.
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.
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?
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.
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.
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.
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
}
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.
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.
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...
Copy link to clipboard
Copied
the animationStep is representing the frame, and as I said before it is doing it with an odd method.
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.
Copy link to clipboard
Copied
Grep tools, what's that?
Copy link to clipboard
Copied
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".