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




Set And ClearInterval Problem



Hya guys,

Just getting in the AS stuff. I'm trying to make a button which, if you click it loads a movie after 2 seconds. I'm did a search on the forums and found a couple of topics about setInterval. However, I can't get it to work properly.

Probably very easy, but as of yet my undertanding of AS is limited at best.

Here is the code I use

on (release) {
function loadcontent(){
_parent.contentholder_mc.attachMovie( "content1","content", 0 )
}
intervalID = setInterval( loadcontent, 2000 );
clearInterval = ( intervalID );
}

If I delete the clearInterval line the movie does get loaded, but if I leave it there, it doesn't do anything. Does the interval get cleared before the movie is loaded or something?

Thnx in advance,

Anne



Ultrashock Forums > Flash > Flash Newbie
Posted on: 2004-12-18


View Complete Forum Thread with Replies

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

Clearinterval
ok i have a function and i call it when an objects armour reaches zero:


Code:
function reset() {
visible = 0;
_root.tank._visible = false;
_root.enemy1.invisible();
_root.enemy2.invisible();
displayTime = 3;
_root.counter._visible = true;

countDown = function(){
displayTime--;
if (displayTime == 0){
visible = 1;
_root.counter._visible = false;
_root.tank._visible = true;
_root.enemy1.reset();
_root.enemy2.reset();
this.swapDepths( 800 );
_x = random(500-50)+50;
_y = random(350-50)+50;
_root.ammo = _root.pammo;
_root.armour = _root.orginalarmour;
speed = 0;
clearInterval(timer);
}
}

timer = setInterval(countDown, 1000);

}


the problem is when i clear the interval for the first time i cant seem to reuse the interval.
is there any other way in doing that?


it can be seen here http://bratz.ath.cx/~griff/tank.1-6.html .

Help Using ClearInterval()
why dosent this work? the following is an except from my code and the "did not clear" message keeps looping.

PHP Code:




var movements = setInterval(slide, 100);
stop();
//------------------------------------
function slide() {
    if (Math.abs(still._y-still.ty)>1) {
        still._y += (still.ty-still._y)/2;
    } else {
        still._y = still.ty;
        clearInterval(movements);
        trace("did not clear");
    }
}

ClearInterval
Hi,
I am willing to figure out why the clearInterval in my example does not respond and do what he should do.
Can anybody please help me ?
Meerah

ClearInterval()
Hi,

movieA_mc contains movieB_mc where movieB is the result of a loadMovie action.

movieB_mc instigates a setInterval which I want to clear by using a button in movieA_mc.

If I apply the following action to my button in movieA_mc the interval in movieB_mc fails to clear:

movieB_mc.clearInterval(myInterval)

In theory is it possible what I want to do?

Thanks.

ClearInterval
How do I clear an interval that I set with this syntax?

Code:
setInterval(shake, 50);
Can anyone help me? Thanks.

ClearInterval
is it possible to clear an interval in an other MC? I'm trying something like: _parent.scroller.content_MC.clearInterval(slideSho w);
seems not to work...

any ideas?

thanks

ClearInterval()
OK im using clear interval in a if statement when a movieclips alpha gets below 5. The interval eases the alpha of the clip and a if statement inside a onEnterFrame event contains a trace call, clearInterval() and an unloadMovie call. When the alpha gets below 5 the trace works and the movie is unloaded, but the trace conltinues to be called. I have tried attaching the clearInterval() to the _root timeline and even the movie clip, and ive looked at the actionscript reference book and they dont say that the function has to be attached to anything. Need some assistance.

Help With ClearInterval
Hello there,

I'm trying to code a fade in/out function to decrease/increase the opacity of a background movieclip. When the user clicks on the play button the background should fade out a bit and when the video finishes playing the background should fade in back to 100.
The thing is that it seems that clearInterval is not working properly and as a beginner I can't see why. I've debbuged the code and the interval is not cleared so it keeps coming back to it over and over again. The 1st time it goes to fadeOut function, keeps decreasing the opacity of the movie clip and when it reaches a value less than 40 and it jumps to the clearInterval part. But it keeps going there all the time, so when the video is played the NetStream.Play.Stop part is executed so it calls the fadeIn function to start the process of increasing the opacity back to 100. But it does not work properly as because the fadeOut function is still running. So now both functions add/subtract a value from the alpha of the movieclip which at this point just keeps flickering.
Help me please!!!

Please take a look at the code:

stop();


// Fade In/Out

mWIPPic2._alpha=100;

function fadeOut (mClip:MovieClip):Void {
if (mClip._alpha > 40){
mClip._alpha=mClip._alpha-5;
trace (mClip._alpha);
updateAfterEvent();
}
else {
clearInterval(nFadeOutInt);
}
};

function fadeIn (mClip2:MovieClip):Void {
if (mClip2._alpha < 100){
mClip2._alpha=mClip2._alpha+1;
trace (mClip2._alpha);
updateAfterEvent();
}
else {
clearInterval(nFadeInInt); }
};

// Create a NetConnection object
var my_nc:NetConnection = new NetConnection();
// Create a local streaming connection
my_nc.connect(null);
// Create a NetStream object and define an onStatus() function
var my_ns:NetStream = new NetStream(my_nc);
// Attach the NetStream video feed to the Video object
my_video.attachVideo(my_ns);

// Buffering

// Set the buffer time
my_ns.setBufferTime(20);

my_ns.onStatus = function(info:Object) {

if (info.code == "NetStream.Play.Start") {
bufferclip._visible = false;
playclip._visible = true;
}

if (info.code == "NetStream.Buffer.Full") {
bufferclip._visible = false;
playclip._visible = false;
}

if (info.code == "NetStream.Buffer.Empty") {
bufferclip._visible = true;
}

if (info.code == "NetStream.Play.Stop") {
my_ns.seek(0);
my_ns.pause(true);
bufferclip._visible = false;
playclip._visible = true;
var nFadeInInt:Number = setInterval(fadeIn,100,mWIPPic2);}

trace (info.code);
}

