This content has been marked as final.
Show 5 replies
-
1. Re: Where to put initialization functions?
Newsgroup_User Jul 21, 2006 7:35 AM (in response to Guest )A _global, or timeline flag variable would work perfect for this.
Something like so:
var isInited:Boolean = false;
function doInit(){
// do init stuff here
isInited = true;
}
if(!isInited){
doInit();
}
Once doInit runs it sets isInited to true and so won't be called again...
HTH
Dave -
2. Re: Where to put initialization functions?
Newsgroup_User Jul 21, 2006 7:41 AM (in response to Guest )My bad - don't initialize isInited to false - leave it undefined:
var isInited:Boolean;
If you set it to false it will get set to false everytime you enter the
frame, so the init code would run again...
Dave -
3. Re: Where to put initialization functions?
panell Jul 21, 2006 7:43 AM (in response to Guest )There is a bether way :]
-
4. Re: Where to put initialization functions?
Rothrock Jul 21, 2006 7:49 AM (in response to Guest )Also, I think you have misunderstood the purpose of onEnterFrame(). It is poorly named and doesn't mean when you enter the frame.
What it really means is to do something repeatedly at the frame rate – even if the timeline is stopped.
So:
this.onEnterFrame=function(){
myInitialVariable=10;
}
Means it will set the variable 20 or 30 times each second (or whatever your frame rate is) until you tell it: delete this.onEnterframe.
Other than that, the best thing to do would be to read all the entries in the help file for the MovieClip class. There you will find the lovely onLoad event. Make a new movie with maybe 10 frames and put this code in the first frame. Then test it and watch.
this.onLoad=function(){
trace("hello world");
}
trace("How are ya"); -
5. Re: Where to put initialization functions?
Newsgroup_User Jul 21, 2006 8:22 AM (in response to Guest )>>
this.onLoad = function(){
//functions
}
<<
That is better, though I was showing how to use the boolean flag var as
he said he couldn't make it work that way and it's a must to know how to
use simple variables in this manner.
Dave