A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [AS 2] Problem with code execution delay for unknown reasons

Threaded View

  1. #1
    Senior Member Alluvian's Avatar
    Join Date
    Jun 2006
    Posts
    967

    [AS 2] Problem with code execution delay for unknown reasons

    The following code is on a movieclip being used as a button.

    Background
    The code is pretty simple. Originally the code was just the code after the gap. This code loaded up a movieclip (filtermc) off-stage that runs through an xml file and preloads a form. This takes a second or two, and when finished that newly loaded movie tweens into position. The tween code is on a frame in the 'filtermc' movieclip.

    The problem is that in the second or two that it takes for this movie to load, people could click the button a second time which messes up the form/movieclip (everything on it is unresponsive, I think because two movieclips having the same name)

    Anyway, I decided to solve this problem by loading a transparent blocker movieclilp in front of this button to keep it from being double clicked. This blocker clip is just a movie that has an empty onRelease function in it so that the button below it cannot receive any new clicks. Also, the button goes to another frame where it says "loading..." to provide feedback to the user.

    The Problem
    When I click this button, there is a delay of about 2 seconds before the semitransparent (for testing) blocker appears. In fact it appears just as the filtermc clip has started it's tween into place.

    It is almost like this code is running out of order. The traces come back in the correct order so I know it is not running out of order, but why the 2 second delay before the blocker movie gets loaded up? The button also takes 2 seconds to show the "loading" frame. The traces also have the same 2 second delay.

    If I comment out the second half of the code (the filtermc part) then the blocker movieclip pops up instantly and the button changes frame instantly.


    PHP Code:
    on (release) {
        
    //problems occur if button is pressed twice before filtermc scrolls into view
        //this button must be disabled until the filtermc finishes loading
        //load up a blocker movie to intercept mouseclicks
        
    var filterblocker:MovieClip;
        
    filterblocker _root.attachMovie("blocker_mov","filterblocker",1900,{_x:70,_y:288,_height:40,_alpha:50});
        
    trace("blockerloaded");
        
    this.gotoAndStop("loading");

        
        var 
    filtermc:MovieClip;
        
    // 2000 is an arbitrary number chosen to get above the other movieclips.  getNextHighestDepth() returns 1048576+ when components are on the stage
        //movie is made offscreen and is tweened in on the second frame of the movie to let it load first.
        
    filtermc _root.attachMovie("filterscreen","filterscreen",2000,{_x:-340,_y:0});
        
    trace("filter panel called");

    Please help, this is driving me nuts!
    Last edited by Alluvian; 05-08-2009 at 11:27 AM.

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