// Begin playing the FLV file
my_ns.play("WIP.flv");

my_ns.pause();

// Controls
btRewind.onRelease = function() {
my_ns.seek(0);
};

btPlay.onRelease = function() {
var nFadeOutInt:Number = setInterval(fadeOut,100,mWIPPic2);
my_video._visible = true;
my_ns.pause(false);
};

btPause.onRelease = function() {
my_ns.pause(true);
};

Thanks

Marcello

[F8] How Do I ClearInterval From 1 Swf To Another?
I have a movie with a main swf loading other swf's into the main movie.

So main.swf loads in movie1.swf

movie1.swf contains a setInterval inside one of it's movie clips (the movie clip instance is named homeImages)

When I load movie2.swf into main.swf everything is working fine.

However when I load movie1.swf back into main.swf the interval running in movie1.swf -> homeImages is now running twice as fast because I didn't clear the interval.

How can I tell movie1.swf - homeImages to clearInterval from main.swf before loading in movie2.swf so my interval doesn't keep running really fast each time I unload and then load movie1.swf?

ClearInterval
Hi,


my clear interval doesnt seem to work and i got no idea why, can anyone help me or guide me along? thanks!

i paste all my script, but most is not important. Just thought it might give a better idea if i paste all. =)


Quote:




detail_lv = new LoadVars();
detail_lv.onLoad = function(success) {
if (success) {
startShow();
} else {
trace("error loading");
}
};
detail_lv.load("data/detail.txt");
var i = 0;
function startShow() {
currentSlide = 0;
loadSlides();
intervalID = setInterval(loadSlides, 1000);
}
function loadSlides() {
container_mc.setMask(_root.contentbg_mc);
animate_array = detail_lv.animate.split("<|>");
maxSlide = animate_array.length;
var depth = i;
depth_txt.text = currentSlide;
container_mc.createEmptyMovieClip("empty"+depth+"_ mc", depth);
var tempHolder = container_mc["empty"+depth+"_mc"];
tempHolder.loadMovie("data/animation/"+animate_array[currentSlide]);
container_mc.onEnterFrame = function() {
var tb = this.getBytesTotal();
var lb = this.getBytesLoaded();
var percent = (lb/tb)*100;
if (Math.ceil(percent)>=100) {
tempHolder._alpha = 0;
this.onEnterFrame = function() {
tempHolder._alpha += 10;
if (tempHolder._alpha>=100) {
tempHolder._alpha = 100;
i++;
currentSlide++;
var deleteContainer = container_mc["empty"+(depth-1)+"_mc"];
deleteContainer.unloadMovie();
delete this.onEnterFrame;
}
};
}
};
if (currentSlide>=(maxSlide-1)) {
container_mc.attachMovie("Mc_logoAnimation", "logoAnimation_mc", depth+10);
container_mc.logoAnimation_mc._x = 500;
container_mc.logoAnimation_mc._y = 350;
endShow();
}
container_mc.logoAnimation_mc.onRelease = function() {
startShow();
};
}
function endShow() {
clearInterval(intervalID);
}




is there any reason that why my clear interval doesnt work at all? thanks in advance. =)

Regards

ClearInterval
I'm having trouble clearing an Interval.

There are three MCs. Main_mc is the _parent to fadein_mc and load_mc. Fadein_mc setInterval "counter". I've been trying to clearInterval in the load_mc, but I can't target the Interval properly.

I tried:

_parent.fadein_mc.clearInterval (counter);

But is doesn't work. Any tips?

Help With ClearInterval
Hello there,

I'm trying to code a fade in/out function to decrease/increase the opacity of a background movieclip. When the user clicks on the play button the background should fade out a bit and when the video finishes playing the background should fade in back to 100.
The thing is that it seems that clearInterval is not working properly and as a beginner I can't see why. I've debbuged the code and the interval is not cleared so it keeps coming back to it over and over again. The 1st time it goes to fadeOut function, keeps decreasing the opacity of the movie clip and when it reaches a value less than 40 and it jumps to the clearInterval part. But it keeps going there all the time, so when the video is played the NetStream.Play.Stop part is executed so it calls the fadeIn function to start the process of increasing the opacity back to 100. But it does not work properly as because the fadeOut function is still running. So now both functions add/subtract a value from the alpha of the movieclip which at this point just keeps flickering.
Help me please!!!

Please take a look at the code:

stop();


// Fade In/Out

mWIPPic2._alpha=100;

function fadeOut (mClip:MovieClip):Void {
if (mClip._alpha > 40){
mClip._alpha=mClip._alpha-5;
trace (mClip._alpha);
updateAfterEvent();
}
else {
clearInterval(nFadeOutInt);
}
};

function fadeIn (mClip2:MovieClip):Void {
if (mClip2._alpha < 100){
mClip2._alpha=mClip2._alpha+1;
trace (mClip2._alpha);
updateAfterEvent();
}
else {
clearInterval(nFadeInInt); }

};// Create a NetConnection object
var my_nc:NetConnection = new NetConnection();
// Create a local streaming connection
my_nc.connect(null);
// Create a NetStream object and define an onStatus() function
var my_ns:NetStream = new NetStream(my_nc);
// Attach the NetStream video feed to the Video object
my_video.attachVideo(my_ns);

// Buffering

// Set the buffer time
my_ns.setBufferTime(20);

