A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Testing for loaded variables

  1. #1
    Junior Member
    Join Date
    Apr 2001
    Posts
    12
    Hello all

    I'm loading some variables into my Flash movie via an ASP page. It seems to me that the variables are loading, but there's some delay. Unfortunately I need to run a function as soon as the movie loads, and the variables (used in the function) are not downloading fast enough.

    The ActionScript Reference Guide mentions something about using onClipEvent() to execute commands only after a variable has loaded - only problem is that onClipEvent() seems to be permanently "greyed out" - so obviously I'm trying to use it in the wrong place.

    So my question is - how do I execute my function only after the appropriate variables have loaded? Or alternatively, when and where is the appropriate place to use the onClipEvent() ?

    While I'm on the subject, if I want to execute a function when a Flash movie loads (something equivalent to JavaScript's onLoad event), where is the best place to run it from?

    Sorry to bombard everyone with what may be simple questions . . . but such are the trials of a newbie.

  2. #2

    Smile Test a Loaded=TRUE variable

    I load variables from text files, but it's probably similar.


    Before you start loading set a variable Loaded = FALSE

    When loading variables include a variable "Loaded" and set it to TRUE

    After a few frames check the Loaded value, if its TRUE then Stop, otherwise try loading again


  3. #3
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835

    Lightbulb


    or load the variables into a movie clip and use the 'onclipEvent(load)' movie clip action. this will trigger once all data has loaded and you can put some code to continue playing the movie in the event handler.



    - n.

  4. #4
    Junior Member
    Join Date
    Jun 2001
    Posts
    2
    I've done this a couple times and it seems to work OK

    set variable loaded="false" and a load variables request on one keyframe, then about two frames later do an if loaded<>"true" go back one frame. If you go back to the load variables frame before their loaded it can cause the system to freeze. The LAST variable in your data list should be loaded=true. If you don't put it last, it will continue before they're all loaded.

    hope that helps

  5. #5
    Junior Member
    Join Date
    Apr 2001
    Posts
    12
    Originally posted by enemem

    or load the variables into a movie clip and use the 'onclipEvent(load)' movie clip action. this will trigger once all data has loaded and you can put some code to continue playing the movie in the event handler.



    - n.
    enemem

    This is exactly what I want to do (use the onClipEvent), but for some reason that particular command is "greyed out" - so I can't select it. Am I holding my mouth the wrong way??

  6. #6
    Senior Member
    Join Date
    Feb 2001
    Posts
    1,835
    Hi Borax,

    at last I've converted someone to my way of doing this! I've been trying for ever but everyone always goes for the 'loading='yes'' option! whimps!

    [back to the real world now]

    anyway, what you need to do is this:

    Take a movie clip instance on the stage [if you want, you can create a new one specifically for this and then hide it later]. Right click on the movie clip and select 'actions'.
    This is where you put the 'onClipEvent(data)' code.

    Let me know if this doesn't work, maybe I can send you an example or something...

    good luck - n.


  7. #7
    Junior Member
    Join Date
    Apr 2001
    Posts
    12
    Thanks for your help everyone . . .

    Have had to put the project on hold for a little, will try out your suggestion this week thanks enemem.

  8. #8
    Originally posted by enemem
    Take a movie clip instance on the stage [if you want, you can create a new one specifically for this and then hide it later]. Right click on the movie clip and select 'actions'.
    This is where you put the 'onClipEvent(data)' code.
    Wanted to give it a try, but I can't find the onClipEvent thingy anywhere.

    I'm not ruling out me being thick, but we are talking Flash4 here aren't we?


    Cheers

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