as3 tracking number value of variables

Posted by Wade D Ouellet on Stack Overflow See other posts from Stack Overflow or by Wade D Ouellet
Published on 2010-03-11T05:31:13Z Indexed on 2010/03/11 5:33 UTC
Read the original article Hit count: 313

Hi, I have a bunch an as3 game going. In my game when newCrag hits egg_mc the score gets added.

// Add the score
var newScore:score_mc;
newScore = new score_mc();
addChild(newScore);
newScore.x = 20;
newScore.y = 20;
newScore.score_txt.text='0/15';
var score:Number=0;

function getEggs(event:Event):void {

    if(event.target.hitTestObject(MovieClip(root).newCrag) && event.target is egg_mc) {

        sndEgg.play();

        if(event.target.stage) {
            event.target.parent.removeChild(event.target);
        } 

        // Increase score
        score++;
        newScore.score_txt.text = "" + score + '/15';

    }

}

I am trying to refer to the number value of the score using if statements. I need to change the speed variables based off the number that is inside the score box.

var speed:Number

if(score > 10 || score == 10) {
    speed=20;
    trace("speed3");
} else if(score > 5 || score == 5 && score < 10) {
    speed=18;
    trace("speed2");
} else {
    speed=14;
    trace("speed1");
}

However, this part of the code is not working. Any help would be much appreciated.

Thanks,

Wade

© Stack Overflow or respective owner

Related posts about as3

Related posts about actionscript