my_ns.onStatus = function(info:Object) {

if (info.code == "NetStream.Play.Start") {
bufferclip._visible = false;
playclip._visible = true;
}

if (info.code == "NetStream.Buffer.Full") {
bufferclip._visible = false;
playclip._visible = false;
}

if (info.code == "NetStream.Buffer.Empty") {
bufferclip._visible = true;
}

if (info.code == "NetStream.Play.Stop") {
my_ns.seek(0);
my_ns.pause(true);
bufferclip._visible = false;
playclip._visible = true;
var nFadeInInt:Number = setInterval(fadeIn,100,mWIPPic2); }

trace (info.code);
}

// Begin playing the FLV file
my_ns.play("WIP.flv");

my_ns.pause();

// Controls
btRewind.onRelease = function() {
my_ns.seek(0);
};

btPlay.onRelease = function() {
var nFadeOutInt:Number = setInterval(fadeOut,100,mWIPPic2);
my_video._visible = true;
my_ns.pause(false);
};

ClearInterval
Dear Colleagues,

I have two clips that load in different swfs. The loaded swfs both have intervals in them.

ActionScript Code:
holder_mc1.loadMovie("HNI_Pos_Full.swf");
holder_mc2.loadMovie("HNI_Neg_Full.swf");

My problem
When the user advances a frame the clips are dropped but the intervals are still running. Here is the output.

holder_mc1 SEC: 0 TOTAL: 4
holder_mc1 SEC: 1 TOTAL: 4
holder_mc1 SEC: 2 TOTAL: 4
holder_mc1 SEC: 3 TOTAL: 4
holder_mc1 SEC: 4 TOTAL: 4
holder_mc1 SEC: 0 TOTAL: 4
holder_mc1 SEC: 1 TOTAL: 4
SEC: 26 TOTAL: undefined
SEC: 29 TOTAL: undefined
SEC: 32 TOTAL: undefined

As you can see it is still runnnig, but it doesn't know what object it belongs to. Therefore, my clearInterval doesn't know where to find it.


ActionScript Code:
clearInterval(holder_mc1.pauseInterval);
clearInterval(holder_mc2.pauseInterval);

Do you have any suggestions on how to kill this interval? Thanks.

ClearInterval
I have root.swf & a.swf & b.swf

when a.swf is loaded into root.swf, it has a SetInterval
but the user has an option to load b.swf to replace a.swf

when this happens b.swf is loaded but the SetInterval Process is still running



I tried using clearInterval within b.swf but it doesnt work



help please

or is I is there a clear All Intervals function that I can use to solve this?

ClearInterval
i had put this script on the frame but it keeps on going to the next frame.


PHP Code:



function wait() {
    gotoAndStop(3);
}
setInterval(wait, 2000); 





how can stop it ?? someone has told me to use "clearInterval" but dont know how apply it. please help.

Help With ClearInterval
onClipEvent (enterFrame) {
function rekka() {
_root.rekka_mc._x = 640+random(400);
_root.rekka_mc._y = random(400);
}
if (this.hitTest(_root.rekka_mc)) {
_root.rekka_mc._x+=13; //there to stop the rekka_mc from moving
var test;
test = setInterval(rekka, 100);
clearInterval(test);
}
}


I want the code to do the rekka function once! but it doesnt move that rekka_mc anywhere? If I dont use clearInterval it does the rekka funciton over and over again...
SO HOW DO I GET IT TO DO THE REKKA FUNCTION ONCE!
PLEASE HELP

ClearInterval
thanks for the help on my prev question.

is there a way to clear an interval set on one function from another?


Code:
function A(){
trace("something");
clearInterval(nClear);
}

function B(){
var nClear:Number = setInterval(A, 100);
}

B();
i mean, to clear the interval i just need an index number of nClear,
but i cant pass it to function A by writing it as an argument.

thanks.

ClearInterval
Hi all,
I'm trying to clear an interval, but it doesn;t seem to work. It looks like it creates an interval on top of another one. Is it because of my onEnterFrame?

Thanks in advance


Quote:




var intervalID:Number;

function delayedFadeInA () {
intervalID = setInterval(delayedFadeInB, 3000);
}

function delayedFadeInB (){
clearInterval (intervalID);
var rollOverTween:Object = new Tween(_root.roll_mc, "_alpha", Strong.easeOut, 0, 100, 1, true);
rollOverTween.onMotionFinished = function () {
startMovie = true;
}

}

_root.onEnterFrame = function(){
delayedFadeInA();
}

ClearInterval - I'm Just Not Getting It...
Hey all,
I just can't seem to get the clearInterval to work. I start it at the beginning of my movie, and try to disable it while someone is clicking on a slider. I just can't seem to get it at all. I have even just assigned the actions to two buttons to start and stop it, and once it starts, the button to stop it doesn't work. Perhaps I am just missing a piece of punctuation or something. At any rate - shouldn't something as simple as this work... This is in a frame script.

setInterval(adjustScroll, 20);
//
mcSlider.onPress = function() {
this.startDrag(false, 328, 125, 328, 385);
clearInterval(adjustScroll);
};
//
mcSlider.onReleaseOutside = mcSlider.onRelease = function () {
this.stopDrag();
setInterval(adjustScroll, 20);
};

ClearInterval()
I have a few slides in separate .swf files which im loading one at a time, using loadMovie()
these slides are using setInterval() to pause for 4 seconds before moving to the next pic.

//*** CODE:
stop();
pausePic = setInterval ( this, "nextFrame", 4000 );

//*** CODE on the following frame:
clearInterval (pausePic);
play();

this works with no problems when i load each one..
The problem comes when i'm unloading the swf. I thought by unloading the movie, it automatically clears all Intervals. But thats not the case. When i load the same slide swf again, these things happen randomly...

*start to play for a few frames, then stop.
*start playing, but the pausePic intervals are reduced in time. The more times i load the quicker the intervals are.
*not play at all
*start to play, but 1 frame at a time... almost 1 to 2 frames per second

