Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Do You Need To Clear Intervals In This Case?



I have an AS class that accepts a movieclip in the constructor and tells that mc to blink via setInterval(). Now, this movieclip is in an external SWF and loaded into another using MovieClipLoader. So the movieclip is loaded on stage and blinking. If I perform a removeMovieClip on that blinking mc do I need to call a clearInterval before removing?



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 02-22-2007, 10:44 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Clear ALL Intervals ?
hi there,

i 'd like to know if there is a way to clear all Intervals in a movie with one command...

in my current project I use setInterval()
very often in different clips and though i cleanly put the corresponding clearInterval() commands in the script I realized, that on slow computers some of them don't get stopped...
which puts more weight on the CPU and sometimes slows down the comp very much.

is there a fix ?


tia

Clear/Set Intervals
I was wondering if someone can tell me if there is a way to find out what Intervals are currently active within a movie. I haven't come across a built in function, but does anyone have a hack?

Thanks!

[F8] Help To Clear All Intervals
I need to clear all intervals within my mcKeyimage mc on the root when I go to other frames on the root not containing the mcKeyimage. The problem is I'm unable to figure out how to reach into the mcKeyimage to clear the interval that's running.

The mcKeyimage has timers set to go to other frames for fades in/out like like this:

(inside mcKeyimage)
on frame1:

Code:
stop();

var imageFader:Number = setInterval(nextframe, 4000);

function nextframe() {
gotoAndPlay(2);
trace("image2 interval called: "+getTimer()+" ms.");
}
on frame2:

Code:
clearInterval(imageFader);
trace("cleared image1 interval");

this.onEnterFrame = function(){
image1._alpha = Math.max(0, image1._alpha - 10);
image2._alpha = 100 - image1._alpha/10;
if (image1._alpha <= 0) {
delete this.onEnterFrame;
}
}
...and so on for 5 images.

My navigation is within a mc on the root:

in mcMainnav there is a mc with this function on it - I traced the clearInterval and on just the press, the key image is still fading:

Code:
onClipEvent(enterFrame){
onPress = function(){
_root.keyimage.clearInterval(imageFader);
trace("cleared interval");
_root.keyimage.stop();
trace("keyimage stopped");
}
onRelease = function(){
_root.gotoAndStop("426market");
}
}

Thanks for any help you can give!!
Matt

Clear All Intervals?
Hello all,

Any help or guidance on this would be greatly appreciated.....

Is there a way to see or clear ALL intervals?
Also..
Is there a way to list all MovieClips on _root and MovieClips within MovieClips?

TIA,
jc_

Is There A Command To Clear All Intervals ?
Hi there

I was wondering if there's a way to clear all currently running intervals without doing each one individually ?

thanks

Losing My Mind...please Clear My Intervals
Hi,

after using setInterval a billion times, i am now having the most unbelievable problems with it!!!

i got some buttons, when clicked they call a daisychain of functions, ending with a loadMovie function:


ActionScript Code:
function loadInMovie(clickedButt, arrayPos){    contentMain.detail.detailImage.holderMc.loadMovie(array_clientImage[arrayPos]);    meMov = setInterval(loadUp, 15);    }


so this triggers:


