PDA

View Full Version : variable issues


rizzo265
09-28-2007, 12:26 PM
I've made a short exercise where I want the score to +1 or -1 depending upon whether two movie clips collide. If they collide, I'd like the score to -1. If they don't collide, I'd like the score to +1 on the last frame. The text field shows that they do collide successfully, I'm just not sure what script to use to make the score change, and where to put it.

Thanks for any help.

WhidbeyTomas
09-29-2007, 07:17 PM
First, a quick tip. Create one layer for code (label it code or action). That way others don't have to hunt for it.

You can create a hit test for your collision (on the main timeline).

onEnterFrame=function(){
if(myArrow.hitTest("target_mc")){
myScore++;
}
}

WhidbeyTomas
09-29-2007, 07:26 PM
Remember that there are three kinds of text fields: static (just for show), dynamic (displays a variable value), and input (accepts a user entered value for a variable). Your score = should be a static text box, not a dynamic text box.

Try Colin Moock's ActionScript for Flash MX: the difinitive guide, as a coding reference.

Jedimace
09-29-2007, 07:47 PM
Also you might want to change how much score it adds so use this its kinda self-explanatory
_root.score += 1
and check the first tutorial it tells you all about it!

Lucidity
10-17-2007, 09:28 PM
Also you might want to change how much score it adds so use this its kinda self-explanatory
_root.score += 1
and check the first tutorial it tells you all about it!

_root.score++ would also work

Noct
10-17-2007, 09:34 PM
score++ and score+=1 achieve the same results.
They are both shorthand for score = score +1

Lucidity
10-17-2007, 09:45 PM
I stand corrected.