Hi I have set up a system that spawns barriers for the player to dodge but it appears the functions won't trigger properly from within "if" statements. I've put nots on my code to guide you through what is going on. PLEASE HELP ME!!!
PHP Code:
var speed:Number=2;
var 
barNumber:int=6;
var 
barLoop:int=0;
var 
timer:Number=0;
var 
limit:Number=100;

//Works (Spawns Barrier and moves)
spawn();

//Doesn't work (Spawns barriers but doesn't move)
//Runs every frame
function timedSpawn():void{
    if(
timer >= limit){
        
spawn();
        
//Resets timer
        
timer 0;
    }else{
        
timer += 1;
    }
}

//Run once when barrier needs to be created
function spawn(){
    
//Random side of the screen
    
var screen_side:Number=Math.round(Math.random()*3);
    
//Library reference
    
var barTemp:MovieClip=new bar;
    
//Give MovieClip a number
    
this["bar"+barLoop]=barTemp;
    
//Add new movieclip to stage
    
addChild(this["bar" barLoop]);
    
//Individual sides saved for movement later
    
this["side"+barLoop]=screen_side;
    
//X/Y and Rotation Depending on the Randomly Generated Screen Side
    //Right
    
if (screen_side==0) {
        
this["bar"+barLoop].x=820;
        
this["bar"+barLoop].y=Math.round(Math.random()*(500-100))+100;
        
this["bar"+barLoop].rotation 90;
    }
    
//Left
    
if (screen_side==1) {
        
this["bar"+barLoop].x=-20;
        
this["bar"+barLoop].y=Math.round(Math.random()*(500-100))+100;
        
this["bar"+barLoop].rotation 90;
    }
    
//Top
    
if (screen_side==2) {
        
this["bar"+barLoop].x=Math.round(Math.random()*(700-100))+100;
        
this["bar"+barLoop].y=-20;
    }
    
//Bottom
    
if (screen_side==3) {
        
this["bar"+barLoop].x=Math.round(Math.random()*(700-100))+100;;
        
this["bar"+barLoop].y=620;
    }
    
//Change number for next barrier
    
barLoop += 1;
}
//Runs every frame
function moveBarriers():void {
    
//Resets the loop to run through all the barriers on stage again
    
barLoop=0;
    
//Moves each individual barrier on stage in a direction dependant on the side they spawned on
    
while (barLoop barNumber) {
        if(
this["side"+barLoop]==0){
            
this["bar" barLoop].-= speed;
        }
        if(
this["side"+barLoop]==1){
            
this["bar" barLoop].+= speed;
        }
        if(
this["side"+barLoop]==2){
            
this["bar" barLoop].+= speed;
        }
        if(
this["side"+barLoop]==3){
            
this["bar" barLoop].-= speed;
        }
        
barLoop=barLoop+1;
    }

Please ask me any questions if you still can't understand my script. I really need help with this.