My question is, How do I clear each Interval on unloadMovie() ?

I tried to have a clearInterval(pausePic); at the beginning of each slide.swf, and also tried to clearInterval() from the unloadMovie() function, but that doesn't work either.

Any Ideas what might be happening?

Thanx in advance.

ClearInterval
The clearInterval is not working. This code is for a scrubber on a voice mail player. The first time the scrubber is clicked on, you can drag the scrubber to any point in the voice mail with no glitches. On the second voice mail, or any after the first, the scrubber pops back and forth across the scrubberBar. I believe it is because the clearInterval is not clearing the variable "id" from setInterval. I am just stuck, and I am wasting a lot of time on such a simple issue. Please help







Attach Code

function scrubSet()
{
var id:Number = 0;
stream_ns.onMetaData = function(evt:Object):Void
{
duration = evt.duration;
ratio = _root.scrubberBar._width / duration;
id = setInterval(updateKnob, 50);
}

stream_ns.onStatus = function(evt:Object):Void
{
if (this.time > 0 && this.time >= (duration - 0.5))
{
trace("Video complete");
clearInterval(id);
delete this.onStatus;
}
}

function updateKnob():Void
{
_root.scrubber._x = _root.scrubberBar._x + _root.stream_ns.time * ratio;
_root.counter.htmlText = stream_ns.time;
}
_root.scrubber.onPress = function():Void
{
clearInterval(id);
stream_ns.pause(true);
var vertical:Number = _root.scrubberBar._y + (_root.scrubber._height / 2);
this.startDrag(
true,
_root.scrubberBar._x,
vertical,
_root.scrubberBar._x + _root.scrubberBar._width,
vertical
);
}
_root.scrubber.onRelease = function():Void
{
this.stopDrag();
stream_ns.seek((this._x - _root.scrubberBar._x) / ratio);
stream_ns.pause(false);
id = setInterval(updateKnob, 50);
}
_root.scrubber.onReleaseOutside = _root.scrubber.onRelease;

_root.scrubDrag.onPress = function():Void
{
clearInterval(id);
stream_ns.pause(true);
var vertical:Number = _root.scrubberBar._y + (_root.scrubber._height / 2);
_root.scrubber.startDrag(
true,
_root.scrubberBar._x,
vertical,
_root.scrubberBar._x + _root.scrubberBar._width,
vertical
);
}

_root.scrubDrag.onRelease = function():Void
{
_root.scrubber.stopDrag();
stream_ns.seek((_root.scrubber._x - _root.scrubberBar._x) / ratio);
stream_ns.pause(false);
id = setInterval(updateKnob, 50);
}
_root.scrubDrag.onReleaseOutside = _root.scrubDrag.onRelease;
}

ClearInterval
i made a news ticker...
every 8 seconds it shows a different item

When I click a button and load another movie, and return...
the delay between the newsitems is not 8 sec anymore.

When I do the same, it's even faster.

clearInterval(newTickerId);
newTickerId = setInterval(myHome.newsTicker,3000);

grtz

ClearInterval
this seams to be a simple thing to do...but for some reason it's not working
i've a mc in timeline (quintaSlide):
_root.introAnim.quintaSlide

inside this one i set a interval:
var tempoQ:Number = setInterval(goframe, 6000);

how can i clear this interval from _root?!

Cant ClearInterval
I've got 4 mc's (flame1,flame2,etc..) that im trying to fade out in a sequence using setInterval. Here's the code:

ActionScript Code:
function fadeOutFlame(target) {    target._alpha = 100;    var speed = 8;    target.onEnterFrame = function() {        if(target._alpha >= 0){        target._alpha -= speed;        clearInterval(ID1);        clearInterval(ID2);        clearInterval(ID3);        clearInterval(ID4);        }else{            delete target.onEnterFrame;        }    };}ID1 = setInterval( fadeOutFlame, 1000, flame1);ID2 = setInterval( fadeOutFlame, 3000, flame2);ID3 = setInterval( fadeOutFlame, 5000, flame3);ID4 = setInterval( fadeOutFlame, 7000, flame4);

Where I have clearInterval (4x's) only flame1 will fade out and the rest won't.
If I remove all the clearIntervals they all fade out in sequence as they should but keep repeating the fadeout function. How can I fix this? Also is there a way to clean this up with a loop maybe?

ClearInterval
I have made a couple of images on each frame with a stop command every frame. I ask the flash to go next frame after every 2 secs. So it'll show image frame by frame every 2 sec with the setInterval command.
In the setInterval, i call a function to clear the interval and goto next frame.
I load this swf in another main swf. but when i unload it by pressing a button,it keep on jump to next frame after certain of time.
Since in the main flash, i have button set to jump to spesific frame by name. it mess up my work!
How to solve this problem by preventing it from looping?
Thanx in advance!!

Please Help How To Clearinterval
Hi, please can anyone help me with this.. slide show.

it looks like the problem is that the interval has not been clear so every time i click away from my slide show (for example navigate to my contact swf) and then come back to the slide show the pictures keep looping on top of each other and fading at the wrong times too.


Does anyone know how to do it?

Ill preciate any help... couse my face starts looking like this ..

this is the code, from one of the kirupa tutorials.

var id, current;
var k = 0, p = 0;
var slide = 1;
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
}
id = setInterval(preloadPic, 100);
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images/galeria/slides/galeria.xml");
function preloadPic() {
clearInterval(id);
var con = picture.duplicateMovieClip("con"+k, 9984+k);
con.loadMovie(image[p]);
preloader._visible = 1;
preloader.swapDepths(con.getDepth()+3);
con._alpha = 0;
var temp = _root.createEmptyMovieClip("temp"+k, 99+k);
k++;
temp.onEnterFrame = function() {
var total = con.getBytesTotal();
var loaded = con.getBytesLoaded();
percent = Math.round(loaded/total*100);
preloader.preload_bar._xscale = percent;
if (con._width) {
preloader._visible = 0;
con.onEnterFrame = fadeIn;
if (slide) {
id = setInterval(nextImage, 5000);
}
delete this.onEnterFrame;
}
};
}
MovieClip.prototype.fadeIn = function() {
if (this._alpha<100) {
current._alpha -= 4;
this._alpha += 4;
} else {
current._visible = 0;
current = this;
delete this.onEnterFrame;
}
};
function nextImage() {
p<total-1 ? p++ : p=0;
desc_txt.text = description[p];
picture_num();
preloadPic();
}

