Question on how to use public properties


(Calem Young) #1

I’m very, very new to As3 and flashdevelop so please forgive me if this question sounds a bit stupid. My question is: what are public properties? I’ve been trying to make an object have an animation that then changes to a different animation when the first one has completly played. I was following the tutorial here: [Animation tutorial][1] And noticed that there was a link to a page about the class Spritemap which is this one: [Information on Spritemap][2] [1]: http://useflashpunk.net/intermediate/animated-sprites.html [2]: http://useflashpunk.net/docs/net/flashpunk/graphics/Spritemap.html Anyways if you follow this link you can also see a table headed “Public Properties” I saw on this table a public property called ‘complete’ and was wondering how I would use this? I was under the impression that these are already predefined variables that can be tested straight away however when I write

if (Spritemap.complete = true && Spritemap.currentAnim()="Smack") { sprHand.play("Still"); }

I get an error. So what is a public property and how would I use one?

Thanks :smiley:


(Zachary Lewis) #2

First, when checking for equality, you should be using the == (equality) operator, not the = (assignment) operator.

Second, a property is basically a function that can be used as a variable.

if (sprHand.complete && sprHand.currentAnim == "Smack")
{
  sprHand.play("Still");
}

(Calem Young) #3

Awesome it works now! Thanks so much :smile:


(Calem Young) #4

The problem I’m having now is that when I try to make the image on the mouse coordinates its not centering on the cursor. I know from previous programming experiences that this is most likely to do with the animations origin. How would I set the origin to the center of my 72 by 72 animation in code?


(Zachary Lewis) #5

Try yourSprite.centerOrigin().


(Calem Young) #6

Yup that works :smiley:


(Zachary Lewis) #7