interval in onclip events
Hi,
since this thread is about intervals, I would like to contribute something I recently found answering somebody's problem. Here is a script to control onClip Events in movieclips:
PHP Code:
onClipEvent (load) {
c=1;//defining the initial value of var c.
}
onClipEvent (enterFrame) {
if (c == 10){//this is the interval frequency
trace("it is working!");
c=1;//reset var to original value
}
c++;//increment c
}
:)
Re: interval in onclip events
Thanks for the input cancerinform :)
Id suggest the following altercation to the code
PHP Code:
onClipEvent (load) {
c=1; // defining the initial value of var c.
}
onClipEvent (enterFrame) {
if (c == 10){ // this is the interval frequency
trace("it is working!");
c=1; // reset var to original value
}else{
c++; // increment c
}
}
The change is putting the c++ in the else of the if statement. This is because, if its not, after you set c back to 1 when c is 10, c++ gets called again and is actually 2 instead of 1. Now, if c is 10, the c++ wont be called and it will stay 1 until the next frame where its checked again :D
another for the setInterval experts
thanks for all of the amazing code thus far. i believe i have a decent handle on how to use setInterval in a standard context, but i am working on an XML fed array to plot points on a map. the following code works well, but plots all of the points at once. what i would like to try to do is implement a delay after each item [i] is populated until all of the [i]s are done. this way the population will flow in over time rather than all at once. any ideas where to implement the code into this? :
// XML load successful
if (gXML.hasChildNodes()) {
//pull in list
listnode=gXML.firstChild;
//load description (children of main node)
if(listnode.hasChildNodes()){
var i =0;
var project = listnode.firstChild;
while(project != null){
trace(project.attributes.id);
name = "icon" + i;
//attach an item button for each item
this.attachMovie("icon",name,i);
//set the button attributes (name and id)
this[name].title = project.attributes.title;
this[name].location = project.attributes.location;
this[name].id = project.attributes.id;
//display the button
this[name].gotoAndPlay("display");
//set its position
this[name]._x = project.attributes.location_mapx;
this[name]._y = project.attributes.location_mapy;
this.list[i] = project;
project = project.nextSibling;
i++;
}
}
}
stop();
Re: MX setInterval Explained
[QUOTE]Originally posted by senocular
[B]I did this one tonight at the request of Jaffasoft ;)
Im a little tired so I hope there arent TOO many mistakes heh. And I didnt include an Appendix as I did with ASBroadcaster, though I dont think theres really as much you can do to extend the use of setInterval. The applications section give some basic usage. Should be a pretty decent go through on the function though:
http://www.umbc.edu/interactive/flas...?p=setInterval
---------------------------------
Cenocular,
When I tried using the following script in your turorial I received an error. I must be doing something wrong.
Error::::
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 1: Statement must appear within on handler
displayTime=30;
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 3: Operator '-' must be followed by an operand
displayTime-;
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 2: Statement must appear within on handler
countDown=function(message){
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 9: Statement must appear within on handler
timer=setInterval(countDown, 1000);
Ginns