okay, so im new too programming and have just started out with AS3, im working on a school project to make a educational game. However im strugling with variables. i declared a int variable in my scene(frame 11) and then used this variable in a movieClip. Here is my code:
Scene 1, Frame 11:
import flash.events.MouseEvent;
//Variables
[COLOR=#ff0000]var speed:int = 1[/COLOR]
var score:Number = 0
var highscore:int = 0
var rndLow:int = 1
var rndHigh:int = 24
var rndLetter:Number = Math.floor(Math.random()*(1+rndHigh-rndLow))+rndLow;
var myString:String= String(rndLetter);
var currentState:int = 1
var btnResumes:MovieClip = new btnResume();
var btnPauses:MovieClip = new btnPause();
var btnPlays:MovieClip = new btnPlay();
btnPlays.x = 115
btnPlays.y = 180
btnResumes.x = 115
btnResumes.y = 180
btnPauses.x = 115
btnPauses.y = 180
addChild(btnPlays)
function plays(event:MouseEvent):void
{
removeChild(btnPlays)
addChild(btnPauses)
currentState = 3
}
btnPlays.addEventListener(MouseEvent.CLICK, plays);
function resumes(event:MouseEvent):void
{
removeChild(btnResumes)
addChild(btnPauses)
currentState = 3
}
btnResumes.addEventListener(MouseEvent.CLICK, resumes);
function pauses(event:MouseEvent):void
{
removeChild(btnPauses)
addChild(btnResumes)
currentState = 2
}
btnPauses.addEventListener(MouseEvent.CLICK, pauses);
function mainMenu1(event:MouseEvent):void
{
if (currentState == 1)
{
removeChild(btnPlays)
} else if (currentState == 2)
{
removeChild(btnResumes)
}else
{
removeChild(btnPauses)
}
gotoAndStop("Menu")
}
btnToMenu1.addEventListener(MouseEvent.CLICK, mainMenu1);
lblLol.text = myString
gotoAndStop("Game")
and here is my movieClip:
if ([COLOR=#ff0000]speed[/COLOR] == 1){
this.x + 1
}else if ([COLOR=#ff0000]speed[/COLOR] == 2)
{
this.x + 2
}else if ([COLOR=#ff0000]speed[/COLOR] == 4)
{
this.x + 4
}else
{
this.x + 8
}
it comes up with error 1120, the highlighted text is the variable i am struggeling with.
Ive been looking for an answer for hours now, any help is appreciated. Bimzy :toad: ps. Toad is awsome.