Playing Mcs In Intervals
was wondering if anyone had a good aproach to play different mcs with a certain pause between each play command
i used to just put something at the end of an mc's timeline that would play the next mc... but i want to try and centralize the code
i have a few mc... all sitting there with a stop in begining and end... i want to say mc1.play(); ... wait 2 sec... mc2.play()... wait 3 sec ... etc
any ideas?
FlashKit > Flash Help > Flash ActionScript
Posted on: 08-29-2002, 11:21 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Playing At Random Intervals...
hello all.
on my timeline there are 3 stops.
at each stop i would like to set some actionscript that says play at random time intervals. so the play head pauses at the stop(); for the random time before it goes to the next.
random = time between 10seconds and 30seconds.
play on random
any help is appreciated.
Playing MC At Random Intervals
Hi, can anyone tell me how to code a movie clip to play at random times (i.e. wait five minutes and then pick a random number of minutes and play again). I scanned through the tutorials but there's a lot to go through and I'm not sure what to look at.
Playing A Sound At Specified Time Intervals
Help...
I need to play a sound at specified time intervals. Specifically I would like to create a tick-tock sound every second. I just can't seem to figure out how to do this. Below is the actionscript I have created so far. You will probably laugh when you read it, but, this is actually the first time I have tried it.....so don't laugh too hard...
icncDate = new Date()
seconds = icncDate.getSeconds()
minutes = icncDate.getMinutes()
hours = icncDate.getHours()
if (seconds<10) {
seconds = "0" + seconds
};
if (minutes<10) {
minutes = "0" + minutes
};
icncTimeTextField = (hours + ":" + minutes + ":" + seconds);
tick = new Sound ();
tick.attachSound(tick);
Not sure what to do now...Thanks in advance....
erik
Erik Rudnick, CCIE No. 9545
mailto:erik@kuriosity.com
Load And Keep Playing Consecutive Mcs At Intervals
Hi all -
I expect once again to be hitting my forehead and saying "d'oh"... this seems like something that should be easy to do but I'm having no luck... I have this feeling I could do this all with ActionScript but I don't know how...and now I'm stuck.
I'm trying to create an animation that will become part of an intro for a website. I want 1,092 slanted ovals (1 slanted oval instance in 28 lines of 39 each) to enter two lines at a time from either side of the screen (starting at top & bottom and ending in the middle), and end up as a parallelogram made up of these ovals.
I created 14 mc's with two lines each starting from the top and bottom and with the two in the 14th meeting at the center. These work great.
I tried placing them at 20-frame intervals on the main stage, and this produced some really funky results! (Neat, but not what I wanted.) I tried to nest them in another mc and use "gotoAndPlay" and frame labels; that didn't work (or maybe it would if I knew what I was doing!!!). I'm starting to get very depressed... I've spent a heck of a lot of time on this and still have a whole site to do!
Can anyone suggest a better way to do this? I'm even willing to start from scratch... And apologies if someone's already answered this... I tried searching for a solution but I don't seem to be using the right key words...
Flash On Another Computer Not Playing Correctly. Any Known Bugs With Intervals?
We have two PCs and two Macs here. I figured the macs would do strange stuff as usual but here is the problem.
I created a flash movie that extensively uses set intervals to hold the playhead in many frames along the timeline. I also have a navigation that has a pause, play, and go to beginning and end.
On my machine works fine. Flash 6 player and using MX. When an associate viewed it on his machine when he dragged the .swf into a browser with flash player 6 it ignored all the intervals and played continuous and the navigation didn't work at all.
So i created an EXE file from flash and this time the intervals worked on his machine but to me it seemed the intervals were off by a few seconds. Also the navigation still didn't work.
I use win2k with explorer and flash player 6.
He uses winxp with explorer and flash player 6.
Does anyone have any ideas?
Playing A Random Moive At Random Intervals
ello
basic rundown:
i have five movies on the stage that are stopped
i want to play one of the five at random intervals
here is what i knocked up:
Code:
minTime = 1000;
maxTime = 5000;
setInterval(function () {
trace("go bubbles");
_root.bub = "bubbles"+(random(6)+1);
_root.bub.play();
trace(bub);
}, Math.ceil(Math.random()*(maxTime-minTime+1))+(minTime-1));
it outputs random bubbles2, bubbles5 etc to the bub variable (as seen in the trace) but when i try to create a string so it plays the bub variable, it doesnt work.
yes i have the bubble movies labeled
im also not sure if the random interval changes each time, is there a way to do this?
thanks for any help
my priority is for the script to tell a random "bubbles" movie to play
thanks
Intervals?
hi, i have one interval at every 40secs which makes my enemys apear on screen i want another interval that is always 10secs earlier, which will display a warning saying that the enemy are coming.
i tried this but didnt work cant seam to change interval time once set?
setInterval(enemyapear, 40000);
warnspeed = 30000
setInterval(attackwarning, warnspeed);
the attackwarning makes the messge apear and add 1 to a list each time.
then on a onEnterframe i had if statements that if a list was 1 then set warnspeed to 70secs and after that if list >1 then add 40secs to the warnspeed eachtime it was completed.
Help With Some Intervals
i'm trying to make this setInterval. which is supposed to change a swf file every 5 secs but i'm not sure if i'm doing the right thing, ohh yeah i'm making this so it just progresively getting a file with a higher number...
but here is the actual code i got so far.
code: var slideInfoLV:LoadVars = new LoadVars ();
slideInfoLV.onLoad = function(success) {
if (success) {
slideCounter();
} else {
frameNum.text = "error";
}
}
slideInfoLV.load("vars/back_info.txt");
var curFrameNum:Number = 0;
function loadFrame () {
_level0.myMCL.loadClip("background/back" + curFrameNum + ".swf", this.backMC);
}
loadFrame();
onLoad = function (){
if (curFrameNum < Number(slideInfoLV.totalBacks) - 1){
setInterval(loadFrame,50000);
curFrameNum++;
}else {
curFrameNum = 0;
}
loadFrame();
slideCounter();
}
Help With Intervals, AS2
Hi I'm using FLash CS3 but working, as required, in AS2. I am modifying a slideshow tutorial so that users can press a button and skip to the slide they would like to view. This function works but I am having trouble with the clearing and resetting of the interval. After pressing one of the buttons, it seems there might be2 intervals running? Anyway, something is messing up the timing, even though the order remains fine. Can anyone point out what I'm doing wrong with that part? Download the fla here:
http://www.aftermath-creative.com/mw2.2.fla (4.9 MB)
and here is all the code I am working with, and it's the button codes that are messing things up (I think):
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 5;
var tweenTime:Number = 1;
pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);
function crossfade() {
if (currClip == pic1) {
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};
listen = new Object();
Key.addListener(listen);
buttons.firstButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic0');
};
buttons.secondButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic1');
};
buttons.thirdButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic2');
};
buttons.fourthButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic3');
};
Intervals
I need help setting Intervals.
Here is my code.
intervalId = setInterval(_root, "gotoAndPlay", 3900, "Loader", "1");
stop();
Next frame:
clearInterval(intervalId):
The problem is when I run the swf file or the exe file it doesn't work it skips to the beginning og the movie.
It works just fine when I preview in flash.
Can anybody help?
Different Intervals
Hi. I'm making a slide show. The images are in a txt file so what my script does is this:
I used setInterval to call a function but the time to call the function is always the same. What I want is that every image is displayed on diferent intervals.
My txt file: &time=2000,5000,1500,9000
that's the time for each image. How can I use this?
How can I make each image displays in it's right time?
thank you.
Using Intervals
I want to have a button that when moused over, slowly fades to 100% alpha, and when moused off, fades back away to 0%. My code works fine if I mouseover the button, wait for it to fade all the way up, and then mouse off.
If I quickly mouse over it and then just as quickly mouse off of it, it fades up perfectly fine, but then does NOT fade back away.
I set this up by creating a movie clip of the button fading in for 20 frames, stopping, and then fading out for 20 frames. It is called crystal1.
I am using intervals to run a function every frame that checks what the current frame is, and if it had finished playing the previous part of the movieclip to play the next part.
Any help would be greatly appreciated!
Attach Code
on (rollOver) {
clearInterval( interval1off );
var interval1on
interval1on = setInterval(crystal1on, 83);
function crystal1on() {
if ( _root.crystal1._currentframe == 40 or _root.crystal1._currentframe == 1 ) {
_root.crystal1.gotoAndPlay(1);
clearInterval( interval1on );
} else if ( _root.crystal1._currentframe == 20 ) {
clearInterval( interval1on );
}
}
}
on (rollOut) {
clearInterval( interval1on );
var interval1off
interval1off = setInterval(crystal1off, 83);
function crystal1off() {
if ( _root.crystal1._currentframe == 20 ) {
_root.crystal1.play();
clearInterval( interval1off );
}
}
}
Intervals?
can we have an actionscript where there is a button to control the movement of the object and not add setInterval in it?
A Little Help With Intervals..
Hi all! I need a little help with some stuff again. I've basically got a bit code that produces a line of numbers as navigation and most of it was written by stringy.
Here is the previous thread:
http://www.kirupa.com/forum/showthread.php?t=266639
The buttons work, but when I click on them I also want my slideshow to stop and possibly stay highlighted.
here is the bit of code that controls selecting the image and stuff:
ActionScript Code:
function dorelease() { clearInterval(myInterval); this._alpha = 100; p = this.ivar-1; nextImage();}
The clearInterval stuff normally stops the slideshow, but in this location it doesn't so I'm guessing it's something to do with _root or _level etc. But for the life of me I can't quite figure it out at the moment.
This is the bit of code that generates the buttons:
ActionScript Code:
mask._visible = false;function getButtons() { mask._width = 0; var clip = this.createEmptyMovieClip("paper", 10000); //clip.setMask(mask); clip._y = 556; clip._x = 10; for (var i = 0; i<cliparray.length; i++) { var clap = clip.attachMovie("btn", "btn"+i, i); clap._x = (clap._width+5)*i; clap.ivar = i; clap._alpha = 40; clap.myText.text = i+1; //clap.onPress = dopress; clap.onRelease = dorelease; //clap.onReleaseOutside= doreleaseOutside; clap.onRollOver = dorollover; clap.onRollOut = dorollout; } //mask.onEnterFrame = grow;}
Help With Intervals
Hi I'm using FLash CS3 but working, as required, in AS2. I am modifying a slideshow tutorial so that users can press a button and skip to the slide they would like to view. This function works but I am having trouble with the clearing and resetting of the interval. After pressing one of the buttons, it seems there might be2 intervals running? Anyway, something is messing up the timing, even though the order remains fine. Can anyone point out what I'm doing wrong with that part? Download the fla here:
http://www.aftermath-creative.com/mw2.2.fla (4.9 MB)
and here is all the code I am working with, and it's the button codes that are messing things up (I think):
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var currClip:MovieClip = pic1;
var arrPosition:Number = -1;
var picArray:Array = new Array("pic1","pic2","pic3","pic4");
var showpicTime:Number = 5;
var tweenTime:Number = 1;
pic1.attachMovie(picArray[++arrPosition],"pic",pic1.getNextHighestDepth());
pic2.attachMovie(picArray[++arrPosition],"pic",pic2.getNextHighestDepth());
pic1._alpha = pic2._alpha = 0;
new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var picInt:Number = setInterval(crossfade,showpicTime*1000);
function crossfade() {
if (currClip == pic1) {
var tween1:Tween = new Tween(pic2, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2:Tween = new Tween(pic1, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic1.pic.removeMovieClip();
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic2;
} else {
var tween1 = new Tween(pic1, "_alpha", Regular.easeIn, 0, 100 , tweenTime, true);
var tween2 = new Tween(pic2, "_alpha", Regular.easeIn, 100, 0 , tweenTime, true);
words.gotoAndStop('pic' + arrPosition);
buttons.gotoAndPlay('pic' + arrPosition);
if(++arrPosition >= picArray.length) {arrPosition = 0;}
tween2.onMotionFinished = function() {
pic2.pic.removeMovieClip();
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
currClip = pic1;
};
};
listen = new Object();
Key.addListener(listen);
buttons.firstButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 0;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic0');
};
buttons.secondButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 1;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic1');
};
buttons.thirdButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 2;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic2');
};
buttons.fourthButton.onRelease = function() {
clearInterval(picInt);
arrPosition = 3;
if (currClip == pic1){
pic2.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
} else {
pic1.attachMovie(picArray[arrPosition],"pic",pic1.getNextHighestDepth());
}
var picInt:Number = setInterval(crossfade,showpicTime*1000);
crossfade();
buttons.gotoAndPlay('pic3');
};
Clear ALL Intervals ?
hi there,
i 'd like to know if there is a way to clear all Intervals in a movie with one command...
in my current project I use setInterval()
very often in different clips and though i cleanly put the corresponding clearInterval() commands in the script I realized, that on slow computers some of them don't get stopped...
which puts more weight on the CPU and sometimes slows down the comp very much.
is there a fix ?
tia
Intervals Problem
Please help
What's wrong in this code?
Why do the 3 objects open with the same interval (1 second), when I set 3 different intervals?
Please help me fix this script...
Thanks a lot!
Keypress Intervals
i have a keypress, but i don't want it to repeat itself at a unbelievable speed. I would like the actions only to happen, at the fastest, half a second apart. This is my code:
on (keyPress "w") {
this.container.attachMovie("ollie", "container", 10);
_root.score = _root.score + 20;
}
I just want it so you can't hold down the button and rack up the points. Somekind of SetInterval thing. What script would i use?
Toggle At Intervals
Hi everybody,
I've got a movie clip called "modes" with only two frames and a stop action on each one. I want to toggle between these two frames at 10 second intervals. The problem with my code is that is keeps looping back to the first frame without ever resting on the second one. Here's what I've got:
_______________
function switchModes(direction) {
modes.alphaChange = -3;
modes.destinationframe = modes._currentframe+direction;
if (this._currentframe = 1) {
direction = 1;
} else {
direction = -1;
}
}
//change modes every 10 seconds
setInterval(switchModes, 10000);
//fade
modes.onEnterFrame = function() {
this._alpha += this.alphaChange;
if (this._alpha < 0) {
this.alphaChange=this.alphaChange*-1;
this.gotoAndStop(this.destinationFrame);
}
if (this._alpha > 100) {
this.alphaChange = 0;
this._alpha = 100;
}
}
_______________
Any ideas?
Thanks.
Interupt Intervals?
I give up. Can anyone tell me how i interrupt/stop an interval using a button. I've attached my TESTS.fla
The animation i have is in a movieclip. its in content movieclip: then on frame 30, inside changeImage movieclip is the animations and code. Please someone help me and my stupidness......
Clear/Set Intervals
I was wondering if someone can tell me if there is a way to find out what Intervals are currently active within a movie. I haven't come across a built in function, but does anyone have a hack?
Thanks!
Problem With Intervals
What i wish to do is tht: flash takes coordinates from .php file and adds them to a mc_object, and updates coordinates after period of time.
I got it work but very buggy. I want flash to take new coordinate after every 1 second(or so), instead of doing tht, flash gives me 100 new coordinates in a second. Changing the interval doesn't make big change.
Have a look at your self:
http://www.zone.ee/avp2estclan/texttest5.swf
Here's the source code:
code: //Loads variables from .php file
loadVariablesNum("replay2.php", 0);
//function for global (not to look)
ball.onEnterFrame = function () {
function coordinate(a, b, c) {
return ((a-b)/c);
}
//sets variable arv equal to 0
arv = 0
// function update starts for script looping (problem starts)
function update() {
// sets coordinates right for _global stuff...(not to look)
ax1 = coordinate(bx1, 370000, 496);
ay1 = coordinate(by1, 6376000, 488);
//adds +1 on every loop to variable arv
arv = arv + 1;
// joins the string "x" and "y" with number arv
bx1 = eval("x"+arv);
by1 = eval("y"+arv);
// check up
trace (ax1);
trace (ay1);
//sets ball coordinates equal to the coordinate got from .php file
setProperty(ball, _x, ax1 );
setProperty(ball, _y, ay1 );
}
// sets the update interval(problem ends(not realy, bec it doesn't work as needed))
interval = setInterval(update, 250);
}
The .php file source:
PHP Code:
&&x1=590081&&y1=6526734&&x2=543431&&y2=6583217&&x3=563168&&y3=6501676&&x4=634040&&y4=654914
And the source file:
http://www.zone.ee/avp2estclan/test.rar
I appriciate any help i can get.
Intervals And Path
do you old pros set all your intervals in _root?
had a problem stopping an interval in a loaded movie, this is the answer?
[F8] Help To Clear All Intervals
I need to clear all intervals within my mcKeyimage mc on the root when I go to other frames on the root not containing the mcKeyimage. The problem is I'm unable to figure out how to reach into the mcKeyimage to clear the interval that's running.
The mcKeyimage has timers set to go to other frames for fades in/out like like this:
(inside mcKeyimage)
on frame1:
Code:
stop();
var imageFader:Number = setInterval(nextframe, 4000);
function nextframe() {
gotoAndPlay(2);
trace("image2 interval called: "+getTimer()+" ms.");
}
on frame2:
Code:
clearInterval(imageFader);
trace("cleared image1 interval");
this.onEnterFrame = function(){
image1._alpha = Math.max(0, image1._alpha - 10);
image2._alpha = 100 - image1._alpha/10;
if (image1._alpha <= 0) {
delete this.onEnterFrame;
}
}
...and so on for 5 images.
My navigation is within a mc on the root:
in mcMainnav there is a mc with this function on it - I traced the clearInterval and on just the press, the key image is still fading:
Code:
onClipEvent(enterFrame){
onPress = function(){
_root.keyimage.clearInterval(imageFader);
trace("cleared interval");
_root.keyimage.stop();
trace("keyimage stopped");
}
onRelease = function(){
_root.gotoAndStop("426market");
}
}
Thanks for any help you can give!!
Matt
[F8] Intervals And Buttons
I am trying to put an interval inside of a button but for some reason it never calls the function(func2).
Here is the code in my button:
code: on (release)
{
func1();
}
and here's my code in Layer 1, Frame 1:
code: _root.stop();
func2 = function()
{
this.dice.gotoAndStop(rdmno);
clearInterval(timer1);
}
func1 = function()
{
rdmno = Math.floor(Math.random() * (20)) + 1;
this.dice.gotoAndStop(21);
timer1 = setInterval(func2, 2000);
}
[CS3] Help With Intervals, I Can't Get Them To Work
Hi i am using as2 and i am somewhat new to flash and what i am trying to accomplish right now is to only advance to the next frame in the animation after a certain amount of tine rather than every frame. The reason i need to use intervals is because how fast the image changes is based on how fast the object is moving. So the faster it goes the faster the animation.
Here is my code
Code:
attached=true;
var updateImage = setInterval(function() {
this.gotoAndStop(_currentframe+1);
},(60/image_speed));
function onEnterFrame(){
if (attached==true){
this.image_speed=_root.player.image_speed;
this._x=_root.player._x;
this._y=_root.player._y;
this._rotation=_root.player._rotation;
}
}
the only variable that you really need to know is image_speed which is anywhere from 0.5 to 1.5. So if that is the case shouldn't my image only go to the next frame every 33-66 Ms? Because right now no matter what i set image_speed to it updates every step.
If you could help me i would appreciate it alot. Thanks
AS2.0 - For Loops And Intervals
Hey guys,
I'm trying to create a fade in and fade out effect with just Action Script and I'm having a bit of trouble. I'm no Action Script expert but I was able to decode a few things to put some code together. This is basically what I'm trying to do:
on (rollOver) {
var myInterval = setInterval(FadeUp, 1000);
function FadeUp () {
for (i = 0; i < 30; i++) {
brightcounter +=1
clearInterval(myInterval);
setBrightness(FirstNews_btn,brightcounter);
trace(brightcounter);
}//End For Loop
}//End of Function
}//End
The brightness fuction is defined somewhere else so dont worry about that. The problem is between the for loop and the intervals. What it's doing is delaying the evaluation of the for loop for the interval seconds, rather than delaying each for loop evaluation by the interval second. How do I correct this?
So what it does is when you roll over something, it holds than evaluates the for loop. What I want it to do is roll over something, evaluate once, then wait by seconds defined, then evaluate again till i > 30.
Array Of Intervals
So I have an array of interval names...
interN = ["id1","id2","id3","id4","id5","id6","id7","id8 "];
My for loop
for(i = 0;i < canN.length;i++){
n = "pd1.drip" + (i+1) + ".drip" + (i+1);
interN[i] = setInterval(wait,100,n,interN[i]);
}
My wait function
n= name of the instance
p= name of the interval id
wait = function(n,p){
eval(n).gotoAndPlay(2);
clearInterval(eval(p));
}
the wait function is not clearing the interval...
Is there something i am missing?
Problem With Intervals
I'm having an odd problem with intervals. I've posted about this before but never got an answer. Since then I've made some changes and modifications to that flash movie.
After loading a flash movie into another movie (home page) I then can click on a button to take me to another part of the site. then click back and it goes back to the home page. After you go back to the home page the interval I'm using to call a timed function messes up and calls randomly.
To see what I mean go to http://www.juliaveenstra.com and click gallery and then click home. watch the background pictures and you should see what I mean.
I've tried clearing the intervals, redefining them etc. with no luck. I'm really not sure what's going on here.
Any help is appreciated,
Thanks,
Intervals For Slideshow
Hi guys, have a problem, i made this flash presentation that consists of 8 slides all in all, one frame per slide, is there a way for me to set an interval for the slide like 30 secs before proceeding to the next slide? using action script ofcourse, i was wondering if i could avoid using the animation timeline. btw im using flash mx only not mx 2004. thanks
Toggle Between Intervals
I'm trying to toggle between intrvlFast and intrvlSlow. This is not working.
PHP Code:
Movieclip.prototype.startScale = function() {
scaleIt = function (mc) {
mc._xscale = mc._yscale += 10;
updateAfterEvent();
};
this.onRelease = function() {
if (!this.fast) {
clearInterval(this.intrvlSlow);
intrvlFast = setInterval(scaleIt, 25, this);
this.fast = true;
} else {
clearInterval(this.intrvlFast);
intrvlSlow = setInterval(scaleIt, 25, this);
this.fast = false;
}
};
};
mc1.startScale()
Any help?
Thanks in advance.
Can Get It To Play In Intervals
Just new to AS. So bear with me.
This script is inside a movie clip, of a star which shoots up along _y axis decelerating as it goes up and also fades out and starts again at the bottom to repeat the process. But I just need it to shoot up in 5 second intervals. So every 5 seconds it'll shoot up and fade out. I've tried setIntervals but it wouldt work for me (I'm sort of new at this to know what I'm doing ).
This is the script, sorry it's kinda messy I commented some things at:
onClipEvent (enterFrame) {
currentlocx = this._x;
currentlocy = this._y;
ball1locy = this._y + accely;//speedy1;
differencey = newY - currentlocy;
accely = differencey/accelFactor;
if (ball1locy < 0 + radiusball1) {
this._y = 78;
} else {
this._y = this._y + accely; //speedy1;
}
this._alpha = (this._y * 100) / 80;
}
onClipEvent (load) {
newY = 0;
speedy1 = -0.8;
speedx1 = 0;
radiusball1 = this._width/2;
accelFactor = 25;//Math.ceil(Math.random()*25) + 2;
}
Intervals Vs OnEnterframe
"Uses setInterval to emulate onEnterFrame events with decreased CPU usage"
I found this statement. Is this true? or is it if setIntervals are set to occur less than FPS ?
If Statement With Different Intervals
Hy there, wonder if anyone can help me out...
I'm doing a calculator in wich I have to perform an action according to result intervals of a dynamic box.
ie. When the result inthe dynamic box is between 25 and 30, it has to perform some action. If the result is between 30 and 35, a diferent action, and so on...
I have made a button to perform the if statement, but I can't specify more than one condition, can I?
I tryed to use some line codes like these:
ActionScript Code:
if(Number(25)<Number(dynamicbox)<Number(30)){
myaction;
}
if(Number(30)<=Number(dynamicbox)<Number(35)){
myaction2;
}
Someone have a clue for this?
Thanx a lot!
edu
Timing And Intervals
I'm sure this topic comes up often but I figured ... umm - well here it is again...
I'm wondering about he acuracy of timing. When I run an interval I can see some drift. With a simple application I'm calling an interval every 100 ms that gets the timer. these are the results
496
672
848
1024
1201
1376
1553
1728
1904
2076
2248
2351
2528
2704
2882
3057
3232
3409
3584
3763
3936
4112
4288
4464
that looks like some serious drif issue to me if the timing is off by 80%. In my practice I found that it's the getTimer is not very reliable, whereas the interval does a pretty good job. I don't really have a way of testing it really though. I'm planning on creating a small audio app. but the last time I tried it, with sounds a little appart, I heard some sounds drift quite often.
I recall hearing that this has been tuned a bit in the mx2004 version but I don't know if that's just a rumor
any thoughts on this?
Am I Clearing My Intervals?
hi all,
this is my code with the setinterval
Code:
function showPortfolio(selected, clip, xValue, yValue) {
var clip = this.createEmptyMovieClip("clip", 10);
clip._x = xValue;
clip._y = yValue;
for (i=0; i<selected.length; i++) {
clip.attachMovie(selected[i], selected[i], setDepth(i));
clip.selected[i]._alpha = 0;
}
portfolioInterval = setInterval(this, "showNextNav", 2000, selected, clip);
}
Now on each button I have
Code:
on (press) {
clearInterval(portfolioInterval);
showPortfolio(projectA, projectA_mc, 30, 50);
}
on (press) {
clearInterval(portfolioInterval);
showPortfolio(projectB, projectB_mc, 30, 50);
}
Am I really deleting portfolioInterval???
how can one trace all intervals???
Random Intervals
I have a ball that moves a long on a motion guide and it loops. Instead of having it loop constantly, I want it to loop, but at different intervals, like it would pause a few seconds then play.
Anyone got any ideas? Thanks in advance.
Intervals || Loop || Other
I have been working with flash since flash 4, but have just recently moved into MX actionscript & AS 2.0. I appreciate all the info on this website and forum, it has been an excellent resource.
I am building a movie where I need to "wait" until a scripted animation is complete before continuing the code. What is the best way to do this? Some reason it feels sloppy to do a while loop. Is there a way to use intervals or events to trigger this?
//discover if an additional expansion is needed
if(orgincmc!=optionid){
//HERE I MUST WAIT until previous move has been completed
containerexpand(optionid);
centerm(optionid);
this.cmc=optionid;
}
Thanks!
Time Intervals ?
Could someone tel me.... how to make some action happens after some time ??
I mean... imagine I have a ball moving randomly through the stage....
I want that... the ball stays on it's place for some time... then move to somehwere else.... stay there a while.... en repeat.
HOW ?
THANKS !!
Bye.
Intervals Without SetInterval()
Since Flash doesn't like to wait for loadVariables to actually receive the information, I need to find a way to make flash look from time-to-time to see if the information has been received.
I would use setInterval, only it's really buggy and there's a high chance the interval will be called again by the user, which will completely mess everything up.
I also cannot use something like this:
onEnterFrame {
count++;
if (count > 10){
count = 0;
....
}
}
because the movie is stopped.
Does anyone know another way to make some form of timer that will count to x seconds?
Problem With Intervals
What i wish to do is tht: flash takes coordinates from .php file and adds them to a mc_object, and updates coordinates after period of time.
I got it work but very buggy. I want flash to take new coordinate after every 1 second(or so), instead of doing tht, flash gives me 100 new coordinates in a second. Changing the interval doesn't make big change.
Have a look at your self:
http://www.zone.ee/avp2estclan/texttest5.swf
Here's the source code:
ActionScript Code:
//Loads variables from .php fileloadVariablesNum("replay2.php", 0);//function for global (not to look)ball.onEnterFrame = function () { function coordinate(a, b, c) { return ((a-b)/c); } //sets variable arv equal to 0arv = 0// function update starts for script looping (problem starts)function update() {// sets coordinates right for _global stuff...(not to look)ax1 = coordinate(bx1, 370000, 496);ay1 = coordinate(by1, 6376000, 488);//adds +1 on every loop to variable arvarv = arv + 1;// joins the string "x" and "y" with number arvbx1 = eval("x"+arv);by1 = eval("y"+arv);// check uptrace (ax1);trace (ay1);//sets ball coordinates equal to the coordinate got from .php filesetProperty(ball, _x, ax1 );setProperty(ball, _y, ay1 );}// sets the update interval(problem ends(not realy, bec it doesn't work as needed))interval = setInterval(update, 250);}
The .php file source:
PHP Code:
&&x1=590081&&y1=6526734&&x2=543431&&y2=6583217&&x3=563168&&y3=6501676&&x4=634040&&y4=654914
And the source file:
http://www.zone.ee/avp2estclan/test.rar
I appriciate any help i can get.
Scope Of Intervals
Hi,
To set the scene I've a flash movie loading a separate flash movie on the click of a button. This imported movie has a interval set to delay it playing.
My problem is that when the button is clicked more than once the interval will remain along with a new interval. I've been trying to clear the first interval from within the button code, and tryed to clear existing intervals on the load of the new movie, with no success. The ID of the intervals are available from within the button.
Are the Intervals available globally or tied to the movieclip they are created?
Thankyou for any help.
Clear All Intervals?
Hello all,
Any help or guidance on this would be greatly appreciated.....
Is there a way to see or clear ALL intervals?
Also..
Is there a way to list all MovieClips on _root and MovieClips within MovieClips?
TIA,
jc_
Help With Intervals Or Delay
the code below is to make a circle follow the line. but when i test movie, the circle will not start from 100, 100. it will directly go to the last point 370, 400. i need to set intervals between each lineTo function. but i don't know how to do it. can someone help me figure out how to write the interval function.
btw, the name of the circle is mymc.
help me someone, i need it as soon as possible. i need to finish it at least by tomorrow.
================================================== ====
this.createEmptyMovieClip("line_mc", 1);
this.attachMovie("mymc", "mymc", this.getNextHighestDepth());
line_mc.lineStyle(2, 0xFF00FF, 30);
mymc._x = 100;
mymc._y = 100;
line_mc.moveTo(100, 100);
mymc._x = 200;
mymc._y = 150;
line_mc.lineTo(200, 150);
mymc._x = 220;
mymc._y = 220;
line_mc.lineTo(220, 220);
mymc._x = 300;
mymc._y = 300;
line_mc.lineTo(300, 300);
mymc._x = 330;
mymc._y = 310;
line_mc.lineTo(330, 310);
mymc._x = 370;
mymc._y = 400;
line_mc.lineTo(370, 400);
How Many Intervals Can Run At The Same Time Before I Get Lag?
Hello,
I am making a game that uses a lot of separate movie clips with onEnterFrame actions happening at the same time. This can make it start to lag, since there are many of them.
I would like to use Intervals and EventListeners, since many of the MCs don't need to be doing anything most of the time.
Does anyone know how many intervals can be running simultaneously before it starts to create lag?
Thanks
All Intervals Go Off At The Same Time.
I'm still on my Pac Man game and I'm having trouble with intervals. I set them to go off ten to five seconds apart, yet they all go off at the same time. Here is my code.
Code:
function makeGhost(alias,toClear,depth){
clearInterval(toClear);
duplicateMovieClip(this.shell, alias, depth);
if(depth==1){
this.stinky._x = 257;
this.stinky._y = 191;
var myYello:Color = new Color(stinky);
myYello.setTransform({ra:255,rb:60,ga:255,gb:60});
}
if(depth==2){
this.blinky._x = 257;
this.blinky._y = 191;
var myBlub:Color = new Color(blinky);
myBlub.setTransform({ba:60,bb:255});
}
if(depth==3){
this.twinky._x = 257;
this.twinky._y = 191;
var myRed:Color = new Color(twinky);
myRed.setTransform({ra:60,rb:255});
}
if(depth==4){
this.drinky._x = 257;
this.drinky._y = 191;
var myGreen:Color = new Color(drinky);
myGreen.setTransform({ga:60,gb:255});
}
}
function begin(){
var ghostA:Number;
var ghostB:Number;
var ghostC:Number;
var ghostD:Number;
this.interMe = setInterval(this,"dirListening",10);
ghostA = setInterval(this, makeGhost('stinky',this.ghostA,1), 5000);
ghostB = setInterval(this, makeGhost('blinky',this.ghostB,2), 10000);
ghostC = setInterval(this, makeGhost('twinky',this.ghostC,3), 25000);
ghostD = setInterval(this, makeGhost('drinky',this.ghostD,4), 30000);
}
this.onLoad = begin;
The code makes a different named ghost appear and clear the interval. That part works, but all my intervals go off instantly without delay. What am I doing wrong?
Intervals || Loop || Other
I have been working with flash since flash 4, but have just recently moved into MX actionscript & AS 2.0. I appreciate all the info on this website and forum, it has been an excellent resource.
I am building a movie where I need to "wait" until a scripted animation is complete before continuing the code. What is the best way to do this? Some reason it feels sloppy to do a while loop. Is there a way to use intervals or events to trigger this?
//discover if an additional expansion is needed
if(orgincmc!=optionid){
//HERE I MUST WAIT until previous move has been completed
containerexpand(optionid);
centerm(optionid);
this.cmc=optionid;
}
Thanks!
Intervals And Clearing
Hiya all,
I have a 'catch them' minigame coded using intervals, and when the player wins the game doesn't seem to stop.
(i think it's interval related)
No one seems to be able to figure it out, thought i'd give you guys a shot.
does anyone know how to mass clear all intervals within a .swf?
|