A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS 3.0 simple boolean not returning correct value. Why?

  1. #1
    Member
    Join Date
    Jan 2009
    Posts
    30

    AS 3.0 simple boolean not returning correct value. Why?

    I have started my movie with the var "nowPlaying" to be true because "mySuper_mc" will be playing at start.
    I have then created a Timer function that will tell the "mySuper_mc" to stop playing after given amount of time and to also set "nowPlaying" variable to false, however the setting the variable to false doesn't seem to work.
    I can mouse over in the begging of the movie before the timer has stopped it and will still get the trace statement that "The Movie Is Stopped"





    PHP Code:
    stop();

    var 
    stopTime:Timer = new Timer(500);

    var 
    nowPlaying:Boolean true;

    stage.addEventListener(MouseEvent.MOUSE_OVERmousedOver);
    function 
    mousedOver(event:MouseEvent):void
    {
        if (
    nowPlaying == false);
        {
            
    trace("The Movie Is Stopped");
        }
    }


    stopTime.addEventListener(TimerEvent.TIMER,  starTimer);
    function 
    starTimer(event:TimerEvent):void
    {
        
    mySuper_mc.stop();
        
    nowPlaying false;
        
    }



    stopTime.start(); 

  2. #2
    Senior Member dudeqwerty's Avatar
    Join Date
    Mar 2005
    Location
    Bosnia
    Posts
    1,626
    It's just a simple typeo, see here:
    Code:
    stop(); 
    
    var stopTime:Timer = new Timer(500); 
    
    var nowPlaying:Boolean = true; 
    
    stage.addEventListener(MouseEvent.MOUSE_OVER, mousedOver); 
    function mousedOver(event:MouseEvent):void 
    { 
        if (nowPlaying == false); // <----------- REMOVE THIS
        { 
            trace("The Movie Is Stopped"); 
        } 
    } 
    
    
    stopTime.addEventListener(TimerEvent.TIMER,  starTimer); 
    function starTimer(event:TimerEvent):void 
    { 
        mySuper_mc.stop(); 
        nowPlaying = false; 
         
    } 
    
    
    
    stopTime.start();
    just remove the semicolon and it will work.
    New sig soon

  3. #3
    Member
    Join Date
    Jan 2009
    Posts
    30
    ohh i see! my bad. Thank you much!
    pretty new to AS . Thanks for letting me know my mistake

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Moved to the appropriate forum

    gparis

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center