preloadPic();

ClearInterval
i made a news ticker...
every 8 seconds it shows a different item

When I click a button and load another movie, and return...
the delay between the newsitems is not 8 sec anymore.

When I do the same, it's even faster.

clearInterval(newTickerId);
newTickerId = setInterval(myHome.newsTicker,3000);

grtz

ClearInterval Var
I've got a function that I want to apply to several movieclips on the stage. It uses the Tween class and I'll pass a number of variables to it everytime it is called. Problem is, I want to clear the Interval without clearing all the Intervals....it works once and then clears all the intervals. Do I have to set an Interval to clear the next Interval...or do I have to set up mutliple functions? Is there a way I can do this by passing a variable into clearInterval("myvariable here")?
Here's my code:

ActionScript Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
// fade for Logos
function FadeIt(theVar, starter, ender, duration){
var fadeTween:Tween = new mx.transitions.Tween(theVar, "_alpha", Regular.easeOut, starter, ender, duration, false);
clearInterval(myfadeID);}
// movement here...I want to pass this
to multiple movieclips. If I write out all
my clearIntervals it executes the first
movement then clears all the intervals. That
makes sense to me...i'm just trying to figure
out a way without having to write so many
individual functions....
function MoveIt(theVar, theInterval, starterX, enderX, durationX, starterY, enderY, durationY){
var moveTween:Tween = new mx.transitions.Tween(theVar, "_y", Strong.easeIn, starterY, enderY, durationY, false);
var move2Tween:Tween = new mx.transitions.Tween(theVar, "_x", Strong.easeIn, starterX, enderX, durationX, false);
clearInterval(theInterval);
}


var myfadeID:Number = setInterval(this, "FadeIt", 1500, teachertxt_mc, 100, 0, 20);
var leftdeskID:Number = setInterval(this, "MoveIt", 2500, deskleft_mc, leftdeskID, -47, -400, 20);
var rightdeskID:Number = setInterval(this, "MoveIt", 2600, deskright_mc, rightdeskID, 404, 700, 20);

ClearInterval Woes
When I select an item in a listbox the function
showDetails is invoked,(via Flash Remoting but I
don't think that's relevant).

showDetails provides data for several text fields which I want to show on the screen sequentially by making them visible after varying times. I use setInterval to achieve this. The first time this works fine but when I switch
to another item in the list box the timings are off. Tracing the displayText function shows that it runs continuously

function showDetails {

// lots of stuff

_root.fieldname1._visible = false;
var intervalID;
intervalID = setInterval( displayText, 600 );

// more stuff
}

function displayText {

_root.fieldname1._visible = true;
clearInterval( intervalID );
}

Where am I going wrong

How Do I Use SetInterval(); And ClearInterval(); ?
I utilized two buttons for load JPEG image that these're from web camera. I wolid like get a new JPEG image by itself every 10 sec. so I use setInterval(); for doing it.
Two buttons are the same method of action script. Only different is loads a JPEG image from different path.

The movie is going well when I just push first button. But when I push the second button which the movie showed two new JPEG images together.

How did I stop to show a new JPEG image when I push another button? I'm not sure the action script can use clearInterval(); or cann't?

Please help me and point me in the right direction with? Any help would be greatly appreciated. Thanks.

Best regards,

softip

How Do I Use SetInterval(); And ClearInterval(); ?
I utilized two buttons for load JPEG image that these're from web camera. I wolid like get a new JPEG image by itself every 10 sec. so I use setInterval(); for doing it.
Two buttons are the same method of action script. Only different is loads a JPEG image from different path.

The movie is going well when I just push first button. But when I push the second button which the movie showed two new JPEG images together.

How did I stop to show a new JPEG image when I push another button? I'm not sure the action script can use clearInterval(); or cann't?

Please help me and point me in the right direction with? Any help would be greatly appreciated. Thanks.

Best regards,

softip

ClearInterval Is Freaking Me Out
What's wrong with my script, can someone tell me why it doesn't work ?
IT ISN'T CLEARING THE INTERVAL !!!!


onClipEvent (load) {
function myInterval() {
_root.play();
}
}
onClipEvent (enterFrame) {
setInterval(myInterval, 4000);
clearInterval(myInterval);
}

ClearInterval Being Tricky....
So... I'm trying to end my jpg loading preloader.

clearInterval(Int_Var); works when i put it right after setInterval call but not anywhere else in the script. so this code works to clear the interval:

load_jpgs = function () {
var Int_Var;
Int_Var = setInterval(check_it, 1000);
clearInterval(Int_Var);
}
check_it = function () { blah blah }

But when I put the clear Interval within the function called, no workie:

load_jpgs = function () {
var Int_Var;
Int_Var = setInterval(check_it, 1000);
}
check_it = function () {
blahblah;
if (stuff is done loading) {
clearInterval(Int_Var);
}
blahblah; }

so whats up with this? some unknown flash lingo known only to the gods of this mountain? that's why i hate actionscript, not even the developers know all of it's quirks.... boo

