A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: onData or onLoad???

  1. #1
    Senior Member
    Join Date
    Oct 2004
    Rio de Janeiro, Brazil

    onData or onLoad???

    Hi there!

    Since some time ago, I have developed a lot of Flash projects with database integration (even in PHP as will in ASP).

    Though, there is something that bugs me... onData and onLoad events used in LoadVars. As you already know, the basic method to access an external script is:

    PHP Code:
    DataSender = new LoadVars();
    DataReceiver = new LoadVars();
    // put here the function to receive data sent back
    DataSender.sendAndLoad ("scriptname",DataReceiver,"POST"); 
    However you need to get ready to receive the data sent back to Flash (as commented above), by the script. Well, normally, I do that by using onLoad event, this way:

    PHP Code:
    DataReceiver.onLoad = function()
    trace (dataReceiver);} 
    Ok, it works like a clock. However, it the server fails, sometimes Flash keep trying and waiting forever.

    Then, I found out that using onData event, you can prevent server timeout, this way:

    PHP Code:
    DataReceiver.onData = function(src)
    if (
    src == undefined)
    trace ("server failed"); }
    trace ("ok"); }

    The problem is that, if you use onLoad you cannot prevent server failure. However if you use onData, you CAN prevent server failure but DataReceiver will not be loaded with content sent back to Flash for the script.

    Anyone there know how to deal with that?

  2. #2
    Senior Member
    Join Date
    Oct 2004
    Rio de Janeiro, Brazil

  3. #3
    Join Date
    May 2004
    onLoad parses (escapes) the string and assigns it to the loadVars object.
    onData doesnt' and passes the value to a single argument.

    comment out either one - they both produce the same net.
    var a=new LoadVars();
    AFAIK, that's the only difference.

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    London, UK
    heres a thought:

    If you want to know whether the server has failed but still use (onLoad) use this trick. Define a variable WITHIN the onLoad handler for e.g var myNumber:Number = 10;

    Then outside of this function define a setInterval which runs only once for e,g after 1- secs. In this function check the value of myNumber, if it is undefined..u know mosy likely there is some server problem
    Flashmatics | Flashmatics Library (free downloads)
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    Flash Certified Developer

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