A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: simultaneous LoadVars - sendAndLoads???

  1. #1
    Senior Member
    Join Date
    Oct 2002
    Posts
    113

    simultaneous LoadVars - sendAndLoads???

    Hi,

    I was wondering if anyone knew weather it was possible to perform simultaneous LoadVars - sendAndLoad?

    It appears to work when calling them, but do they happen at the *same* time?

    Thanks.

  2. #2
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    Actually one must complete before another can be called... this is at least true in MX.

  3. #3
    Arabic Flasher
    Join Date
    Jul 2001
    Location
    Saudi Arabia
    Posts
    190
    hi

    u need to use functions


    and here the code to call another loader after the one was complete

    code:

    loader1 = function () {
    TheLoader1 = new LoadVars();
    myLoadVar1 = new LoadVars();
    myLoadVar1.some_var = "your_var";
    myLoadVar1.onLoad = function(success) {
    // add some code here
    // now call the loader2
    loader2();
    };
    TheLoader1.sendAndLoad("file.php", myLoadVar1, "POST");
    };
    loader2 = function () {
    TheLoader2 = new LoadVars();
    myLoadVar2 = new LoadVars();
    myLoadVar2.some_var = "your_var";
    myLoadVar2.onLoad = function(success) {
    // add some code here
    };
    TheLoader2.sendAndLoad("file.php", myLoadVar2, "POST");
    };
    loader1();
    stop();




    at the function loader1 u'll call the loader2 after the function one was loaded successful


    hope that help u


    http://www.flashyat.com/

  4. #4
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    This was the way I achieved this in the movie I made the post about =)

    However, I was faced with this question again. I have another script which takes around 30 minutes to excecute. Unfortunatly I have to wait until it is finished until I can call other scripts. As far as I know I can't even just send variables to the first script without opening a new window... (maybe using loadvariablesNum??) or loading in new movies on different levels?

  5. #5
    Arabic Flasher
    Join Date
    Jul 2001
    Location
    Saudi Arabia
    Posts
    190
    hi

    30 minutes that is really take along or( u mean 30 seconds?)

    ok i have a solution for u

    when u call the function that take 30 minute u may want to add another function that check if that function was successful excecuted

    u can use setinterval

    code:

    function The30MinutsFunction() {
    //YOUR CODE HERE
    //after this function finish excecuted time add some var
    was_finish = true;
    }
    function callback() {
    if (was_finish) {
    //now call the other function
    clearInterval(intervalID);
    }
    }
    var intervalID;
    intervalID = setInterval(callback, 10000);
    //check it every 10 seconds
    The30MinutsFunction();



    http://www.flashyat.com/

  6. #6
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    Yes 30 minutes.

    I cannot call another script whilst I am waiting for one to load, that is the problem.

    loadVars.send opens a new window and sendAndLoad waits for the the script to fully excecute. While it is possible to *call* one whilst another is excectuing (set interval or just using the timline) only one sendAndLoad seems possible at a time.

  7. #7
    Arabic Flasher
    Join Date
    Jul 2001
    Location
    Saudi Arabia
    Posts
    190
    yes the setinterval it's ur choice now

    but for what i know that the next function will start after the preview function was success
    Code:
    m1 = function(){
    a1 = 1;
    trace("m1 was called and finish");
    return a1;
    }
    
    m2 = function(){
    a2 = 2;
    trace("m2 was called and finish");
    return a2;
    }
    
    m1();
    m2();
    m1 will start and after it's finish the m2 will be start

    so u don't need to wait it's just start after the first one was finish from excecuted


    http://www.flashyat.com/

  8. #8
    Senior Member
    Join Date
    Oct 2002
    Posts
    113
    The reason I want to call two together is to check the progress of the one that takes 20 minutes.

    This doesn't seam possible, and doing them one after the other (even if you do call them at the same time) is pointless.

    PS loadVariablesNum also waits for the script to finish executing preventing furhter send and load's to take place.

  9. #9
    Registered User
    Join Date
    Feb 2001
    Posts
    13,041
    Hi,

    one alternative: change your server code to do both tasks in parallel and return one result in the end

    another one: change your server code so that the initial call returns "job started", and further calls either return progress data or a result

    Musicman

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