thanks for any help you may be able to lend to my question.

How Do I Use A Variable With ClearInterval()?
I have a function and one of its parameters is the name of the intervalID. Example:

function Bob(X, Y, intervalName) {
if (X == Y) {
trace(x is y);
}
clearInterval(intervalName);
}

and the interval is set like so:


onClipEvent(mouseUp){
ID = setInterval(_root.Bob, 1000, 4, 5, ID);
}


For one reason or another, the clearInterval(intervalName) does not evaluated to clearInterval(ID). How do i make this work?

ClearInterval Question
I have used the clearInterval many times but usually the function cancelled itself out so the clearInterval was inside the function and it worked fine. This time however I am having trouble with it.

The function I have turns on and off the rollover effects on the buttons for the links on a site im working on. setInterval cycles through the function and it works perfectly. Going in order lighting up the buttons.

What I want is when you yourself rollover a certain button the interval clears then on rollout the interval restarts. I thought i could simply add clearInterval on rollover and setInterval to restart the function on rollout.

When this didnt work I tried changing the interval to a global interval just to make sure the rollover buttons on the main layer were interacting with the interval in the movieclip. Still this did not work. The next thing I tried was changing the button links to mcs, the code already their worked both ways but again this did not work.

Those are the things I tried so I wouldnt get people telling me to do the things I already did, if anyone could help me out. Thanks

[as2] ClearInterval Problem
I have made a menu, that reads its content out of an XML file.

When you move over the buttons, the scale, and alpha is set to 100.
When you leave the button it is resetted to it's original size/position.

But, if you move to fast over the buttons, they disappear. It's like the file doesn't call the clearInterval:

Here is the code:
code:
//Begin of code

a=3
mcBalk=this.attachMovie("balk_mc","mc_balk",0)


mcBalk._x=Stage.width-(mcBalk._width)
mcBalk._y=(Stage.height/2)-(mcBalk._height/2)





menu_XML=new XML()
menu_XML.ignoreWhite=true
menu_XML.onLoad=function(OK){
if(OK){
Menu_inladen(this.firstChild)
}
else{
trace("No valid XML-file")
}

}
menu_XML.load("XML/menu.xml")

function Menu_inladen(data){

aantalMenuItems=data.childNodes.length
arrMenuItems=[]
for (i=0;i<aantalMenuItems;i++){
ItemNaam=data.childNodes[i].childNodes[0].firstChild
UrlImg=data.childNodes[i].childNodes[1].firstChild
arrMenuItems.push({nr:i, name:ItemNaam, UrlImg:UrlImg});
}


for (i=0;i<arrMenuItems.length;i++){
mc=this.attachMovie("button_mc","mc_button"+i,i+1)
mc._xscale=50
mc._yscale=50
mc._alpha=50
mc._x=470
mc._y=50+(i*80)
mc.obj=arrMenuItems[i]
mc.obj.mc=mc
UrlImg=mc.obj.UrlImg
mc.image_mc.loadMovie(UrlImg)
mc.onRollOver=function(){

RollOver(this.obj)

}
mc.onRollOut=function(){

RollOut(this.obj)
}



}
}
function RollOver(obj){
intervalROver=setInterval(IntervalRollOver,1,obj)


}
function RollOut(obj){
intervalROut=setInterval(IntervalRollOut,1,obj)
}

function IntervalRollOver(obj){

if(obj.mc._xscale<100){


obj.mc._xscale=obj.mc._yscale+=a
obj.mc._alpha+=a
}
else{
clearInterval(intervalROver)
}
}
function IntervalRollOut(obj){
if(obj.mc._xscale>50){

obj.mc._xscale=obj.mc._yscale-=a
obj.mc._alpha-=a
}
else{
clearInterval(intervalROut)
}
}
// End of code

ClearInterval From External SWF
Hi Everyone,
I have an swf called "practice.swf" that is being imported into a movie clip called containermc in "main.swf". If I declare a setInterval command in practice.swf, how can I cancel it from main.swf. The interval declared in practice.swf is done like so:
pinterval = setInterval(p_select, thetime);

In my main.swf file, I attempted to clear it as follows: containermc.clearInterval(pinterval);

This does not seem to be working. Any help would be greatly appreciated. Thank you.

Set/clearInterval From Within Another Fucntion
I'm trying to control a number of repetitve tasks with functions. By repetitve task, i mean something like a button entering the stage from the side and decelerating as it approaches its final destination. I had been doing this with onClipEvent, so each new frame would repeat the calculations and bring it closer, and when it got there, the MC would be removed so the script loop would stop. This works fine, but lots of moving pieces means an unwieldy number of control clips.

So I'm trying to do the same thing with functions on the root time line. If I use setInterval, I can get the functions to repeat, again bringing the targeted object closer to where it needs to be with each turn of the interval. However, to stop this, I must use clearInterval. Now if the completion of one motion is the trigger for another, I need to set set my Interval for the second function from within the first function. This works just fine. However, i cannot get the clearInterval to work if the setInterval is made inside a function.

I figured since setInterval is basically just a variable, if I specify _root. as the scope for that variable, I should be able to reach it from these other functions, but that returns and error. I'd really like this to work, does anyone have any work arounds. Examples below. Thanks


Code:
var function1 = function():Void{
yGap = (-600 - _root.mc1._y)/2;
scaleGap = (5 - _root.mc1._yscale)/2;
with(_root.mc1){
_yscale += scaleGap;
_xscale += scaleGap;
_y += yGap;
}
if(Math.abs(yGap) <= 1){
_root.mc1._yscale += 100;
_root.mc1._xscale += 100;
_root.mc1._y = 0;
var function2Interval:Number = setInterval(function2, 42);
clearInterval(_root.function1Interval);
}
}
var function1Interval:Number = setInterval(function1, 42);
With this on the root timeline, the setInterval for function 1 starts and works fine. The setInterval for function 2 starts and works fine. The clearInterval for function1 works fine. But...the clearInterval for function2, nested inside function 2, doesn't work:


