F8 - SetInterval Help?
PHP Code:
button3.onPress = function(){ myArray.sortOn(["color"]); myInterval = setInterval(preloader, 10); function preloader(){ var i:Number=0; if (i<myArray.length){ play(); clearInterval(myInterval); } eval(myArray[i].instance).slideTo(0,i*myArray[i].instance._height,1,"easeOutBounce"); i++; }
}
trying to get something like this to work... click on the button, it sorts the array, then waits a bit moving each item in the array.
i can sort and move the array fine, when i try to add setInterval, it borks... by which i mean, i don't know what i'm doing at 5am.
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 12-08-2005, 05:57 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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();
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?
SetInterval....please Help
Okay i've read through almost all posts on setIntervals and still can't work out how to do what i need.
I have a main menu of 4 buttons that access a content movieclip with all my content in. One of these have a music page that has images changing within a movie clip every 25 seconds using setIntervals. These images are to run constantly until the user choses another menu option this is working fine. I then want to clearInterval(timer) once a new choice is made. Currently the timer just keeps running and resets the site.
I understand what needs to be done but don't know how to access the setInterval code i have within 2 movieclips. as far as i can see i need to clear the setInterval via the menu buttons.....and *u** knows how.
I usually have patience to work these bits out but, im a wee short of time on this one and have to get this finished.
I've tried to attach my fla but its to big for forum even after compression (4.2mb). if anyone can help will mail the file.
Thanks a bundle for any help, my sanity is thread bare....not helped by too much coffee due to desperation, so thanks
Setinterval, But How?
i got a simple movie using property. but i dont know how to use the setinterval action to only take speed influence on the movement of mc vozi
thats the main script:
startx = GetProperty(/:vozi,_x) ;
starty = GetProperty(/:vozi,_y) ;
horizontalno = /:targetx-startx;
vertikalno = /:targety-starty;
setProperty(/:vozi, _x, startx+(horizontalno/2));
setProperty(/:vozi, _y, starty+(vertikalno/2));
thtas on the buttons:
on (release) {
targetx = 195;
targety = 139;
}
thanks for any help...
setinterval but how?
How To Use Setinterval
check my fla
i have one movie clip which i want to play on click of a button after 1 second. i know it can be done using setinterval, but i dont know how to use it
SetInterval
I need to have an animation play every 30 seconds(example). I tried this but it did not work. The animation started playing but then it kept on playing.
Code:
setInterval(function () {
ball.gotoAndPlay(1);
}, 30000);
Where did I go wrong?
Thanks
SetInterval...not Quite Getting It
Just playing around, trying to understand setInterval. i can get my image to increase/decrease alpha, but it only works 2 times...then it is stuck at lower alpha....what am i missing?
Code:
mcFrame.createEmptyMovieClip("mcBox", this.getNextHighestDepth());
var mclLoader:MovieClipLoader = new MovieClipLoader();
var oImageListener:Object = new Object();
oImageListener.onLoadInit = function(mcContent:MovieClip) {
//size of photo in frame
mcContent._xscale = 10;
mcContent._yscale = 10;
//location in frame
mcContent._x = (mcFrame.mcBox._x+5);
mcContent._y = (mcFrame.mcBox._y+5);
//alpha of photo
mcPict._alpha = 60;
mcPict.onRollOver = function() {
var nAlpha:Number=setInterval(increaseAlpha,5,mcPict);
clearInterval(nLessAlpha);
updateAfterEvent();
};
mcPict.onRollOut=function():Void{
clearInterval(nAlpha);
var nLessAlpha:Number=setInterval(lessAlpha,5,mcPict);
updateAfterEvent();
}
//size of frame
mcFrame._width= mcPict._width;
mcFrame._height=mcPict._height;
};
mclLoader.loadClip("edelweiss.jpg", mcFrame.mcBox);
mclLoader.addListener(oImageListener);
//var and functions to call in code
var mcPict:MovieClip = mcFrame.mcBox;
function increaseAlpha(arg) {
if (arg._alpha<100) {
arg._alpha++;
}
}
function lessAlpha(arg){
if(arg._alpha>60){
arg._alpha--;
}
if(arg._alpha==60){
clearInterval(nLessAlpha);
}
}
AS 2 + SetInterval()
In Actionscript 2 I cannot access global class variables in a method being executed by setInterval(). The variable can be accessed in other methods fine. The workaround is to pass the variable in as a parameter on the setInterval() function, but it seems I should be able to access it without doing that. Here is an example of what I am running in to:
Code:
class Food {
private var drink:String = "Pepsi";
private var interval:Number;
// Constructor
public function Food() {
getDrink();
interval = setInterval(allDrinks, 500);
}
private function getDrink() {
// Returns "Pepsi"
trace(drink);
}
private function allDrinks() {
// Returns "undefined" instead of "Pepsi"
trace(drink);
}
}
I'd also like to note that I am using Flash player 8. Any help would be appreciated!
Using SetInterval
if I have a function like this:
selectItem = function(bname:String){
///Code
}
How can I use setInterval to change the value of 'banme'?
SetInterval Help
Hey everyone,
I have a question in relation to the setInterval function. I have a movie on level0 that loads in a movie on level1. Level1 has a short animation playing using the setInterval function that fades in movie clips. The problem that I get when doing this is the setInterval animation speeds up every time you load it in. I don’t understand why this is happening. I was under the knowledge that if you load then unload a movie it’s variables are reset?
Here is my script that sits on level1 (the loaded in movie). I have attached a file if you don’t understand.
Code:
var boxCount:Number = 5;
var countVar:Number = 0;
var extraCount:Number = 0;
var total:Number = 100;
var idCount:Number= 0;
for(var i:Number = 1; i<=_root.boxCount; i++) {
var prevNum:Number = i - 1;
attachMovie("myBox_mc", "myBox"+i, i);
_root["myBox"+i]._y = 125;
_root["myBox"+i]._alpha = 0;
if(i <= 1) {
_root["myBox"+i]._x = 130;
} else {
_root["myBox"+i]._x = _root["myBox"+prevNum]._x + 60;
}
}
var intervalID:Number = setInterval(mycallback1, 0.1);
intervalID;
function mycallback1() {
if(_root.extraCount != 1) {
_root.extraCount = 1;
}// else {
//_root.navigation_mc[_root.furnitureNavigation[+idCount]]._y = -20;
//}
if (_root.countVar >= _root.total) {
_root.countVar = 0;
idCount++
_root.extraCount = 0;
} else {
countVar = countVar + 5;
trace(countVar)
_root["myBox"+idCount]._alpha = _root.countVar;
}
if (idCount == _root.boxCount) {
_root.extraCount = 1;
clearInterval(newintervalID);
}
};
Thanks,
Dan.
SetInterVal Help..
ok..I was recently trying to help another memeber here...and got stumped on a certain part..I can NOT figure out WHY my setInterVal is NOT working..or being called..
original code that I wrote..worked fine. he wantd a way to "time" (slow down) the damage his "character" got..instead of a steady "decrease" on the hitTest.
code that I originally wrote & worked:
Code:
this.onEnterFrame = function() {
this._x = this._x - _root.speed;
if (this.hitTest(_root.square_mc)) {
_root.speed = 0;
_root.circleHP = _root.circleHP -_root.squareDamage;
}
if (_root.circleHP <= 0) {
_root.circle_mc._visible = false;
_root.speed =1;
_root.damageAmount = 0;
}
}
Code that I tried to append to use a setInterVal action..calling the function "damage"
Code:
function(damage) {
if (_root.fight == yes){
_root.circleHP = _root.circleHP - _root.squareDamage;
}
};
setInterval(damage,500);
this.onEnterFrame = function() {
this._x = this._x - _root.speed;
if (this.hitTest(_root.square_mc)) {
_root.fight = yes;
_root.speed = 0;
}
if (_root.circleHP <= 0) {
_root.circle_mc._visible = false;
_root.speed =1;
_root.damageAmount = 0;
_root.fight = no;
}
}
why wont the setInterVal fire??
and .fla if needed..
Using SetInterval
Well, I posted this in the Newbies section and no one answered so maybe I've advanced to "General". I want to create a MC that loops at random intervals. This is the code I put in frame 1.
function doNext() {
this.nextFrame();
clearInterval(timeDelay);
}
RandTime = (Random(15)+5)*1000;
timeDelay = setInterval(doNext, RandTime);
The last frame goes back to the first frame. It doesn't work. Any ideas?
Here's what I don't understand about setInterval, does the timeline stop when you begin setInterval? Otherwise my movie is just playing and when the function is called it goes on to the next frame which is what it is doing anyway, so the net result is nothing. On the other hand, if I put a stop action it never goes to the next frame... Also is it initiating the interval by seting it to the variable or do I need to do something else?
If there's another way to do what I want please let me know.
Thanks,
Please Help With SetInterval
I've been stuck on this for quite a while...
Here's just part of the total code. I would like to delay the start of photo2_mc with setInterval but I just can't make it work. Can someone give me some pointers? That would be huge.
Thanks, Scott
Code:
_root.createEmptyMovieClip("photo2_mc", 5);
photo2_mc._x = 70
photo2_mc._y = 30
photo2_mc.loadMovie("photo2.jpg");
preload=setInterval(preloadB,20,photo2_mc);
function preloadB(mc){
if(mc.getBytesLoaded()>0&&mc.getBytesLoaded()>=mc.getBytesTotal()){
clearInterval(preload);
photo2_mc.setMask(photo2_mask_mc);
}
}
_root.createEmptyMovieClip("photo2_mask_mc", 6);
photo2_mask_mc._x = 70;
photo2_mask_mc._y = 30;
loadMovie("wide_mask_sm.jpg",photo2_mask_mc);
new Tween(photo2_mc, "_alpha", Strong.easeIn, 0, 100, 3, true);
SetInterval Help
I am trying to call a movieClip function using setInterval which has a this.broadcastMessage("do_something", var, var)
The story so far:
The main MC uses a for loop with this.attachMovie() to attach a MC from the library 5 times with unique id,_name,_depth & _y to create a menu. Each menu instance is initialize as invisible -- no problems.
When the last menu item has been created it then calls a function in the main MC with - this._parent.(sendMenuItems). -- again no problems so far.
sendMenuItems() calls a showItem(id) function with a setInterval of 500 and is repeated 5 times then stops. The showItem(id) function uses this.broadcastMessage("show", btnId) to show each menu item one by one. A trace shows the function is called 5 times but the menu items don't recieve the show(btnId) message. I have changed the menu items show() function to trace a message but no joy.
It looks likel the broadcastMessage("show", btnId) is not being carried out inside the setInterval loop!
May be I've missed something or need to take a different approche.
Can anyone help.
TIA
Better Than SetInterval()?
For my latest site, I wanted to execute animations and scripts at different times, so instead of using alot of setInterval's, I did this. Made "controller" movieclips, in them at certain keyframes I'd write my script, so if I wanted something to happen 2 seconds after a button is clicked, I'd direct that button to gotoAndPlay 60 frames before the keyframe inwhich the script is located. I say 60 frames because my movie is running at 30fps. Any con's to this method of delayed animation? I dont think many people use this, I think it's alot easier than a code based system
Setinterval?
Hi, Ive looked around for a while now but i cant seem to figure out how to get this working.
What i want to do is have a button that when clicked jumps to a frame plays out the frames then does another command, I cant do this on the timeline because the command will be different depending which button is pressed but the same frames need to be played.
I think i need to use setinterval so that it jumps to the frame, plays it, waits a set amount of seconds then does the command i want.
Is that the best way to do it or is there another way? If it is the best way any help getting it to work would be veeeeery apreciated.
thanks.
SetInterval Help....
Hi guys.
i am tinkering about with an idea of setting auto slide show for a gallery that i am working on.
Reading over some post's regarding the topic i went with using setInterval.
code:
function slideShow () {
var intervalId:Number;
var count:Number = 1;
var maxCount:Number = totalPages.text;
var duration:Number = 5000;
function executeCallback ():Void {
trace ("executeCallback intervalId: " + intervalId + " count: " + count);
if (count >= maxCount) {
clearInterval (intervalId);
}
count++;
}
intervalId = setInterval (executeCallback, "executeCallback", duration);
}
The code does work but the duration does not.
Function should be called every 5 seconds but instead is called every second. I know it probs my coding. Can someone see where i am going wrong.
Thanks
Paul
SetInterval....I Think.
I am using swapmc to load in swf files as I need them on different keyframes. I am doing this like this:
loadMovie("main.swf", "products");
What I want to do is load in a swf into the "products" mc and after 10 seconds a different swf file is loaded into that "products" mc. I can do this simply by just adding a scene and running down the time line but I thought there was a way to do this with setInterval....but I am stumped.
SO, it would be something like this:
loadMovie("main.swf", "products"); now wait 10 seconds and then
loadMovie("main2.swf", "products"); now wait 10 seconds and then...
loadMovie("main3.swf....
Thanks in advance for any help.
SetInterval - Help Please
Hi, this is my first post on FlashKit.
I am building my first real project in Flash 8 Professional and I have a question that I can't seem to find an answer to in the docs. It seems fairly straightforward. Let me layout the problem:
1. load data from an XML file (got that part)
2. load objects on stage with parsed data (got that part)
3. iterate through nested entries and hold for X seconds on each entry
4. since these are "featured items" it needs to loop.
OK, I have the first 2 done. The last for some reason isn't working for me.
Code:
var oXMLData = new XML();
oXMLData.ignoreWhite = true;
oXMLData.onLoad = processXMLData;
oXMLData.load("items.xml");
CycleThroughItems();
It seems as though CycleThroughItems() is firing before the XML data is loaded.
If I put the call to CycleThroughItems() inside processXMLData() then it fires.
That's not the REAL problem though as there probably some detail about how Flash processes ActionScript that I don't understand.
The REAL problem is that even though I have setInterval in my code it doesn't seem to make any difference.
Here is a code sample:
Code:
/* this function works fine */
function processXMLData(success) {
if (success) {
var oRootNode= this.firstChild;
var sTitle:String= "";
var sAbout:String= "";
var sPrice:String= "";
var sMoreInfoURL:String= "";
var sImagesPrefix:String= "";
for(var i = 0; i < oRootNode.childNodes.length; i++) {
sTitle = getValue(findNode(oRootNode.childNodes[i], "Title"));
sAbout= getValue(findNode(oRootNode.childNodes[i], "About"));
sPrice= getValue(findNode(oRootNode.childNodes[i], "Price"));
sMoreInfoURL= getValue(findNode(oRootNode.childNodes[i], "MoreInfoURL"));
sImagesPrefix= getValue(findNode(oRootNode.childNodes[i], "ImagesPrefix"));
aItems[i]= new Item(sTitle, sAbout, sPrice, sMoreInfoURL, sImagesPrefix);
}
/* Load objects with JPEGs. */
trace("aItems.length = " + aItems.length);
if(aItems.length > 0) {
RotateItems(0);
} else {
address_dt.text = "no items found";
}
}
}
/* this function works fine */
function getValue(node) {
if (node && node.firstChild) {
return node.firstChild.nodeValue;
} else {
return "";
}
}
/* this function works fine */
function findNode(node, nodeName) {
if (node.nodeName==nodeName) {
return node;
} else {
for(var i = 0; node.childNodes && i < node.childNodes.length; i++) {
var foundNode = findNode(node.childNodes[i], nodeName);
if (foundNode != null)
return foundNode;
}
return null;
}
}
/*
I think the problem is in here.
*/
function LoadItem(lid:Number) {
trace("LoadItem(" + lid + ")");
/* -- REMOVED CODE FOR CLARITY --
Here is where I load the objects on stage
with the data ... the removed code works fine.
*/
for(var vid = 0; vid < iNumImages; vid++) {
iCurrentInterval = setInterval(LoadItemView, iNumSeconds * 1000, lid, vid);
}
lid++;
if(lid >= aItems.length) {
lid = 0;
}
}
function LoadItemView(lid:Number, vid:Number) {
var v_temp = vid + 1;
loadMovie(sItemImagesDir + aItems[lid].ImagesPrefix + "_" + v_temp + ".jpg", view_mc.image);
}
var oXMLData = new XML();
oXMLData.ignoreWhite = true;
oXMLData.onLoad = processXMLData;
oXMLData.load("items.xml");
Lag Due To SetInterval()
it's fine for about 10 seconds...then it starts running then it seems to run the function more often because it duplicats an object quicker...after a minute there is some serious lag!!
i have lockated the problem to here....
Code:
onClipEvent (load) {
//lag here
function trail() {
clearInterval(trailinterval);
duplicateMovieClip(_root.player, "player"+i, i);
trailinterval = setInterval(trail, 100);
}
trailinterval = setInterval(trail, 10);
var i = 0;
}
The player object is deleted. so it's not that.
when i clicked display variables it came up with:
(i never use this, but it looked weird and i thought it might help find the problem)
Code:
Level #0:
Variable _level0.$version = "WIN 7,0,14,0"
Variable _level0.trailinterval = undefined
Movie Clip: Target="_level0.playerundefined"
Variable _level0.playerundefined.trail = [function 'trail']
Variable _level0.playerundefined.trailinterval = 3478
Variable _level0.playerundefined.i = 0
Movie Clip: Target="_level0.player"
Variable _level0.player.trail = [function 'trail']
Variable _level0.player.trailinterval = 3462
Variable _level0.player.i = 406
Movie Clip: Target="_level0.player0"
Variable _level0.player0.trail = [function 'trail']
Variable _level0.player0.trailinterval = 3477
Variable _level0.player0.i = 0
Movie Clip: Target="_level0.player386"
Variable _level0.player386.trail = [function 'trail']
Variable _level0.player386.trailinterval = 3467
Variable _level0.player386.i = 0
Movie Clip: Target="_level0.player388"
Variable _level0.player388.trail = [function 'trail']
Variable _level0.player388.trailinterval = 3468
Variable _level0.player388.i = 0
Movie Clip: Target="_level0.player390"
Variable _level0.player390.trail = [function 'trail']
Variable _level0.player390.trailinterval = 3469
Variable _level0.player390.i = 0
Movie Clip: Target="_level0.player392"
Variable _level0.player392.trail = [function 'trail']
Variable _level0.player392.trailinterval = 3470
Variable _level0.player392.i = 0
Movie Clip: Target="_level0.player394"
Variable _level0.player394.trail = [function 'trail']
Variable _level0.player394.trailinterval = 3471
Variable _level0.player394.i = 0
Movie Clip: Target="_level0.player396"
Variable _level0.player396.trail = [function 'trail']
Variable _level0.player396.trailinterval = 3472
Variable _level0.player396.i = 0
Movie Clip: Target="_level0.player398"
Variable _level0.player398.trail = [function 'trail']
Variable _level0.player398.trailinterval = 3473
Variable _level0.player398.i = 0
Movie Clip: Target="_level0.player400"
Variable _level0.player400.trail = [function 'trail']
Variable _level0.player400.trailinterval = 3474
Variable _level0.player400.i = 0
Movie Clip: Target="_level0.player402"
Variable _level0.player402.trail = [function 'trail']
Variable _level0.player402.trailinterval = 3475
Variable _level0.player402.i = 0
Movie Clip: Target="_level0.player404"
Variable _level0.player404.trail = [function 'trail']
Variable _level0.player404.trailinterval = 3476
Variable _level0.player404.i = 0
[F8] Need Some Help With SetInterval
Hi,
I have a flash file wich has 3 movieclips (in an other movieclip) that I like to play randomly with a pause of 3 sec.
i got the random part done, but i cant get the setInterval to work like i want.
The setInterval works one time. I would realy apreciate if can someone can help me with my script?
Code:
var allMC:Array = new Array();
allMC.push(this.clips.mc1);
allMC.push(this.clips.mc2);
allMC.push(this.clips.mc3);
var totalframes;
var myInterval:Number;
var Duration:Number = 3000;
i = 1;
clips.onEnterFrame = function() {
myInterval = setInterval(speel, Duration);
function speel() {
totalframes = allMC[test]._totalframes;
if (i == 1) {
test = Math.floor(Math.random()*3);
clearInterval(myInterval);
if (allMC[test]._currentframe == 1) {
allMC[test].gotoAndPlay(1);
i++;
}
} else if (allMC[test]._currentframe == totalframes) {
allMC[test].gotoAndStop(1);
v = test;
while (v == test) {
test = Math.floor(Math.random()*3);
}
allMC[test].gotoAndPlay(1);
clearInterval(myInterval);
}
}
};
Do I Use A SetInterval(); ?
I have a movieClip that I need to load into my main stage. Once it is there I have 3 different animations that I'd like to play randomly at 10 second intervals. Where do I begin?
Thanks in advance
SetInterval (); Help?
hello all, basically i have the following functionality on a button instance, which works fine.
on (release) {
worldTemp = Number(coralTemp) + Number(phytoTemp) + Number(bugTemp);
for (depth =330; depth <worldTemp; depth++)
{
world_mc.duplicateMovieClip("newclip_world"+depth, depth);
_root["newclip_world"+depth]._x = int(Math.random()*500);
_root["newclip_world"+depth]._y = int(Math.random()*500);
}
}
but i want the same action to happen with out needing to press the button. So every 10 seconds i want to automatically update worldTemp, something like this......
function getTemp():Void {
worldTemp = Number(coralTemp) + Number(phytoTemp) + Number(bugTemp);
for (depth =330; depth <worldTemp; depth++)
{
world_mc.duplicateMovieClip("newclip_world"+depth, depth);
_root["newclip_world"+depth]._x = int(Math.random()*500);
_root["newclip_world"+depth]._y = int(Math.random()*500);
updateAfterEvent();
}
var newTemp = setInterval(getTemp, 1000);
can someone point me in the right direction??
[F8] Further Help On SetInterval
I saw the post on basic code for it, but my code is still not working right. I've been struggling on this one bit of code for over a week and I'm about to pull my hair out over this one... *nervous laughter*
So, here's my code:
Code:
stop();
millisecondsToDelay = 3*1000;
myFutureFunction = function () {
clearInterval(ih);
BgStr_mc.onLoad = function() {
var txt:TextField = this.createTextField("txt", this.getNextHighestDepth(), this._width/2, this._height/2, 200, 50);
var x = Stage.width/2;
var y = Stage.height/2;
BgStr_mc._x = x;
BgStr_mc._y = y;
var fmt:TextFormat = new TextFormat();
fmt.color = 255;
fmt.font = "Verdana";
fmt.size = 24;
rnd = Math.round(Math.random()*(block.length));
if (block[rnd]<0) {
var temp = Math.round(block[rnd]*amount);
txt.text = temp;
amount += temp;
}
if (block[rnd] == 0) {
gotoAndStop(10);
} else {
txt.text = block[rnd];
amount += block[rnd];
}
txt.setTextFormat(fmt);
if (amount>max) {
amount = max;
}
if (amount<0) {
amount = 0;
this.gotoAndPlay(10);
}
amt.text = amount;
block.splice(rnd, 1);
};
};
ih = setInterval(myFutureFunction, millisecondsToDelay);
BgStr_mc.onRelease = function() {
txt.text = "";
gotoAndStop(7);
};
I'm using some mc as buttons to randomly select a value from an already made array. there is another mc that comes and enlarges taking up the entire screen. I want a textbox to be formed on top of the big mc with the value that was pulled from the array. I've gotten it to work before, but the textfield would show up right after I pressed the button... Any help would be appreciated
[F8] SetInterval
Hey guys,
Basically what I want is for a function to be called every x milliseconds, but the thing is, x milliseconds will change over time. So what i've done to try and get this it work is made a little ball mc and put it on the first frame, along with this code on the first frame:
Code:
interval = 10;
vel = 2;
movement = function() {
ball._x += vel;
if (ball._x >= 512 - ball._width / 2 || ball._x <= ball._width / 2) {
vel *= -1;
}
}
setInterval(movement, interval);
onMouseDown = function() {
interval -= 1
}
Now, I want interval to change, which it does. However, the actual interval of the setInterval thing doesn't change. I've tried a few ways to get around this, but none of them worked.
Basically what I want is for the setInterval function to update what inverval is, so it calls the function sooner and sooner. Hopefully you get the point.
Thanks in advance,
- Gordon.
[F8] Help W/ SetInterval
Code:
var intervalId:Number;
var count:Number = 0;
var maxCount:Number = 10;
var duration:Number = 20;
function executeCallback():Void {
trace("executeCallback intervalId: " + intervalId + " count: " + count);
if(count >= maxCount) {
clearInterval(intervalId);
}
count++;
}
intervalId = setInterval(this, "executeCallback", duration);
can someone please explain why var intervalId is == to 1?
what part of this code below sets intervalId to 1?
Code:
intervalId = setInterval(this, "executeCallback", duration);
any help is greatly appreciated.
thanks in advance
[F8] SetInterval Help
I have a gallery that is displayed on the screen with the following code:
Quote:
var i = 0;
//initiate positioning
var sc_x = 0;
var sc_y = 0;
var rowcount = 1;
function doGall()
{
this.createEmptyMovieClip("container"+i, this.getNextHighestDepth());
targ = eval("container"+i);
id = photos[i].firstChild.firstChild;
targ.attachMovie("photoz", "photoza", this.getNextHighestDepth(), {theID:id});
targ._x = sc_x;
targ._y = sc_y;
sc_x = sc_x+159;
rowcount++;
if(rowcount > 3)
{
sc_x = 0;
sc_y += 80;
rowcount = 1;
}
//increment counter
i++;
populate(targ);
//clears interval and stops loop
if(i>=8)
{
//array
for(f=0; f<8; f++)
{
nameArray[f] = eval(_root.gallery["container"+f]);
}
//end array
clearInterval(myint);
}
}
//interval
var myint = setInterval(this, "doGall", 200);
stop();
the thumbnails created receive the following function onclick
Quote:
function doMove()
{
trace(o);
newint = setInterval(this, "doMove", 200);
targ = nameArray[o];
//create new Points
var finPoint = {};
sX = targ._x;
sY = targ._y;
finPoint.x = _root.coord._x;
finPoint.y = _root.coord._y;
targ._parent.globalToLocal(finPoint);
targ.onEnterFrame = function()
{
cPosX = this._x;
dPosX = finPoint.x-cPosX;
moveX = dPosX/2;
this._x += moveX;
cPosY = this._y;
dPosY = finPoint.y-cPosY;
moveY = dPosY/2;
this._y += moveY;
if(Math.abs(Math.ceil(dPosX)) == 0 && Math.abs(Math.ceil(dPosY)) == 0) delete targ.onEnterFrame;
}
o++;
}
My problem is that I can either not Get the setInterval to work... as In I can't figure a way to call it to stop once the var o has reached a certain value. tryed a few scenario but can't put my finger on it.
--Oliver
SetInterval..
how to call setInterval to loop again after the clearInterval? example.. if i press button i want to call the loop again do its function. Thanks..
|