# Help with Variable, from my scene to a movieClip

**URL:** <https://forum.kirupa.com/t/help-with-variable-from-my-scene-to-a-movieclip/328422>\
**Category:** flash\
**Created:** [May 16, 2012, 9:16am UTC](https://forum.kirupa.com/t/help-with-variable-from-my-scene-to-a-movieclip/328422 "2012-05-16T09:16:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bimzy](https://avatars.discourse-cdn.com/v4/letter/b/34f0e0/32.png) [@Bimzy](https://forum.kirupa.com/u/Bimzy)\
**Post date:** [May 16, 2012, 9:16am UTC](https://forum.kirupa.com/t/help-with-variable-from-my-scene-to-a-movieclip/328422/1 "2012-05-16T09:16:20Z")

</div>

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:

```auto
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:

```auto
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.
