-
Hi,
I have an action that must happen as soon as possible after the movie starts to play. The problem is, the action uses a variable that is in a movie which loads when the main movie begins to play, so I have to wait until the variables are all loaded to use the variable in my action.
SO, to clarify in my mind how Flash is handling the loading of the movie and its variables, I have a question....well a few actually.
1. LoadMovie DOES bring in all of the variables from the movie I'm loading, right? So not only do I have to wait for the movie to load, but I have to wait for the variables to load in as well..
2. To see if the movie and its variables are loaded, I'm checking if the particular variable I want from the movie is == "", however I can't seem to get the loop to work. I'm using a while loop which has something wrong with it because it gives me an endless loop. However, if I use a frame loop, it just keeps going through the while loop and after a few loops, my variable has loaded, so I assume it stops. It seems like I don't have much control over it though, I can't tell for sure if it has stopped looping and I do not want to drain the processing to this action. Shouldn't the while loop work fine without the frame looping it back? I'd like to just have a while loop in the parent script on startMovie instead of having it in an MC with a frame loop...Here's the code that gives me the endless loop.
Code:
count = 1;
while (_root.mapWidth == "") {
count++;
trace (count);
trace (_root.mapWidth);
}
setProperty ("_root.object", _x, 275-(_root.mapWidth/2));
So basically, this code is sitting inside an MC on the _root and runs as soon as the movie starts because as soon as the variable mapWidth is loaded, I want it to reposition object. How can I do this in my parent script on startMovie without getting into an endless loop???
3. If the above method won't work I was considering another:
I was reading about onClipEvent(data) in the Flash Reference and it said "When specified with a loadMovie action, the data event occurs repeatedly, as each section of data is retrieved." So what is a 'section of data'? Does this mean after each symbol loads and each variable loads, it would carry out my action? I guess that would not be a good alternative.
But, "When specified with a loadVariables action, the data event occurs only once, when the last variable is loaded." So would it be worth while to use this method and add a LoadVariables action right after my LoadMovie action, or would the clipEvent(data) only see my LoadMovie action since it occurs before LoadVariables??
Basically, I just need to action to be carried out once on startMovie after the mapWidth variable is loaded. Any ideas?? Thank you so much!!
Jessica
[Edited by jstrobel on 08-15-2001 at 11:00 AM]
-
Ok I'm still working on this.
Why will my set property command,
Code:
setProperty ("_root.object", _x, 275-(_root.mapWidth/2));
...work on a mouse event but not on a frame event (the 4th frame of my movie -- the main frame after preloading)???
The variable mapWidth MUST be loaded because its value is displayed immediately in the text field and also, I have the set property code on a button and that works perfectly. It just wont work on the frame (where I NEED it to work).
Does anyone know why? This is driving me crazy!
Thank you,
Jessica
EDIT!
Nevermind...I ended up getting it to work by testing on one frame and looping back with another frame, carrying out my actions and stopping when my test is true -- not elegant at all but it works.
[Edited by jstrobel on 08-15-2001 at 03:21 PM]
-
1. Yes, but don't think of them as two seperate actions, a movie loads in frame by frame and will load any actions that are associated to that frame.
2. To check if a movie is loaded, the easiest way is to make a movie clip inside the loaded .swf and place this code on it:
onClipEvent(enterFrame){
if (_root.getBytesLoaded==_root.getBytesTotal)
//do whatever action you want
}
3. onClipEvent(data) refers to specifically loading variables into a MC and then running action once the data has loaded.
-
That's really cool. I'm going to give that a try too. Thank you. And thanks for the clarification. =)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|