ActionScript Code:
function loadUp() {    contentMain.preloader._alpha = 100;    var bytesL = contentMain.detail.detailImage.holderMc.getBytesLoaded();    var bytesT = contentMain.detail.detailImage.holderMc.getBytesTotal();    var percent = bytesL/bytesT*100;    if (bytesL>=bytesT && bytesT>4) {        trace("done loading");        loaderOff();//function to clear preloader        clearInterval(meMov);        } else {        contentMain.preloader._xscale = percent;    }}


pretty standard right? Ok so when i click a link, the preloader kicks in and it works fine, calling loadOff() and tracing "done loading".

if i then press another button same thing.

BUT if i press another button before the current movie has finished loading, the preload bar adjusts and loads the new movie, but when complete, i get an infinite loop of traces and the loaderOff function doesn't kick in.

so i guess the clearInterval is breaking down, but why? and how to fix?

basically the **** thing breaks down on me!!!

please, any ideas why? i'm losing my mind on this one!

Losing My Mind...please Clear My Intervals
Hi,

after using setInterval a billion times, i am now having the most unbelievable problems with it!!!

i got some buttons, when clicked they call a daisychain of functions, ending with a loadMovie function:


ActionScript Code:
function loadInMovie(clickedButt, arrayPos){    contentMain.detail.detailImage.holderMc.loadMovie(array_clientImage[arrayPos]);    meMov = setInterval(loadUp, 15);    }


so this triggers:


ActionScript Code:
function loadUp() {    contentMain.preloader._alpha = 100;    var bytesL = contentMain.detail.detailImage.holderMc.getBytesLoaded();    var bytesT = contentMain.detail.detailImage.holderMc.getBytesTotal();    var percent = bytesL/bytesT*100;    if (bytesL>=bytesT && bytesT>4) {        trace("done loading");        loaderOff();//function to clear preloader        clearInterval(meMov);        } else {        contentMain.preloader._xscale = percent;    }}


pretty standard right? Ok so when i click a link, the preloader kicks in and it works fine, calling loadOff() and tracing "done loading".

if i then press another button same thing.

BUT if i press another button before the current movie has finished loading, the preload bar adjusts and loads the new movie, but when complete, i get an infinite loop of traces and the loaderOff function doesn't kick in.

so i guess the clearInterval is breaking down, but why? and how to fix?

basically the **** thing breaks down on me!!!

please, any ideas why? i'm losing my mind on this one!

Convert Lower-case To Upper-case While Typing In Input Field
Hi,

is it possible to convert lower-case text to upper-case while typing in the input text field? In example: if a user type lower-case text in input text field, the upper-case is used instead. I'm using String class and toUpperCase() method, for converting other text.

Thanks, M :D ario

How To Know If A Letter Is Upper Case Of Lower Case
Hi,

I am trying to extract letters from a string and I want to know if a letter is lower case or higher case.

for sure I can do something like:


Code:
var i:String = "L"
var j:String = i;

i.toLowercase();

if(i == j){trace("i is Lower case");}else{trace("i is Higher case");}



.
But I feel guilty while using this code...

I am pretty sure I can do something with the 16 bit code work that String.charCodeAt() gives... but what?!?!? (Do I look like someone who dont know s..t about ascii!?)

Most probably capital letter and small letter are one after the other or so but what order and what code to use to put the code back to letters?

thank you!

Upper Case Lower Case Problem
Ok I have a line in my actionscript that goes like this:

mySnd.loadSound("http://www.blahblah.com/mp3/mp3up/" + _root.user + ".mp3" ,true)

_root.user is given to it via url var.

If the file name that wants to be played is Mike and _root.user is mike it wont play the file, but if i rename the mp3 to mike.mp3 it works.

I want it to play the file regardless of case... how can I do this?

Clear Button Work To Clear All The Lines Drawn On The Board
hi i need help in regrading to my school project... here is my project... i have been stuck with this for the pass 2 weeks and i still cant figure it out i am hoping that some one would be able to help me.

my project is that i need to click 3 points on the board to draw line connecting the points which i have done.

but i need help in getting my clear button work to clear all the lines drawn on the board

and also to allow the program to draw another sets of lines after the first line has been drawn

and also an undo button that will undo the previous line drawn

Clear Stage And Clear Class Values?
I'm working with this tutorial to create a quiz, but modifying it to load the data from XML: Create a Quiz Application Using AS3 Classes

I would like to put a retry button at the end that would clear all previously set values and clear all the display objects that I've added to the stage and basically start the file over again as if it was the first time. Is this possible?

I would think there's an easy way since it is using external class files... I hope it doesn't require a lot of manual Remove Child At and clearing variable and array values.

Case Of The Double Case
Hey there,

I am trying to combine each of these scrips. The first script is the keylistener on a frame of the MC. This allows the user to use keys to navigate:

code: // TOOLS MENU - EXPORT - EXPORT LIST SELECTION

keyListener_TOOLSExport_Export_List = new Object()
keyListener_TOOLSExport_Export_List .onKeyDown = function() {
switch (String.fromCharCode(Key.getAscii())) {

case "k" :// K (OK)
_root.Tools_Export.gotoAndStop("EXPORT-TIME DATA");
Key.removeListener(keyListener_TOOLSExport_Export_ List);
break;

default :
break;
}
};
Key.addListener(keyListener_TOOLSExport_Export_Lis t);

Now this is on a button on the same frame. The idea is to take the user back to the page they came from:

code: on (release) {
switch (ToolsExportFrame) {
case 1: // Tools_Export_Time
_root.Tools_Export.gotoAndStop("EXPORT-TIME DATA");
break;

case 2: // Tools_Export_Depth
_root.Tools_Export.gotoAndStop("EXPORT-DEPTH DATA");
break;

case 4: // Tools_Export_Auto
_root.Tools_Export.gotoAndStop("PRINT-AUTO");
break;

}
}

Now...what I would like, is to have it so when a user presses a key, it checks to see where they came from, and sends them back to the previous frame, like the second code does.

Any ideas?

Thanks,

Jeff

Clear Images On Flash Not Clear On Net
I have imported 2 pictures into my library, used the bitmaps in flash converted to symbols for editing. They look great when in flash but they are very pixelated when viewed on the web. Dont know why, quality is all the way up, jpg setting is all the way, it has to do with the way it is published internally. here take a look............. www.newrealitydesigns.com In reference to the table.

If anyone knows whats up let me know.

new_reality@411.com

Intervals?
hi, i have one interval at every 40secs which makes my enemys apear on screen i want another interval that is always 10secs earlier, which will display a warning saying that the enemy are coming.

i tried this but didnt work cant seam to change interval time once set?

setInterval(enemyapear, 40000);
warnspeed = 30000
setInterval(attackwarning, warnspeed);

the attackwarning makes the messge apear and add 1 to a list each time.

then on a onEnterframe i had if statements that if a list was 1 then set warnspeed to 70secs and after that if list >1 then add 40secs to the warnspeed eachtime it was completed.

Help With Some Intervals
i'm trying to make this setInterval. which is supposed to change a swf file every 5 secs but i'm not sure if i'm doing the right thing, ohh yeah i'm making this so it just progresively getting a file with a higher number...

but here is the actual code i got so far.

code: var slideInfoLV:LoadVars = new LoadVars ();
slideInfoLV.onLoad = function(success) {
if (success) {
slideCounter();
} else {
frameNum.text = "error";
}
}

slideInfoLV.load("vars/back_info.txt");

var curFrameNum:Number = 0;

function loadFrame () {
_level0.myMCL.loadClip("background/back" + curFrameNum + ".swf", this.backMC);
}

loadFrame();

onLoad = function (){
if (curFrameNum < Number(slideInfoLV.totalBacks) - 1){
setInterval(loadFrame,50000);
curFrameNum++;
}else {
curFrameNum = 0;
}
loadFrame();
slideCounter();
}

Help With Intervals, AS2
Hi I'm using FLash CS3 but working, as required, in AS2. I am modifying a slideshow tutorial so that users can press a button and skip to the slide they would like to view. This function works but I am having trouble with the clearing and resetting of the interval. After pressing one of the buttons, it seems there might be2 intervals running? Anyway, something is messing up the timing, even though the order remains fine. Can anyone point out what I'm doing wrong with that part? Download the fla here:

http://www.aftermath-creative.com/mw2.2.fla (4.9 MB)

and here is all the code I am working with, and it's the button codes that are messing things up (I think):


Code:
stop();

import mx.transitions.Tween;
import mx.transitions.easing.*;

var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 5;
var tweenTime:Number = 1;

pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);

function crossfade() {
if (currClip == pic1) {
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};


listen = new Object();
Key.addListener(listen);

buttons.firstButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic0');
};

buttons.secondButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic1');
};

buttons.thirdButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic2');
};

buttons.fourthButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic3');
};

