SetInterval Issue
Hi,
This the issue:
One the stickman hits the black stickman
he should go in panelty for 9 second -Ie could not hit anyone else
but if he hits the red stiickman he should be fine
the code is behaving strangely
--I read most of the setinterval examples and issues
Please see attached file
Please help
Thanks
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 05-19-2007, 02:07 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
SetInterval Issue
Hello there,
I have a mc that I want to move as fast as the flashplayer can, so after reading senocular's excelent article/tutorial I tried this code: onClipEvent (load) {
MoveObject = function() {
this._x-=50;
updateAfterEvent();
}
if (this._x<10){clearInterval(moveID);}
}
on(release){
//trace("X = "+this._x)
moveID = setInterval(moveObject, 40);
}
but it does not work.
Any help on that?
Cërf.
An Issue With SetInterval ...
Hi, I have a main movie, which loads in a swf of rotating images ... to pause inbetween the tweens of images, I used this code:
code:
stop();
interval = setInterval( function () {
Play();
clearInterval(interval);
}, 5000);
And it works fine on the swf by itself ... but when I view it from my main movie, it moves my main movie on!?
I really can't understand why, becoz this function is inside a movieclip on a loaded swf. So it's like 3 level's deep, yet still affecting the main timeline with NO root pathing!?!?!
Very weird!!! Can anyone help me with this, or a new code? I even tried: gotoAndPlay("theF1"); instead of Play(); but that ALSO made the main timeline move forward a frame ... which again is REALLY weird when there are no frames labeled that on the main movie.
HELP!?
[F8] SetInterval Issue
I am trying to get a better understanding of how the setInterval code works.
I have created an example to hopefully show where my understanding is falling down.
The example code is as follows:
FRAME 1
##########
//
counter_button.onRelease = function() {
clearInterval(myInt);
}
checkData = function() {
trace("Interval= "+myInt);
//trace("Check Data"+thisCheck);
}
thisCheck = setInterval(checkData, 1000);
##########
FRAME 2
##########
this.stop();
i = 0;
tracer = function() {
i++;
trace(i);
}
myInt = setInterval(tracer, 1000);
##########
Button is used to clearInterval and is placed on frame 1
What I am presuming is happening and what I want to do is set an interval (myInt) that is just running an operation. I then want to clear this interval, but make sure that it has been cleared by using another interval (thisCheck) to see whether it is still running.
What I am finding is that the 'thisCheck' interval is always returning a value irrespective of whether the 'myInt' is running or of it has been cleared.
I would have presumed that once thr initial interval is cleared, the check interval would return an 'undefined' value, but all I get is the value 2, which I have no idea where it comes from.
Also, has anyone encountered any problems if an interval function is left running for a long period of time ? Is there some sort of internal Flash stack that reaches a point and falls over ?
I hope this request makes sense and any pointers you can give me would be greatly appreciated, as I just cannot get my head around this. Hopefully it is something straight forward ???
Regards,
Motorpilot
SetInterval Issue...(?)
Here is my issue:
If I click on a link once, everything loads OK, however, if I go click on it again, it only loads partially... Can anyone tell me why this is and how to resolve?
Here is the link:
http://laughwithlarry.com/index.swf
Here is the AS for the booking button:
Code:
on(release){
unloadMovieNum(2);
loadMovieNum("booking.swf",2);
}
The AS for the booking page:
Code:
stop();
setInterval(fadeInFunction, 800);
counter = 0;
function fadeInFunction() {
counter++;
_root.Increment(counter, 100, 2);
}
function Increment(count, maxAlpha, speed) {
_root.onEnterFrame = function() {
_root["MovieClip"+count]._alpha += speed;
if (_root["MovieClip"+count]._alpha>=maxAlpha) {
_root["MovieClip"+count]._alpha = maxAlpha;
delete _root.onEnterFrame;
}
};
}
Also, here is the code for the index page where the links fade in:
Code:
loadMovieNum("home.swf",2);
setInterval(fadeInFunction, 800);
counter = 0;
function fadeInFunction() {
counter++;
_root.Increment(counter, 100, 2);
}
function Increment(count, maxAlpha, speed) {
_root.onEnterFrame = function() {
_root["MovieClip_mc"+count]._alpha += speed;
if (_root["MovieClip_mc"+count]._alpha>=maxAlpha) {
_root["MovieClip_mc"+count]._alpha = maxAlpha;
delete _root.onEnterFrame;
}
};
}
var colorful = new Color(_root.MovieClip_mc3);
MovieClip_mc3.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc3) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc3.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc3) {
_alpha = 100;
Increment(50, 4);
}
};
var colorful = new Color(_root.MovieClip_mc4);
MovieClip_mc4.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc4) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc4.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc4) {
_alpha = 100;
Increment(50, 4);
}
};
var colorful = new Color(_root.MovieClip_mc5);
MovieClip_mc5.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc5) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc5.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc5) {
_alpha = 100;
Increment(50, 4);
}
};
var colorful = new Color(_root.MovieClip_mc6);
MovieClip_mc6.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc6) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc6.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc6) {
_alpha = 100;
Increment(50, 4);
}
};
var colorful = new Color(_root.MovieClip_mc7);
MovieClip_mc7.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc7) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc7.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc7) {
_alpha = 100;
Increment(50, 4);
}
};
var colorful = new Color(_root.MovieClip_mc8);
MovieClip_mc8.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc8) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc8.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc8) {
_alpha = 100;
Increment(50, 4);
}
};
var colorful = new Color(_root.MovieClip_mc9);
MovieClip_mc9.onRollOver = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha += speed;
if (this._alpha>=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc9) {
_alpha = 50;
Increment(100,4);
}
};
MovieClip_mc9.onRollOut = function() {
MovieClip.prototype.Increment = function(maxAlpha, speed) {
this.onEnterFrame = function() {
this._alpha -= speed;
if (this._alpha<=maxAlpha) {
this._alpha = maxAlpha;
delete this.onEnterFrame;
}
};
};
with (MovieClip_mc9) {
_alpha = 100;
Increment(50, 4);
}
};
Thanks for your time!
SetInterval Issue
Hi, I am loading Time from Remoting in AS2. But at a time same 2 swf is not showing same time. Initially Time gap is about -1 to +2 seconds. But if i close second swf and open after 5 mins then diffrence increse to 2 mins....
But backend timer is ok as per tested in HTML. So what is the solution to match these timing. It is very crucial for me so please help me.
I had one idea also but that didn't work on this.
Actually i am managing time gap to load from remoting by getTimer() method like following:
var id = getTimer();
function onLoadfromRemoting(res:Result){
var timegap = getTimer()-id;
}
This will give me time gap to load from remoting. but i can't find the solution... why time between 2 swf has been increased? I am running timer from setInterval metod.
Please let me know the solution asap... thanks in advance
Help ... SetInterval Issue
Hey! I'm hoping someone can help me. There's something I'm just not understanding about the setIntervals in my script. I've used setInterval before without any problems, but this time they're returning numerical values incrimenting by 2 each time.
The script consists of:
function r - which returns a random value between the min (i) and max (a) values passed.
function f0 - the initial function that gets called. This function clears the two ('t' and 'm' - dynamically more than two) timers, runs function 'f1' and instantiates a setInterval to recall itself (f0).
function f1 - This function randomly decides wheather the object (passed value 'obj') should shrink or grow (functions 'cG' and 'cS'), and then sets an interval to which the object does just that.
function cG - grows the object by 1px.
function cS - shrinks the object by 1px.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Here is my code:
//These are limits as to the 'obj's _xscale
_global.Li = 80;
_global.La = 100;
r = function(i, a) {
return Math.floor(Math.random()*(a - i)) + i;
}
cG = function(o) {
o._xscale = o._xscale + 1;
o._yscale = o._yscale + 1;
o._x = o._x - 1;
o._y = o._y - 1;
}
cS = function(o) {
o._xscale = o._xscale - 1;
o._yscale = o._yscale - 1;
o._x = o._x + 1;
o._y = o._y + 1;
}
f0 = function(obj, t, m) {
clearInterval(t);
clearInterval(m);
f1(obj,m);
t = setInterval(f0, r(800, 200), obj, t, m);
// Uncommenting the line below illustrates my problem. The story's the same with 'm' in 'f1'
//trace(t);
}
f1 = function(obj, m) {
if(obj._xscale <= _global.La && obj._xscale >= _global.Li) {
clearInterval(m);
r(1, 99) % 2 ? m = setInterval(cG, r(200, 80), obj) : m = setInterval(cS, r(200, 80), obj);
}
if(obj._xscale > _global.La) {
clearInterval(m);
m = setInterval(cS, r(200, 80), obj);
}
if(obj._xscale < _global.Li) {
clearInterval(m);
m = setInterval(cG, r(200, 80), obj);
}
}
f0(o1, "t1", "m1");
// More objects can be targeted as shown below. 't1' and 'm1' are variable names gived to the timers set.
//f0(o2, "t2, "m2");
//f0(o3, "t3, "m3");
//f0(o4, "t4, "m4");
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Thanks in advance. If you need any additional information please ask.
yours, in Christ
vaughan
(:
Help ... SetInterval Issue
Hey! I'm hoping someone can help me. There's something I'm just not understanding about the setIntervals in my script. I've used setInterval before without any problems, but this time they're returning numerical values incrimenting by 2 each time.
The script consists of:
function r - which returns a random value between the min (i) and max (a) values passed.
function f0 - the initial function that gets called. This function clears the two ('t' and 'm' - dynamically more than two) timers, runs function 'f1' and instantiates a setInterval to recall itself (f0).
function f1 - This function randomly decides wheather the object (passed value 'obj') should shrink or grow (functions 'cG' and 'cS'), and then sets an interval to which the object does just that.
function cG - grows the object by 1px.
function cS - shrinks the object by 1px.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Here is my code:
//These are limits as to the 'obj's _xscale
_global.Li = 80;
_global.La = 100;
r = function(i, a) {
return Math.floor(Math.random()*(a - i)) + i;
}
cG = function(o) {
o._xscale = o._xscale + 1;
o._yscale = o._yscale + 1;
o._x = o._x - 1;
o._y = o._y - 1;
}
cS = function(o) {
o._xscale = o._xscale - 1;
o._yscale = o._yscale - 1;
o._x = o._x + 1;
o._y = o._y + 1;
}
f0 = function(obj, t, m) {
clearInterval(t);
clearInterval(m);
f1(obj,m);
t = setInterval(f0, r(800, 200), obj, t, m);
// Uncommenting the line below illustrates my problem. The story's the same with 'm' in 'f1'
//trace(t);
}
f1 = function(obj, m) {
if(obj._xscale <= _global.La && obj._xscale >= _global.Li) {
clearInterval(m);
r(1, 99) % 2 ? m = setInterval(cG, r(200, 80), obj) : m = setInterval(cS, r(200, 80), obj);
}
if(obj._xscale > _global.La) {
clearInterval(m);
m = setInterval(cS, r(200, 80), obj);
}
if(obj._xscale < _global.Li) {
clearInterval(m);
m = setInterval(cG, r(200, 80), obj);
}
}
f0(o1, "t1", "m1");
// More objects can be targeted as shown below. 't1' and 'm1' are variable names gived to the timers set.
//f0(o2, "t2, "m2");
//f0(o3, "t3, "m3");
//f0(o4, "t4, "m4");
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Thanks in advance. If you need any additional information please ask.
yours, in Christ
vaughan
(:
Menu Issue (uses SetInterval)
Im using F5.
I am trying to make a drop down menu, and thought of using the setInterval function.
I made a menu inside a MC, wich has, on the 1st frame the action:
tempo=4000;//time Id wish to wait, in miliseconds
stop ();
Then, once the user presses a button, the timeline plays, untill it reaches frame 10, where I have:
stop();
var timer;
timer = setInterval(moveOn, tempo);
function moveOn(){
gotoAndPlay("roda");
clearInterval(timer);
}
I want to wait for tempo then goto "roda" and play, but its not working the way I expected
The file is attached.
Any help will be much appreciated
Thanx in advance
Menu Issue (uses SetInterval)
Im using F5.
I am trying to make a drop down menu, and thought of using the setInterval function.
I made a menu inside a MC, wich has, on the 1st frame the action:
tempo=4000;//time Id wish to wait, in miliseconds
stop ();
Then, once the user presses a button, the timeline plays, untill it reaches frame 10, where I have:
stop();
var timer;
timer = setInterval(moveOn, tempo);
function moveOn(){
gotoAndPlay("roda");
clearInterval(timer);
}
I want to wait for tempo then goto "roda" and play, but its not working the way I expected
The file is attached.
Any help will be much appreciated
Thanx in advance
Setinterval Delay Issue
I am re posting this because I need help on this!
Below is the code I am using....
SMALLER MOVIE 1
myFrameMove1=function(){
transitionbox1.play();
}
myInterval1 = setInterval(myFrameMove1,3000);
gotoAndStop(1);
clearInterval(myInterval1)
SMALLER MOVIE 2
myFrameMove2=function(){
transitionbox2.play();
}
myInterval2 = setInterval(myFrameMove2,3000);
gotoAndStop(1);
clearInterval(myInterval2)
I have a MAIN movie that has two buttons
each button loads a SMALLER MOVIE into place
the two SMALL MOVIE each have a setinterval
delay transition, this seams to work as long as
you do not view each movie more than once
in other words
click button 1
click button 2
and than click on button 1 again
after yo do this you will see the delay becomes sparatic
and changes at no set time.
There is a source file that will help
Please Help, Anyone!!!!!!!!
SetInterval Scoping Issue, Please Help
Can someone explain why I can't read the variables in the dummy class below?
(I wrote the class below to try to quickly convey my problem without asking you all to go through my own, longer classes that are not getting along nicely with setinterval)
class Test{
private var myVariable:Number = 0;
public function Test(){
setInterval(functionOne,500 );
}
function functionTwo():Number{
myVariable++;
trace('from functionTwo myVariable : '+myVariable);
return myVariable;
}
function functionOne(){
var test2:Number =functionTwo();
trace('test2 ' +test2);
}
}
Issue With SetInterval Function.
This is a simplified version of the actual project I'm working on, but it's basically set up the same way, I haven't been able to get much help from anyone on this yet, but maybe someone here will know how to deal with this
The main file contains a blank movie clip (loader_mc), it's set to load "mc_1.swf" by default. If one of the movie clips contained inside of mc_1.swf is clicked it changes the value of the _root variable stuff (_root.stuff) to 100. This is in turn supposed to then call the setInterval function callback0. I'm doing this because, in my more complex version, I need to have a delay to allow an animation to finish. The setInterval function callback0 is then supposed to load "mc_2.swf" into loader_mc. The problem is, for whatever reason, the damn thing gets caught in an endless loop that continually loads mc_2.swf.
Does anyone have a clue as to why it's doing this?
Here's the code, and I've also attached the entire project.
Code:
loadMovie("mc_1.swf","loader_mc");
_root.stuff = 0;
function callback0(){
clearInterval(intervalID);
loadMovie("mc_2.swf","loader_mc");
_root.stuff = 0;
}
function callback1(){
clearInterval(intervalID);
loadMovie("mc_1.swf","loader_mc");
_root.stuff = 0;
}
box.onEnterFrame = function(){
if(_root.stuff == 100){
intervalID = setInterval(callback0, 1000);
}
if(_root.stuff == 99){
intervalID = setInterval(callback1, 1000);
}
trace(stuff);
}
SetInterval/clearInterval ID Issue
Hey,
I'm having an issue with setInterval/clearInterval when it comes to dealing with objects. Take this example:
ActionScript Code:
MovieClip.prototype.setCount = function(numToCount){ this.interval = new Object(); this.interval.count = 0; this.interval.countUp = function(numToCount) { this.count++; trace(this.count); if(this.interval.count == numToCount){ clearInterval(this.countUp); } }; setInterval(this.interval, "countUp", 100, numToCount);};myMc.setCount(3);
Why does clearInterval not stop the interval? Does clearInterval not work when called inside a setInterval? Am I doing something wrong? How do I get it to delete the interval when it reaches a certain count?
Thanks again!
SetInterval/clearInterval ID Issue
Hey,
I'm having an issue with setInterval/clearInterval when it comes to dealing with objects. Take this example:
ActionScript Code:
MovieClip.prototype.setCount = function(numToCount){ this.interval = new Object(); this.interval.count = 0; this.interval.countUp = function(numToCount) { this.count++; trace(this.count); if(this.interval.count == numToCount){ clearInterval(this.countUp); } }; setInterval(this.interval, "countUp", 100, numToCount);};myMc.setCount(3);
Why does clearInterval not stop the interval? Does clearInterval not work when called inside a setInterval? Am I doing something wrong? How do I get it to delete the interval when it reaches a certain count?
Thanks again!
SetInterval() Update Event Issue
Hello,
i have a setInterval() on the _root timeline which loads jpeg images in to a movieclip.createEmptyMovie(image,1)
the code is as follows
Code:
Int2 = setInterval(function () { if (i>4) {i = 1;}trace('Int '+i);Url = 'images/flashimages/sequence1_image'+i+'.jpg';eval('ImageEffectMc'+i).Image.image.loadMovie(Url);eval('ImageEffectMc'+i).gotoAndPlay('tween');i++;updateAfterEvent();break;}, 2025);
My problem is while i get images 1 and 2 to appear i am unable to get images 3 and 4 to show.
I made sure all jpegs were NOT progressive = true;
I was able to load the jpegs images perfectly when usng a debug script making sure the movie was created first = true
What could cause it to not show the 3rd and 4th image on setInterval();
Kendall
Scripted Mask SetInterval Issue
Hello-
I am not sure if my problem has to do with setInterval or just bad code on this attached file. I am doing this as part of an image viewer with a cool masking transition. When the user presses the button, the scripted mask animation plays via the setInterval code and exposes the picture underneath. That part works fine. The problem is that when the animation is over, and the image is exposed, I want to be able to click the button again and the boxes play in the reverse order, back down again to 20% scale. right now, I only get the 36th box to scale back down. I have no idea why its not working...please..anyhelp would do, even if the code has to be redone! I'm quite certain this has been done before, so if I am coding the effect the wrong way, please let me know. thanks, Eric
Time Delay / SetInterval Issue
I can't seem to figure this out. It seems to me like it should work but it doesn't. Of course I am new to all of this so...
I am trying to autoscroll some text from a text file but I want to slow it down a bit.
Here is the code:
myData = new LoadVars();
myData.onLoad = function(){
myText_txt.text = this.content;
}
myData.load("DLG.txt");
myTimer = setInterval(myDelay, 1000);
_root.onEnterFrame = function() {
function myDelay(){
clearInterval(myTimer);
if(this.myText_txt.scroll==this.myText_txt.maxscro ll) {
this.myText_txt.scroll = 1;
}
else {
this.myText_txt.scroll ++;
}
}
}
It works without the myDelay function but it moves to quickly. When I add the myDelay function, it doesn't move at all.
Any help is very appreciated.
SetInterval Code Flow Issue
I am trying to halt control of the main code until the images have loaded and their widths have been captured-- but the main code continues to execute without waiting for the functions to complete... any ideas?
//main code
InitImage();// why doesn't code stop and wait here???
trace(ImageSizeArray[num].ImgWidth);//DOESN'T WORK HERE
function InitImage(){
loadMovie(ImageWindowArray[num].ImageURL, "mcImage" );
id1 = setInterval(preloader,100);
}
function preloader(){
var gbt = mcImage.getBytesTotal();
var gbl = mcImage.getBytesLoaded();
if(gbl == gbt){ //if loaded, record image width, and get next image
clearInterval(id1);
var obj:Object = new Object();
obj.ImgWidth = mcImage._width;
ImageSizeArray.push(obj);
trace(ImageSizeArray[num].ImgWidth);//BUT IT DOES WORK HERE!!!
num++;
if (num < ImageWindowArray.length){
InitImage();
}
}
}
Custom Objects And Internal SetInterval Loops -> A Problem Stopping The SetInterval
Let's say I had a class like this:
PHP Code:
var someVar = new Widget();
function Widget() {
// Some variables, etc...
this.int_someCommand = 0;
// Activate the function on instantiation
this.someCommand();
};
Widget.prototype.someCommand = function() {
clearInterval(this.int_someCommand);
this.int_someCommand = setInterval(this, 'someCommandLoop', 50);
};
Widget.prototype.someCommandLoop = function() {
trace("THIS IS A WIDGET LOOP!");
};
...now, I was always under the impression that if you delete an object in Flash, the setInterval loops associated with it would die as well. But when I try to:
PHP Code:
// At some other point in my timeline...
delete someVar;
or:
PHP Code:
someVar = new Object();
...the original loop is still running (I can tell just by reading the trace). How do I go about properly terminating a setInterval loop inside an Object without having to call a clearInterval()? Or is a clearInterval() the only way?
Thanks.
Tween Class, Does It Use Setinterval? Getting Strange Setinterval Type Problem
I have a gallery with small thumbnails. Upon clicking a thumbnail, I am using the Tween class to pull clips from an array and fade them between each other, loading the clips into a container.
When I click the thumbnail it loads the .swf fine and plays the Tween Class animation just as it's supposed to, however if I click any other thumbnail and go back to that first one the timing gets totally screwed up and the fades get jittery and overlap each other, much like it does with setInterval if you don't clear the intervals.
Is there a way to clear the Tween Class? Does it's timer run on setInterval?
This is the code I am using for the tween class
Thanks!
Code:
import mx.transitions.Tween;
import mx.transitions.easing.*;
//content movieclips put into an array
var mcArray:Array = new Array(content1, content2);
for (var k in mcArray) {
mcArray[k]._alpha = 0;
}
// tween class has something called "OnEnterFrameBeacon" and it is added to the stage
// when we import the as file, so I wanted to get rid of it.
var n:Number = 0;
function playFades() {
if (n<mcArray.length) {
var tween_handler1:Object = new Tween(mcArray[n], "_alpha", Strong.easeIn, 0, 100, 1, true);
tween_handler1.onMotionFinished = function() {
//trace("motion finished by "+mcArray[n]);
//n++;
var tween_handler2:Object = new Tween(mcArray[n], "_alpha", Strong.easeIn, 100, 0, 3.5, true);
tween_handler2.onMotionFinished = function() {
//trace("motion finished by "+mcArray[n]);
n++;
playFades();
};
};
} else {
n = 0;
playFades();
}
}
playFades();
[CS3] Still Having Clock Time Zone Issue---and Dynamic Text Box Issue
I'm trying to do a clock that displays another time zone. The problem I'm having is that instead of running on a 12 hour clock, its on a 24hr one.
any insight as to how I can change the time?
Currently the clock is displaying
23:00p-Jul.22
I want it to display 11:00p-Jul.22
var dayText:String;
var dateText:String;
var monthText:String;
var AmPm:String;
_root.onEnterFrame = function() {
var myDateate = new Date();
//var sec:Number = myDate.getSeconds();
var min:Number = myDate.getMinutes();
var hour:Number = myDate.getHours();
var day:Number = myDate.getDay();
var date:Number = myDate.getDate();
var month:Number = myDate.getMonth();
//var year:Number = myDate.getFullYear();
//sec = sec<10 ? "0"+sec : sec;
min = min<10 ? "0"+min : min;
//AM/PM
if (hour>12) {
hour = hour-12;
AmPm = "p";
} else {
AmPm = "a";
}
//day
if(date == 1 || date == 21 || date == 31) {
dateText = date+"";
} else if(date == 2 || date == 22) {
dateText = date+"";
} else if(date == 3 || date == 23) {
dateText = date+"";
} else {
dateText = date+"";
}
//month
if (month == 0) {
monthText = "jan";
} else if (month == 1) {
monthText = "feb";
} else if (month == 2) {
monthText = "mar";
} else if (month == 3) {
monthText = "apr";
} else if (month == 4) {
monthText = "may";
} else if (month == 5) {
monthText = "jun";
} else if (month == 6) {
monthText = "jul";
} else if (month == 7) {
monthText = "aug";
} else if (month == 8) {
monthText = "sep";
} else if (month == 9) {
monthText = "oct";
} else if (month == 10) {
monthText = "nov";
} else if (month == 11) {
monthText = "dec";
}
//display
dateDisplay.text = hour+":"+min+ AmPm + "-" + monthText+"."+ dateText;
};
Complex Audio Issue..or Maybe Just Syntax Issue
what's up peoples. I'm building a new site for my studio and having some audio issues i can't explain very well, so here goes:
I've got an external .swf successfully loading into _level6 of my project with it's own audio. and from reading thse forums, i know that if i want to control the audio independently of other audio, i need to attach the sound object to a seperate movieclip, which i'm doing and I can control the audio just fine. However, when i click to load in a dynamic image into a dynamicly loaded movieClip, the volume button no longer works. Both the soundobject's mc and the dynamic mc's are being loaded into the nextHighestDepth() so i don't think one is kicking out the other. Here's what i've got:
Code to attach the soundObject when the section starts:
Code:
this.createEmptyMovieClip("soundstage6",this.getNextHighestDepth());
work_sound = new Sound(soundstage6);
work_sound.attachSound("myaudiofile");
work_sound.start(0, 999);
Code to control the volume:
Code:
this.testVol.onPress = function () {
this._parent.work_sound.setVolume(0);
}
Code that loads in my dynamic images:
Code:
this.testLoad.onPress = function () {
_root.attachMovie("infoClip", "infoClip", this.getNextHighestDepth(), {_alpha:0, _x:491.1, _y:193.9});
}
that testLoad button does severl other things when clicked, but when i comment out that particular line of code, the volume control button contines to work. I'm sure this has something to do with the fact that all of this is occuring on _level6 but i have no idea why or how to fix it!!!
Anybody have any ideas? Sorry for the long and complex explination!!
Mac Textinput Issue + New Player Fullscreen Issue
Please inform me if I am a total idiot,... but it appears that holding down backspace while in a TextInput on a mac will only delete one character rather than deleting chars as long as the button is held down. I have tried making the simplest project consisting of only a base sprite and a textinput, and it fails (i thought i may have been preventing the event from bubbling or something.) I tested the movie on PC and holding down backspace works fine. Is this a known issue? and so I just have to extend textInput?...
Also, it seems like when coming back from fullscreen in a swf embedded on a page causes some flickering of the swf content upon resizing the browser window, 3 people I know have also encountered this problem.
Thanks for any help,
Chris Laan
Button Issue In Flash - Program Issue
all of a sudden when i create a button and place it on stage i cant click it to drag it, scale or whatever...instead when i hover over it it behaves as in a compiled swf file (cursor changes into a hand,...).
How can i change that to the way it was? Anyone had this problem before? It is becoming really irritating.
Level Issue Or Version Issue?
hi,
wondering if anyone knows why this movie here:
http://www.pixel360.com/dev/zoompan.html
works fine as it is, but when loaded into another movie, into an MC called 'blankmc1' it will drag, but not zoom?
Also when i try exporting it as AS 2 and Flash8 the zoom handle sticks to the top of the screen?
source here:
----------------------------------------------
http://www.pixel360.com/dev/zoompan.fla
weird?
Help With Crash Issue/actionscript Issue
Hello all,
My name is Josh and I want to say thanks for even reading my post, I appreciate any help I can get. I am here at work trying to edit a flash intro I bought from templatemonster (no im not a newbie, but this is the one my boss really liked, so what he wants he gets). Im trying to edit it here and i first opened it in Flash 8 which is what i normally use. So, im editing it and usually after I edit a few things I would like to get a glimpse so i test the movie real quick. Well, everytime the "export movie" dialog box came up, it stops at about a little more than half way and the box goes away and NOTHING comes up. IT doesnt freeze, but my test movie doesnt show like something usually would. So i tried installing/uninstalling it to no avail. Finally my boss went out and purchased flash cs3 and we installed that. So im editing it again, and went to test movie, and this time it gets 3/4 way done and "flash has unexpectedly quit" etc etc. So im starting to think its something with the actionscripting maybe?? i dont know but im really frustrated and need some help here. And also, even if I tried to just plain export the movie to swf, crashes too!
Thanks everyone!
-Josh
Flash 8 Pro Issue Interval Issue
Hey, I've been working on my site for a few weeks trying to get it all just right, and I'm making it import text, to text fields from external documents, I've been using loadVariablesNum() and createTextField() to post the text onto the flash document.
ActionScript Code:
//0x393c39;
this.createTextField("forum_box",this.getNextHighestDepth(),212,3,162,120);
forum_box.wordWrap = true;
forum_box.border = true;
loadVariablesNum ("forum_txt.php", 2);
function ftv() {
if (_level2.forum_txt != undefined) {
trace(_level2.forum_txt);
forum_box.htmlText = _level2.forum_txt;
clearInterval(ftt);
}
}
var ftt:Number = setInterval(ftv, 100);
this function keeps looping, it is in a frame that is only called once, i tested this by placing a trace at the very begining , just to see if it would echo it to the output screen more than once, It seems my interval isn't stopped by clearInterval(). if anyone can see my issue here it would be greatly helpful.
Thanks
SetInterval Help
I'm not really sure how to go about using this, I'm terrible with actionscript.
I have a button that needs to have a delayed response, half a second to be specific, and then it needs to bring the user to a different scene. Is that easy to do or no? All I want is the user to click the button, it waits, then goes to a different scene...
Thank you, I'm lost!
SetInterval()
I am having a small problem with setInterval() -- I can't seem to make it update a var outside the callback?
var arg = 0;
function mySetTest(arg) {
arg++;
trace("arg = " + arg);
}
setInterval(mySetTest, 1000, arg);
tx!
SetInterval?
I have a slideshow, that loads a jpg and txt file randomly. Now instead of adding a huge number of frames to get time between slides, how do I use the setInterval command to wait, say 10 seconds, before executing the script again?
Thanks
SetInterval() - BUG
hi,
in the MovieClip:
this.kup=setInterval(function(){ trace("lup") },100);
i attach this movieclip onto stage:
when i removeMovieClip() this movieclip the setInterval function of this movieclip still wokrs..normally when we remove a clip all it's stuff inside it removes. But wht not in this casse with setInterval ?
is it a bug or there is sthg i passed.
SetInterval
i've read the sticky thread about setInterval and the answer to my questions weren't in there.
question1: is there a way to stop the interval with an action and then start the interval back up again where it left off?
question 2: once an interval is finished, is it possible to start it again?
thanks!
SetInterval Help
This is a two part question.
first i want to delay the loop on a movie that I have made. So when the movie reaches the end it delays for 2 min. then replays. Someone suggested using setInterval, since I don't know the first thing about actionscript, how it works, syntax anything I am having trouble getting it to work...I don't even know where to start with this.
I am also wondering if I could use this setInterval in the middle of my movie, instead of lengthening a static frame to get a delay.
I assume I would need to have the action call a function (although I am not sure what that really means, it sounds right) to continue playing the movie after the delay....I have seen stuff about using clearInterval so the action does not repeat, How does that work...I wonder if that would apply to my useage of this action?
If somebody wouldn't mine taking sometime and helping me through so I can understand what I need to do and whats going on that would be great. I catch on pretty quick, I just don't have any base as to what action scripting relates to.
Just a note: I have read through the setInterval tutorial in the actionscripting section, twice, over my head...:-(
SetInterval() Woe...
OK, in doing my own research on setInterval(), I used another board's setInterval() thread to come up with:
Code:
MovieClip.prototype.moveBox = function (){
this._y=this._y+1;
if (this._y = 300){
clearInterval (intID);
}
updateAfterEvent();
}
MovieClip.prototype.moveInterval = function (){
intID= setInterval(this.moveBox, 60,box);
}
intID;
_root.createEmptyMovieClip("box",10)
box.beginFill(0xcc0000,20)
box.moveTo(0,0);
box.lineTo(400,0);
box.lineTo(400,40);
box.lineTo(0,40);
box.lineTo(0,0);
_root.onLoad=function(){
box.moveInterval()
}
A box shows up, but it won't move. The following AS *does* move the box, but for the life 'o me, I can't create/duplicate copies and have them each move.
Code:
_root.createEmptyMovieClip("box",10)
box.beginFill(0xcc0000,20)
box.moveTo(0,0);
box.lineTo(400,0);
box.lineTo(400,40);
box.lineTo(0,40);
box.lineTo(0,0);
_root.onLoad=function(){
intID=setInterval(moveBox,60,box);
}
moveBox=function(clip){
clip._y++;
if(clip._y>300){
clearInterval(intID);
}
updateAfterEvent();
}
The closest I've come is have all the copies stack up on each other but with no movement. I've tried sooo many different variations on the setInterval() theme over the last day and a half - everything from assigning copies of the clip to an array, doing an Object assignment in order to specify a method using function-scope, to the above prototype method, I'm giving up the ghost and CRYING for help! I just wanna create multiple instances of a clip at a given rate, and then move each of them at another rate. So close, but I just couldn't make it happen. Any suggestions would be HUGELY appreciated!
SetInterval
Hey, I'm using the setInterval to keep calling a function if a variable is blank ... but it messes up when it reaches a certin number (I set a up a var it increment by 1)
here is the main piece code
getBal = setInterval(splitSerbal, 100);
/**** Gets the Balance and Serial Number for the game ****/
function splitSerbal() {
// Makes sure that the balance and serial are parsed once
// Gets the serial and balance seperate
if (serbalreturn == null || serbelreturn == "") {
a++;
trace(a);
getBal = setInterval(splitSerbal, 100);
} else {
do you have any clue why setInterval would mess up
if you want to see for your self make a new file and place that code in it.
thanks
- S
Should I Use SetInterval?
I have this little bit of script that will create 5 buttons. They all appear at once, but I would like them to appear one right after another. How would I do this? Would I use setInterval? If so, could someone show me how that would work?
Code:
for (h=1; h<=5; h++) {
_root.attachMovie("BtnMC", "Btn"+h, h+1000);
with (eval("Btn"+h)) {
_x = h*20-10;
_y = 240;
}
}
SetInterval
Hello
Please help... What should I fix in this script to make the circles appear one by one with particular interval of time?
Using SetInterval
ok. i have the following code in the main timeline:
PHP Code:
MovieClip.prototype.fades = function() {
//continuing code
};
then, in a MC that was loaded using attachMovie, i have this:
PHP Code:
onEnterFrame = function () {
this.fades();
contents.drag.enabled = this.enable;
contents.closer.enabled = this.enable;
};
When trying to replace the onEnterFrame with a setInterval i cannot get the function to work. any ideas?
SetInterval And Mc's
Hiya
OK .... I must be having a "dumb-day", but I've read all there is to read on setInterval and I'm still having trouble.
I have a clip on the main timeline that I want to play every 10 seconds. I placed the following code on the last frame of the clip :
stop();
setInterval( function() {gotoAndPlay(1);}, 10000);
Works great for about 5 minutes and then starts to glitch. Anyone know what I am doing wrong?
Thanks in advance
Mick
SetInterval How, What And Where.....
Hi All,
What is wrong with this code? The dame thing doesn't work. The setInterval timer isnt starting and / or it isnt calling the function.
Code:
function(refreshchat) {
this.xmlcnmsg.trigger()
}
setInterval( refreshchat , 6000 );
Cheers
Carl
SetInterval
Why doesn't this work?
Code:
function swfWait5() {
loadMovie("finalnews.swf", "_root.mc");
clearInterval(SW6);
}
SW6 = setInterval(swfWait2, 2000);
SetInterval With Xml. . . Is This Possible?
I need a little assistance in creating a setInterval function based on my xml file. If anyone could help, I would really appreciate it!
Here's a sample of xml file:
<count id="1">
<mediatype>1</mediatype>
<information>Introduction</information>
<endtime>12</endtime>
</count>
<count id="2">
<mediatype>2</mediatype>
<information>Clip 2</information>
<endtime>50</endtime>
</count>
<count id="3">
<mediatype>3</mediatype>
<information>Clip 3</information>
<endtime>150</endtime>
</count>
This is a sample of my actionscript:
Code:
myInterval = setInterval(beginFadeOut, time());
function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time() {
sec = ((10/5)*1000);
trace("seconds called");
return sec;
}
eg.
sec = parent.childNodes[i].firstChild;
So, the value would be put in an array. I have tried several things, and have tried to ask the form, but no response.
If I need to post the .fla just let me know. Any assistance would be great!
Thanks,
cbs
Setinterval
TO WHOM IT MAY CONCERN:
My objective is to attain a algorithm similar to setinterval that can
be employed with flash 5.
Please respond
Kevin
SetInterval
Hi,
basically I'm trying to create a grid of thumbnails.
I'm using to functions:
function 1. loops through an array of pictures and finds the necessary params for it(ie xpos, ypos, ect...)
function 2. creates that thumbnail.
--------------
What I want to do is have them appear one by one not at the same time, but I don't want a timeline loop, so here's what I got up to now
--------------
/*create the clip to hold the grid on level1*/
_root.createEmptyMovieClip("grid", 1);
_root[grid]._x = 20;
_root[grid]._y = 100;
/*initializing my vars to create grid*/
rows = 5;
cols = 7;
xpos = 0;
ypos = 0;
/*this is the function I want to call every 2 seconds*/
function createThumb(item, type, xpos, ypos, targ) {
trace("xpos:"+xpos+" ypos:"+ypos);
}
/*here I loop through my Array of pics and call the above function*/
for (i=1; i<=pAr.length; i++) {
(i%cols == 0) ? xpos=(cols-1)*100 : xpos=((i%cols)-1)*100;
(i%cols == 1 && i != 1) ? ypos=ypos+72 : ypos=ypos;
interv = setInterval(createThumb, 1000, "test", "test", xpos, ypos, "test");
/*clearInterval(interv);*/
}
---------------
Notice my commented clearIntervals, I though this would work but it's clears the interval before calling the function.
Any Help to figure this out would be muchly appreciated.
Thanks
Dan
SetInterval Bug?
Hey,
I've got some weird problems when using setInterval. Look at the folowing two codes and try them:
code:
//--Works as it should be---
var test = "Test failed";
var nr = 1;
var text1 = "Test completed";
function newMap() {
test = this["text"+nr];
trace(test);
}
newMap();
code:
//--Does't work, 'test' totaly looses it's value---
var test = "Test failed";
var nr = 1;
var text1 = "Test completed";
function newMap() {
test = this["text"+nr];
trace(test);
clearInterval(itv);
}
itv = setInterval(newMap, 120);
What causes this? What can I do to fix it?
Thnx a lot,
SaphuA
SetInterval Help
See if I can describe whats happening here. Im getting some strange results.
I have used setInterval before with no problems whatsoever, untill now.
I have my main movie that loads external swf's into an emptyclip.
In one of those external swf's I have another emptyclip that loads other external swf's. In those swf's are MC's that have pictures in them that scroll from left to right. When the picture gets in the middle is where I use this setInterval script.
code:
stop();
function stopClip() {
clearInterval(interval);
play();
}
interval = setInterval(stopClip, 400)
When I try to load another swf with other pics, it all goes to wack. The picture MC's duplicate and I get pictures flying everywhere.
If I take out the setInterval script, it play fine, but I need it to stop for 3 seconds. Any other way to get the MC to stop for 3 seconds?
SetInterval
This is a great function to use. However, I had some inconsistancies with timing. Should I set the intervel to a multiple of the framerate for best result? I was pubishing at 12 frames per second and using an interval time of 83 miliseconds
bjornolafson@hotmail.com
bjornolafson@hotmail.com
Use Of SetInterval().
I need to have a function that reads a text file or database every 30 seconds say.
The system I am developing needs to be running indefinitely - i.e. 10 hours+ at a time.
Is it OK for me to use the function setInterval()?
I'm just worried that inadvertantly I might chew up processor resources?
The reason why I'm concerned is because there also exists clearInterval(). I just thought there must be a good reason to have this other function.
Should I be doing what I want to do using another method?
Any feedback/help would be appreciated.
Thanks.
OM
Where It's At? (setInterval)
I wrote this code
ActionScript:
_root.izmjena = setInterval(promjena, 2000);
function promjena() {
trace(this);
trace(_parent);
}
but when i traced to locate where is this setInterval it says "undefined".
so where it's at?
Problem is when i try to access some MC from this function called in setInterval, it doesn't work although that same MC is in root. So where is that setInterval located?
|