A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Can a For loop run within an interval?

  1. #1
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160

    Can a For loop run within an interval?

    This may be a shot in the dark but does anyone know if you can run a For loop within an interval? I am running the below code and for whatever reason when I run “barPosDwn()” without the interval (press and release the button) the For loop runs just fine. However when I run “barPosDwn()” from and interval (press and hold the button) the trace on the For loop comes back undefined.

    Does anyone have any ideas? Any help would be greatly appreciated.

    PHP Code:
    sDSS_btn.onPress = function(){
        
    barPosDwn();
        var 
    barPosDwnTime:Number getTimer()/1000;
        
    barPosDwnTimerFun(barPosDwnTime);
    }
    sDSS_btn.onRelease = function(){
        
    delete this.onEnterFrame;
        
    clearInterval(barPosDwnInt);
    }
    function 
    barPosDwnTimerFun(barPosDwnTime) {
        
    this.onEnterFrame = function() {
            if ((
    getTimer()/1000)-barPosDwnTime>.25) {
                
    barPosDwnInt setInterval(barPosDwn_root.intervalSpeed);
                
    delete this.onEnterFrame;
            }
        };
    }
    function 
    barPosDwn() {
        
    optionBar int((setOpBar._y)*10)/10;
        if (
    ok == true) {
            if (
    optionBar>=151.9 && optionBar<=281.9) {
                
    ok false;
                
    endP optionBar+26;
                
    motionT = new Tween(setOpBar"_y"Regular.easeInOutoptionBarendP.4true);
                
    //this prevents the bar from going out of sequence
                
    motionT.onMotionFinished = function() {
                    
    ok true;
                };
            } else if (
    optionBar == 307.9 && set11._y != 311.8) {//This controls the MC movement
                
    ok false;
                for (
    i=1i<12i++) {
                    
    this["set"+i]._y -= 26;
                    
    trace(this["set"+i]._y);
                }
                
    ok true;
            }
        }

    Last edited by hts5000; 12-23-2009 at 09:38 AM.

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    I didnt look very long..

    but sometimes when using THIS in a function can lead to path trouble..

    try to hardcode first to see if this is the problem.

  3. #3
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    Thanks Whispers!!! I was scratching my head for a day over that.

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    was that it then?

    I barely looked at your supplied code.. and that was first thing that caught my eye is all..

    if its not..I can look a better look..(later)

  5. #5
    Senior Member hts5000's Avatar
    Join Date
    Oct 2007
    Posts
    160
    Yup, that was it. The code above was located in a clip that was located in another clip so replacing "this" with "_root.mc1.mc2" fixed the issue. I knew the code "should" have worked so it was really throwing me for a loop. This is a new weird bug that I just have to be aware of in the future. Thanks again for your help!

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