Intervals
I need help setting Intervals.

Here is my code.

intervalId = setInterval(_root, "gotoAndPlay", 3900, "Loader", "1");
stop();

Next frame:
clearInterval(intervalId):

The problem is when I run the swf file or the exe file it doesn't work it skips to the beginning og the movie.

It works just fine when I preview in flash.

Can anybody help?

Different Intervals
Hi. I'm making a slide show. The images are in a txt file so what my script does is this:

I used setInterval to call a function but the time to call the function is always the same. What I want is that every image is displayed on diferent intervals.

My txt file: &time=2000,5000,1500,9000

that's the time for each image. How can I use this?

How can I make each image displays in it's right time?

thank you.

Using Intervals
I want to have a button that when moused over, slowly fades to 100% alpha, and when moused off, fades back away to 0%. My code works fine if I mouseover the button, wait for it to fade all the way up, and then mouse off.

If I quickly mouse over it and then just as quickly mouse off of it, it fades up perfectly fine, but then does NOT fade back away.

I set this up by creating a movie clip of the button fading in for 20 frames, stopping, and then fading out for 20 frames. It is called crystal1.

I am using intervals to run a function every frame that checks what the current frame is, and if it had finished playing the previous part of the movieclip to play the next part.

Any help would be greatly appreciated!