Code:
var function2 = function(){
scaleGap = (100 - _root.mc2._yscale)/5;
_root.mc2._yscale += scaleGap;
if(Math.abs(scaleGap) <= 1){
_root.mc2._yscale = 100;
clearInterval(function2Interval);
}
}

Problem With ClearInterval
I have a function that plays a sound effect randomly, every 4 to 12 seconds
code:
playWatercoolerNoises = function() {
_global.PlaySFX("watercooler");
}
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random()*(max-min))+min;
return randomNum;
}

_global.interval_id = setInterval(playWatercoolerNoises,randRange(4000, 12000));

this code is located on the _root timeline.

The entire swf is loaded inside another movie.
I can clear the interval from anywhere inside the loaded movie using
code:
clearInterval(_global.interval_id)


However, I also need to be able to clear the interval from another movie, which is also loaded inside the base movie, and my clearInterval call does not seem to work

Any suggestions?

Thanks

JennyJ

p.s. I am publishing all files as Flash 7 AS2

ClearInterval Not Working
Hi all

I always seem to have a hell of a time using intervals.

It works most of the time but some times it the interval function will keep on fireing even though i have called the clearInterval method.

It works most of the time but some times it will just refuse to actually stop the interval no matter how many times i try to call the clearInterval();

eg


PHP Code:




var myInt;
var timeCount = 0;
function init(){
myInt  = setInterval(tick, 800);
}

function tick(){
    if( timeCount > 3){
    clearInterval(myInt);
    playQuiz(1);
    };
    trace(timeCount);
    timeCount++;
}







I can get this to work fine but its the odd exception that bothers me i just cant rely on it do clear when i want it to.

Any suggestions would be awsome.

Thanks

Andrew

ClearInterval Issue
Hi,

I have attached a source file, but basically I have a main movie and 2 content movies that load into the main movie.

The 2 content movies have a dissolve filter that uses setIntervals
I am having trouble clearing them because when go back and forth betwween the 2 content files the setInterval gets all messed up, HELP Please!

click me

ClearInterval() Function
I need help for the clearInterval() Function in Flash MX 2004. When I go enter the function in Actionscript then the following comes up:

clearInterval(IntervalID)
I want to know what is the IntervalID. First I thought it was the variable name for my timer, which is a Dynamic Textbox but no.

Please help!

Problems With ClearInterval()
It might be that I've been working for 5 hours strait but I cant seem to see why this doesnt work: (I highlighted the code of interest. Essentially, my call to clearInterval isnt working I think).
Code:
products.onRollOut = function() {
boxctl2 = setInterval(checkOutsideBox2, 100);
};
function checkOutsideBox2() {
if ((_xmouse>dropDownMenu2._x+dropDownMenu2._width) || (_xmouse<dropDownMenu2._x) || (_ymouse<dropDownMenu2._y-10) || (_ymouse>dropDownMenu2._y+dropDownMenu2._height)) {
clearInterval(boxctl2);
current3 = productsTotalSlides;
clearInterval(menuControl2);
var menuControl2 = setInterval(hideMenuItem2, 150);
if (_root.currPageName == "products") {
products.upState.gotoAndStop(upFrame);
} else if (products.upState._currentframe != 1) {
products.upState.gotoAndPlay(upFrame+1);
}
}
}
function hideMenuItem2() {
if (current3>=1) {
trace("removing clip "+current3);
dropDownMenu2["p"+current3].onEnterFrame = fadeAway;
current3--;
} else {
trace("not removing "+current3);
clearInterval(menuControl2);
}
}


Results from the trace() calls:
Code:
removing clip 4
removing clip 3
removing clip 2
removing clip 1
not removing 0
not removing 0
not removing 0

and so on.....


Any ideas guys?

edit: This code has worked for me before unless im missing some minor thing. There is another piece of code that also uses setInerval() but with different intervalIDs.

ClearInterval Not Clearing
Help.

I have a main timeline with buttons. Each button goes to a specific frame in the timeline.

In the first frame only is a Movie clip. This movie clip (movie1_mc) is an animation that uses functions to pause in its own timeline for a few seconds. Thus, the animation will play until it reaches a pause function, waits 6 seconds and plays onto the next pause function.

However, I cannot get this animation to stop when I am in the main timeline. I'd like it to stop when a button from the main timeline is used to advance to a frame in the main timeline.

For instance, if I my button advances me to frame 10 in the main timeline, all is fine until the movie1_mc starts playing again. It will pop into view and run a random speeds.

Below is the script used in frames within the mc.


function hold() {

gotoAndPlay("one");///This gotoAnd Play advances the movie1_mc timeline to the next interval stop.

clearInterval(delayID);

}

var delayID = setInterval(hold, 6000);
stop();


Any help is appreciated.

[F8] ClearInterval Problem
Hello,

I have several buttons on my stage that load an external Flashpaper swf into an empty movie clip on my stage, and to mess with the API settings I need to use setInterval to keep it looping until it completly loads into the MC. The problem is that when it loads, the clearInterval doesn't stop the setInterval from looping over and over....

Here is the code I have on the frame with everything in it:

IntervalID = setInterval(Zoomer, 100);
function Zoomer() {
clearInterval(IntervalID);
var fp = course_loader.getIFlashPaper();
if (!fp) {
return;
} else {
fp.setCurrentZoom(75);
fp.setSize(558, 414);
fp.showUIElement("Pop", false);
fp.showUIElement("PrevNext", false);
fp.showUIElement("Page", false);
clearInterval(IntervalID);
}
}


