Groups | Blog | Home
all groups > flash actionscript > october 2004 >

flash actionscript : preloading #includes with load()


Nytyme
10/10/2004 8:54:20 PM


I have an #include issue.


I have several AS files that perform setup for my movies. One loads
variables, one sets styles, etc.
The problem is ActionScript doesn't wait for code to finish executing before
moving on, specifically in the case of load().
So, #include "variables.as" will run and move onto #include "styles.as"
before variables.as has even loaded the txt file containing the variables I
want to create.

How can I make it wait programmatically?


Currently I have an onLoad call to the next AS file. BUT I don't always us the
same AS file and want them to run standalone.

I could create a frame that contains stop(); #include "variables.as" and has
an onLoad function do a play();
then in the next frame have a stop(); and #include "styles.as". This will
most likely work... but it seems amaturish.

I want a programmatic solution, not a hard coded Timeline solution.

Can anyone help me out?

Thanks
Rothrock
10/10/2004 9:22:12 PM
I think you've got a few issues to work out.

First be sure you understand #include. This is something that is only dealt
with at compile time. The #include cannot be changed based upon any user input
or time or what ever you wan't to base it on. Basically it is just a way to
save you having to type code into the actionscript window. Again, it is only
looked at at compile time!

Now if within the #include you have loads it depends upon which version of
Flash you are using. There are a lot of tricks that have been developed. With
Flash MX they introduced the loadVars class. Check it out in the help files,
especially the onLoad event.

Before that, people would often put a variable at the end of their file such
as fileLoaded=true. Then they would have an onEnterFrame that checked to see if
fileLoaded == true.

If you post a bit more on what you are trying to do and which version of Flash
you are using, perhaps we can help you some more.
AddThis Social Bookmark Button