Attach Code

on (rollOver) {

clearInterval( interval1off );
var interval1on
interval1on = setInterval(crystal1on, 83);

function crystal1on() {

if ( _root.crystal1._currentframe == 40 or _root.crystal1._currentframe == 1 ) {

_root.crystal1.gotoAndPlay(1);
clearInterval( interval1on );

} else if ( _root.crystal1._currentframe == 20 ) {

clearInterval( interval1on );
}
}
}


on (rollOut) {

clearInterval( interval1on );
var interval1off
interval1off = setInterval(crystal1off, 83);

function crystal1off() {

if ( _root.crystal1._currentframe == 20 ) {

_root.crystal1.play();
clearInterval( interval1off );
}
}
}

Intervals?
can we have an actionscript where there is a button to control the movement of the object and not add setInterval in it?

A Little Help With Intervals..
Hi all! I need a little help with some stuff again. I've basically got a bit code that produces a line of numbers as navigation and most of it was written by stringy.

Here is the previous thread:

http://www.kirupa.com/forum/showthread.php?t=266639

The buttons work, but when I click on them I also want my slideshow to stop and possibly stay highlighted.

here is the bit of code that controls selecting the image and stuff:


ActionScript Code:
function dorelease() {    clearInterval(myInterval);    this._alpha = 100;    p = this.ivar-1;    nextImage();}


The clearInterval stuff normally stops the slideshow, but in this location it doesn't so I'm guessing it's something to do with _root or _level etc. But for the life of me I can't quite figure it out at the moment.

This is the bit of code that generates the buttons:


ActionScript Code:
mask._visible = false;function getButtons() {    mask._width = 0;    var clip = this.createEmptyMovieClip("paper", 10000);    //clip.setMask(mask);    clip._y = 556;    clip._x = 10;    for (var i = 0; i<cliparray.length; i++) {        var clap = clip.attachMovie("btn", "btn"+i, i);        clap._x = (clap._width+5)*i;        clap.ivar = i;        clap._alpha = 40;        clap.myText.text = i+1;        //clap.onPress = dopress;        clap.onRelease = dorelease;        //clap.onReleaseOutside= doreleaseOutside;        clap.onRollOver = dorollover;        clap.onRollOut = dorollout;    }    //mask.onEnterFrame = grow;}

How To Get Something To On Intervals
I have a enemy clip and a fire clip. Now I want to make the enemy fire every once in 5 seconds, how is this achieved?

Help With Intervals
Hi I'm using FLash CS3 but working, as required, in AS2. I am modifying a slideshow tutorial so that users can press a button and skip to the slide they would like to view. This function works but I am having trouble with the clearing and resetting of the interval. After pressing one of the buttons, it seems there might be2 intervals running? Anyway, something is messing up the timing, even though the order remains fine. Can anyone point out what I'm doing wrong with that part? Download the fla here:

http://www.aftermath-creative.com/mw2.2.fla (4.9 MB)

and here is all the code I am working with, and it's the button codes that are messing things up (I think):


Code:
stop();

import mx.transitions.Tween;
import mx.transitions.easing.*;

var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 5;
var tweenTime:Number = 1;

pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);