And then on each button I have code similar to this:

on (press) {
loadMovie("courses/Adult Basic Education.swf", course_loader);
IntervalID = setInterval(Zoomer, 100);
}



I hope this is clear.... Thanks to anyone that can offer any advice!

ClearInterval Question
I'm sure this is simple but I'm missing something...

a/s on my_mc:

on(rollOver) {
mousescrollint = setInterval(_parent.mousescroll, 80);
}

a/s on my timeline:

function mousescroll(){
if ('some condition') {
}
else {
trace("clear interval");
clearInterval(mousescrollint);
}
}

Problem is the clearInterval is not working and I think it's because the setInterval is on the mc because if I put the setInterval on the main timeline then the clearInterval does work. So do I need something like this:

clearInterval(my_mc.mousescrollint);

or something like that??? I've tried a bunch of different things but obviously not the correct one! Thanks!

[CS3] ClearInterval Just Not Working
Hi,

I'm using netStream to load in a video and am using a setInterval command to update the indicator bar to show how much has loaded.
The thing is my clearInterval just isn't working. Is my code wrong??

PHP Code:




if (_root.getPN(4)==_root.page)
{
    var netConn1:NetConnection = new NetConnection();
    netConn1.connect(null);
    var netStream1:NetStream = new NetStream(netConn1);
    netStream1.onMetaData = function(infoObject:Object)
    {
        for (var propName:String in infoObject)
        {
            trace(propName + " = " + infoObject[propName]);
        }
        
        var movieLength:Number = infoObject["duration"];
        trace(formatMinSec(movieLength));
        function formatMinSec(secs:Number):String
        {
           var m1:Number = Math.floor(secs/60);
           var s1:Number = Math.round(secs - m1*60);
           return m1.toString() + ":" + ((s1 < 10) ? '0' : '') + s1.toString();
        }
        controller.movieLengthTxt.text = "/" + (formatMinSec(movieLength));
    };
    indicator.blockPlay._xscale = 0;
    video.attachVideo(netStream1);
    netStream1.setBufferTime(5);
}
else
{
    netStream1.onStatus = function(eventObj:Object)
    {
        if( eventObj.level == "status" && eventObj.code == "NetStream.Play.Stop" )
        {
            netStream1.close();
            media.clear();
        }
    };
    clearInterval(time_interval);
    clearInterval(loaded_interval);
}

loadVideo.onRelease = function()
{
    videoIn(controller, 100);
    videoIn(video, 100);
    videoIn(indicator, 100);
    videoIn(backMc, 100);
    videoIn(image, 0);
    videoIn(this, 0);
    this.enabled = false;
    netStream1.play("flv/video1.flv")
    _global.myInt;
    var loaded_interval1:Number = setInterval(checkBytesLoaded, 500);
}

function checkBytesLoaded()
{
       var pctLoaded:Number = Math.round(netStream1.bytesLoaded/netStream1.bytesTotal*100);
    trace(Math.round(netStream1.bytesLoaded/1000)+" of "+Math.round(netStream1.bytesTotal/1000)+" KB loaded ("+pctLoaded+"%)");
    indicator.blockPlay._xscale = pctLoaded;
    
       if (pctLoaded>=100)
       {
      clearInterval(loaded_interval1);
      trace("interval cleared");
       }
}







Once pctLoaded is 100 it should clear the interval but the output window just happily traces and traces "interval cleared"!

Any ideas?

Matt

ClearInterval - Right And Wrong Way?
I've got a question about clearInterval.
In Flash 8, actionscript 2 I tried to set and delete an Interval as follows:

Bt1.onRelease = function(){
if(intervalID != null) {
clearInterval(intervalID);
}
var intervalID:Number = setInterval(automat, delay);
}

Bt2.onRelease = function(){
clearInterval(intervalID);
}

The setInterval starts the function, which seams allright but you can never ever stop it with clearInterval!
I just don't understand why it will not stop.
After trying almost everything (reading all my Flash books, google-search etc gave me no answers),
I found out it does work if you don't strict type the setInterval at startingpoint.

This example works ok:

var intervalID:Number;
Bt1.onRelease = function(){
if(intervalID != null) {
clearInterval(intervalID);
}
intervalID = setInterval(automat, delay);
}

Bt2.onRelease = function(){
clearInterval(intervalID);
}

Problem solved. But I still don't understand why the first attempt won't work.

Cannot ClearInterval In Class
Hi:

I have just started working with classes and am having trouble using setInterval/clearInterval in the class. I am sure my scoping is incorrect but I am not sure how to fix it. My problem (simplified) is below:



Code:
class myClass extends MovieClip {
var loopImage:Number
function myFunc1(){
loopImage = setInterval(this, "cycleImages", 4500);
}
function myFunc2(){
clearInterval(loopImage);
}
function cycleImages(){
//irrelevent whats in here
}
}

Bascially, how do I set up my interval so that when "myFunc2" is called, loopImage is not undefined and it is able to clear the interval.

Thanks in advance.

ClearInterval Problems
Hi folks.

Can someone please help me with this one? I have no earthly idea why the clearInterval in this function never happens. The condition is met and the trace is called, but no clearInterval.

Any ideas?


Code:

this.onRelease = function() {
intervalFadeUP = setInterval(fadeUP, 100);
_parent.gotoAndPlay("totransformagain");
};
this.onRollOut = function() {
_parent.gotoAndPlay("totransbg");
};



fadeUP = function () {
if (_root.mcBigBlueBox._alpha>=100) {
clearInterval(intervalFadeUP);
trace("alpha is greater than or equal to one hundred");
} else {
_root.mcBigBlueBox._alpha += 5;
trace("FADING UP");
}
};

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