function crossfade() {
if (currClip == pic1) {
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};


listen = new Object();
Key.addListener(listen);

buttons.firstButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic0');
};

buttons.secondButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic1');
};

buttons.thirdButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic2');
};

buttons.fourthButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic3');
};

Playing Mcs In Intervals
was wondering if anyone had a good aproach to play different mcs with a certain pause between each play command

i used to just put something at the end of an mc's timeline that would play the next mc... but i want to try and centralize the code

i have a few mc... all sitting there with a stop in begining and end... i want to say mc1.play(); ... wait 2 sec... mc2.play()... wait 3 sec ... etc

any ideas?

Intervals Problem
Please help
What's wrong in this code?
Why do the 3 objects open with the same interval (1 second), when I set 3 different intervals?
Please help me fix this script...
Thanks a lot!

Keypress Intervals
i have a keypress, but i don't want it to repeat itself at a unbelievable speed. I would like the actions only to happen, at the fastest, half a second apart. This is my code:

on (keyPress "w") {
this.container.attachMovie("ollie", "container", 10);
_root.score = _root.score + 20;
}


I just want it so you can't hold down the button and rack up the points. Somekind of SetInterval thing. What script would i use?

Toggle At Intervals
Hi everybody,

I've got a movie clip called "modes" with only two frames and a stop action on each one. I want to toggle between these two frames at 10 second intervals. The problem with my code is that is keeps looping back to the first frame without ever resting on the second one. Here's what I've got:
_______________

function switchModes(direction) {
modes.alphaChange = -3;
modes.destinationframe = modes._currentframe+direction;
if (this._currentframe = 1) {
direction = 1;
} else {
direction = -1;
}
}

//change modes every 10 seconds
setInterval(switchModes, 10000);

//fade
modes.onEnterFrame = function() {
this._alpha += this.alphaChange;
if (this._alpha < 0) {
this.alphaChange=this.alphaChange*-1;
this.gotoAndStop(this.destinationFrame);
}
if (this._alpha > 100) {
this.alphaChange = 0;
this._alpha = 100;
}
}
_______________

Any ideas?

Thanks.

Interupt Intervals?
I give up. Can anyone tell me how i interrupt/stop an interval using a button. I've attached my TESTS.fla

The animation i have is in a movieclip. its in content movieclip: then on frame 30, inside changeImage movieclip is the animations and code. Please someone help me and my stupidness......

Problem With Intervals
What i wish to do is tht: flash takes coordinates from .php file and adds them to a mc_object, and updates coordinates after period of time.
I got it work but very buggy. I want flash to take new coordinate after every 1 second(or so), instead of doing tht, flash gives me 100 new coordinates in a second. Changing the interval doesn't make big change.

Have a look at your self:
http://www.zone.ee/avp2estclan/texttest5.swf

Here's the source code:

code: //Loads variables from .php file
loadVariablesNum("replay2.php", 0);

//function for global (not to look)
ball.onEnterFrame = function () {
function coordinate(a, b, c) {
return ((a-b)/c);
}

//sets variable arv equal to 0
arv = 0

// function update starts for script looping (problem starts)
function update() {
// sets coordinates right for _global stuff...(not to look)
ax1 = coordinate(bx1, 370000, 496);
ay1 = coordinate(by1, 6376000, 488);
//adds +1 on every loop to variable arv
arv = arv + 1;
// joins the string "x" and "y" with number arv
bx1 = eval("x"+arv);
by1 = eval("y"+arv);
// check up
trace (ax1);
trace (ay1);
//sets ball coordinates equal to the coordinate got from .php file
setProperty(ball, _x, ax1 );
setProperty(ball, _y, ay1 );
}
// sets the update interval(problem ends(not realy, bec it doesn't work as needed))
interval = setInterval(update, 250);
}

The .php file source:

PHP Code:




&&x1=590081&&y1=6526734&&x2=543431&&y2=6583217&&x3=563168&&y3=6501676&&x4=634040&&y4=654914







And the source file:
http://www.zone.ee/avp2estclan/test.rar

I appriciate any help i can get.

Intervals And Path
do you old pros set all your intervals in _root?

had a problem stopping an interval in a loaded movie, this is the answer?

[F8] Intervals And Buttons
I am trying to put an interval inside of a button but for some reason it never calls the function(func2).

Here is the code in my button:
code: on (release)
{
func1();
}

and here's my code in Layer 1, Frame 1:
code: _root.stop();

func2 = function()
{
this.dice.gotoAndStop(rdmno);
clearInterval(timer1);
}

func1 = function()
{
rdmno = Math.floor(Math.random() * (20)) + 1;
this.dice.gotoAndStop(21);
timer1 = setInterval(func2, 2000);
}

[CS3] Help With Intervals, I Can't Get Them To Work
Hi i am using as2 and i am somewhat new to flash and what i am trying to accomplish right now is to only advance to the next frame in the animation after a certain amount of tine rather than every frame. The reason i need to use intervals is because how fast the image changes is based on how fast the object is moving. So the faster it goes the faster the animation.

Here is my code

Code:
attached=true;

var updateImage = setInterval(function() {
this.gotoAndStop(_currentframe+1);
},(60/image_speed));

function onEnterFrame(){
if (attached==true){
this.image_speed=_root.player.image_speed;
this._x=_root.player._x;
this._y=_root.player._y;
this._rotation=_root.player._rotation;
}
}


the only variable that you really need to know is image_speed which is anywhere from 0.5 to 1.5. So if that is the case shouldn't my image only go to the next frame every 33-66 Ms? Because right now no matter what i set image_speed to it updates every step.

If you could help me i would appreciate it alot. Thanks

AS2.0 - For Loops And Intervals
Hey guys,
I'm trying to create a fade in and fade out effect with just Action Script and I'm having a bit of trouble. I'm no Action Script expert but I was able to decode a few things to put some code together. This is basically what I'm trying to do:

on (rollOver) {

var myInterval = setInterval(FadeUp, 1000);
function FadeUp () {
for (i = 0; i < 30; i++) {
brightcounter +=1
clearInterval(myInterval);
setBrightness(FirstNews_btn,brightcounter);
trace(brightcounter);

}//End For Loop
}//End of Function

}//End

The brightness fuction is defined somewhere else so dont worry about that. The problem is between the for loop and the intervals. What it's doing is delaying the evaluation of the for loop for the interval seconds, rather than delaying each for loop evaluation by the interval second. How do I correct this?

So what it does is when you roll over something, it holds than evaluates the for loop. What I want it to do is roll over something, evaluate once, then wait by seconds defined, then evaluate again till i > 30.

Array Of Intervals
So I have an array of interval names...

interN = ["id1","id2","id3","id4","id5","id6","id7","id8 "];

My for loop
for(i = 0;i < canN.length;i++){
n = "pd1.drip" + (i+1) + ".drip" + (i+1);
interN[i] = setInterval(wait,100,n,interN[i]);
}

My wait function
n= name of the instance
p= name of the interval id

wait = function(n,p){
eval(n).gotoAndPlay(2);
clearInterval(eval(p));
}

the wait function is not clearing the interval...
Is there something i am missing?

Problem With Intervals
I'm having an odd problem with intervals. I've posted about this before but never got an answer. Since then I've made some changes and modifications to that flash movie.

After loading a flash movie into another movie (home page) I then can click on a button to take me to another part of the site. then click back and it goes back to the home page. After you go back to the home page the interval I'm using to call a timed function messes up and calls randomly.

To see what I mean go to http://www.juliaveenstra.com and click gallery and then click home. watch the background pictures and you should see what I mean.
I've tried clearing the intervals, redefining them etc. with no luck. I'm really not sure what's going on here.

Any help is appreciated,
Thanks,

Intervals For Slideshow
Hi guys, have a problem, i made this flash presentation that consists of 8 slides all in all, one frame per slide, is there a way for me to set an interval for the slide like 30 secs before proceeding to the next slide? using action script ofcourse, i was wondering if i could avoid using the animation timeline. btw im using flash mx only not mx 2004. thanks

Toggle Between Intervals
I'm trying to toggle between intrvlFast and intrvlSlow. This is not working.


PHP Code:



Movieclip.prototype.startScale = function() {
    scaleIt = function (mc) {
        mc._xscale = mc._yscale += 10;
        updateAfterEvent();
    };
    this.onRelease = function() {
        if (!this.fast) {
            clearInterval(this.intrvlSlow);
            intrvlFast = setInterval(scaleIt, 25, this);
            this.fast = true;
        } else {
            clearInterval(this.intrvlFast);
            intrvlSlow = setInterval(scaleIt, 25, this);
            this.fast = false;
        }
    };
};
mc1.startScale() 




Any help?

Thanks in advance.

Can Get It To Play In Intervals
Just new to AS. So bear with me.

This script is inside a movie clip, of a star which shoots up along _y axis decelerating as it goes up and also fades out and starts again at the bottom to repeat the process. But I just need it to shoot up in 5 second intervals. So every 5 seconds it'll shoot up and fade out. I've tried setIntervals but it wouldt work for me (I'm sort of new at this to know what I'm doing ).

This is the script, sorry it's kinda messy I commented some things at:

onClipEvent (enterFrame) {
currentlocx = this._x;
currentlocy = this._y;
ball1locy = this._y + accely;//speedy1;
differencey = newY - currentlocy;
accely = differencey/accelFactor;
if (ball1locy < 0 + radiusball1) {
this._y = 78;
} else {
this._y = this._y + accely; //speedy1;
}
this._alpha = (this._y * 100) / 80;
}

onClipEvent (load) {
newY = 0;
speedy1 = -0.8;
speedx1 = 0;
radiusball1 = this._width/2;
accelFactor = 25;//Math.ceil(Math.random()*25) + 2;
}

Intervals Vs OnEnterframe
"Uses setInterval to emulate onEnterFrame events with decreased CPU usage"

I found this statement. Is this true? or is it if setIntervals are set to occur less than FPS ?

If Statement With Different Intervals
Hy there, wonder if anyone can help me out...

I'm doing a calculator in wich I have to perform an action according to result intervals of a dynamic box.
ie. When the result inthe dynamic box is between 25 and 30, it has to perform some action. If the result is between 30 and 35, a diferent action, and so on...
I have made a button to perform the if statement, but I can't specify more than one condition, can I?

I tryed to use some line codes like these:

ActionScript Code:
if(Number(25)<Number(dynamicbox)<Number(30)){
 myaction;
}
if(Number(30)<=Number(dynamicbox)<Number(35)){
 myaction2;
}

Someone have a clue for this?

Thanx a lot!

edu

Timing And Intervals
I'm sure this topic comes up often but I figured ... umm - well here it is again...
I'm wondering about he acuracy of timing. When I run an interval I can see some drift. With a simple application I'm calling an interval every 100 ms that gets the timer. these are the results

496
672
848
1024
1201
1376
1553
1728
1904
2076
2248
2351
2528
2704
2882
3057
3232
3409
3584
3763
3936
4112
4288
4464

that looks like some serious drif issue to me if the timing is off by 80%. In my practice I found that it's the getTimer is not very reliable, whereas the interval does a pretty good job. I don't really have a way of testing it really though. I'm planning on creating a small audio app. but the last time I tried it, with sounds a little appart, I heard some sounds drift quite often.
I recall hearing that this has been tuned a bit in the mx2004 version but I don't know if that's just a rumor
any thoughts on this?

Am I Clearing My Intervals?
hi all,

this is my code with the setinterval

Code:
function showPortfolio(selected, clip, xValue, yValue) {
var clip = this.createEmptyMovieClip("clip", 10);
clip._x = xValue;
clip._y = yValue;
for (i=0; i<selected.length; i++) {
clip.attachMovie(selected[i], selected[i], setDepth(i));
clip.selected[i]._alpha = 0;
}
portfolioInterval = setInterval(this, "showNextNav", 2000, selected, clip);
}
Now on each button I have

Code:
on (press) {
clearInterval(portfolioInterval);
showPortfolio(projectA, projectA_mc, 30, 50);
}
on (press) {
clearInterval(portfolioInterval);
showPortfolio(projectB, projectB_mc, 30, 50);
}
Am I really deleting portfolioInterval???

how can one trace all intervals???

Random Intervals
I have a ball that moves a long on a motion guide and it loops. Instead of having it loop constantly, I want it to loop, but at different intervals, like it would pause a few seconds then play.
Anyone got any ideas? Thanks in advance.

Intervals || Loop || Other
I have been working with flash since flash 4, but have just recently moved into MX actionscript & AS 2.0. I appreciate all the info on this website and forum, it has been an excellent resource.

I am building a movie where I need to "wait" until a scripted animation is complete before continuing the code. What is the best way to do this? Some reason it feels sloppy to do a while loop. Is there a way to use intervals or events to trigger this?



//discover if an additional expansion is needed
if(orgincmc!=optionid){

//HERE I MUST WAIT until previous move has been completed

containerexpand(optionid);
centerm(optionid);
this.cmc=optionid;
}

Thanks!

Time Intervals ?
Could someone tel me.... how to make some action happens after some time ??
I mean... imagine I have a ball moving randomly through the stage....
I want that... the ball stays on it's place for some time... then move to somehwere else.... stay there a while.... en repeat.


HOW ?

THANKS !!
Bye.

Intervals Without SetInterval()
Since Flash doesn't like to wait for loadVariables to actually receive the information, I need to find a way to make flash look from time-to-time to see if the information has been received.

I would use setInterval, only it's really buggy and there's a high chance the interval will be called again by the user, which will completely mess everything up.

I also cannot use something like this:

onEnterFrame {
count++;
if (count > 10){
count = 0;
....
}
}

because the movie is stopped.

Does anyone know another way to make some form of timer that will count to x seconds?

Problem With Intervals
What i wish to do is tht: flash takes coordinates from .php file and adds them to a mc_object, and updates coordinates after period of time.
I got it work but very buggy. I want flash to take new coordinate after every 1 second(or so), instead of doing tht, flash gives me 100 new coordinates in a second. Changing the interval doesn't make big change.

Have a look at your self:
http://www.zone.ee/avp2estclan/texttest5.swf

Here's the source code:


ActionScript Code:
//Loads variables from .php fileloadVariablesNum("replay2.php", 0);//function for global (not to look)ball.onEnterFrame = function () {   function coordinate(a, b, c) {    return ((a-b)/c);    }    //sets variable arv equal to 0arv = 0// function update starts for script looping (problem starts)function update() {// sets coordinates right for _global stuff...(not to look)ax1 = coordinate(bx1, 370000, 496);ay1 = coordinate(by1, 6376000, 488);//adds +1 on every loop to variable arvarv = arv + 1;// joins the string "x" and "y" with number arvbx1 = eval("x"+arv);by1 = eval("y"+arv);// check uptrace (ax1);trace (ay1);//sets ball coordinates equal to the coordinate got from .php filesetProperty(ball, _x, ax1 );setProperty(ball, _y, ay1 );}// sets the update interval(problem ends(not realy, bec it doesn't work as needed))interval = setInterval(update, 250);}


The .php file source:

PHP Code:



&&x1=590081&&y1=6526734&&x2=543431&&y2=6583217&&x3=563168&&y3=6501676&&x4=634040&&y4=654914 




And the source file:
http://www.zone.ee/avp2estclan/test.rar

I appriciate any help i can get.

Scope Of Intervals
Hi,
To set the scene I've a flash movie loading a separate flash movie on the click of a button. This imported movie has a interval set to delay it playing.

My problem is that when the button is clicked more than once the interval will remain along with a new interval. I've been trying to clear the first interval from within the button code, and tryed to clear existing intervals on the load of the new movie, with no success. The ID of the intervals are available from within the button.

Are the Intervals available globally or tied to the movieclip they are created?

Thankyou for any help.

Copyright © 2005-08 www.BigResource.com, All rights reserved