Hello All,
I am loading 4 images into 4 empty movie clips.
----
this.createEmptyMovieClip("cell1", 1)
this.createEmptyMovieClip("cell2", 2)
this.createEmptyMovieClip("cell3", 3)
this.createEmptyMovieClip("cell4", 4)
cell1._x=0
cell1._y=0
cell2._x=200
cell2._y=0
cell3._x=200
cell3._y=200
cell4._x=0
cell4._y=200
cell1._alpha=0
cell2._alpha=0
cell3._alpha=0
cell4._alpha=0
loadMovie("images/g1.jpg", "cell1");
loadMovie("images/g2.jpg", "cell2");
loadMovie("images/g3.jpg", "cell3");
loadMovie("images/g4.jpg", "cell4");
---
Now what I am trying to do is fade in each clip.
fadeIn = function (cell1){
if (cell1._alpha < 100)
{ cell1._alpha += 4;
}
if (_alpha == 100){
clearInterval();
}
}
onEnterFrame = function() {
fadeIn(this.cell1);
//fadeIn(this.cell2);
};
---
So that works. (I am sure it is not pretty code, but I am learning)
Now here is the twist.
For each of the 4 clips I want the image to fade in at different intervals.
cell1 starts, then say 5sec. later cell2 starts, and 5sec. later cell3 starts etc...
function wait(cell2, n) {
cell2.stop();
other_mc.stop();
// use setInterval to trigger something n seconds later
// and assign it a variable "myInterval" so you can clear it later
// otherwise it would repeat the same action forever
var myInterval = setInterval(function () {
cell2.fadeIn();
other_mc.play();
clearInterval(myInterval); // now that everything is playing again, clear the interval
}, 5 * 1000); // n*1000 milliseconds = n seconds
}
Any pointers would be great.
Thanks,
Justin
fadeIn with setInterval pause
Started by kawabuz, Apr 01 2006 01:10 PM
5 replies to this topic
#1
Posted 01 April 2006 - 01:10 PM
#2
Posted 01 April 2006 - 01:57 PM
if you are using Flash8, I would have a look at the tween class, which does that job much easier then hand-writing everything from scratch.
#3
Posted 01 April 2006 - 02:18 PM
Thanks Funysoul.
I opened the "tweenProgress.fla" in Flash 8.
However it far more advanced than my skills/knowledge.
I think my question is more about writing a function that does multiple things.
function loader(theClip, wait, fadeIn){};
So can "wait' and "fadeIn" be called or does it all need to be in one function "loader"
with the instuction for each listed within the loader function.
Thanks for any guidance.
Justin
I opened the "tweenProgress.fla" in Flash 8.
However it far more advanced than my skills/knowledge.
I think my question is more about writing a function that does multiple things.
function loader(theClip, wait, fadeIn){};
So can "wait' and "fadeIn" be called or does it all need to be in one function "loader"
with the instuction for each listed within the loader function.
Thanks for any guidance.
Justin
#4
Posted 01 April 2006 - 02:24 PM
here a snippet of the tween class I've used on a project:
You are trying to achieve the same like I did on this earlier project, and believe me this is the easiest way to get it
If you want you can PM me your email address and I send you the fla file
import mx.transitions.*;
import mx.transitions.easing.*;
var ts1:TransitionManager = new TransitionManager(ts1_mc);
ts1.startTransition({type:Fade, direction:Transition.OUT, duration:5, easing:easeOut});
var myListener:Object = new Object();
myListener.allTransitionsOutDone = function(eventObj:Object){
gotoAndStop(2);
}
ts1.addEventListener("allTransitionsOutDone", myListener);
stop();
You are trying to achieve the same like I did on this earlier project, and believe me this is the easiest way to get it
If you want you can PM me your email address and I send you the fla file
#5
Posted 02 April 2006 - 01:02 PM
Hi funkysoul.
I got the file. But it was not quite the answer.
Here is what I have now.
//===============
//global timer skeleton
global.myTimer = new Object();
_global.myTimer.id = setInterval(_global.myTimer.callback, 1000);
_global.myTimer.callback = function()
{
//-- Do what ever you want....
};
//===================================
//create holder clips, set x&y, load images
this.createEmptyMovieClip("cell1", 1)
this.createEmptyMovieClip("cell2", 2)
this.createEmptyMovieClip("cell3", 3)
this.createEmptyMovieClip("cell4", 4)
cell1._x=0
cell1._y=0
cell2._x=200
cell2._y=0
cell3._x=200
cell3._y=200
cell4._x=0
cell4._y=200
loadMovie("images/g1.jpg", "cell1");
loadMovie("images/g2.jpg", "cell2");
loadMovie("images/g3.jpg", "cell3");
loadMovie("images/g4.jpg", "cell4");
//====================================
//crazy prototype function thing that does the fade
MovieClip.prototype.customFade = function(desAlpha, rate, interval){
if (!interval) interval = 50;
var mc=this, fade=rate*((desAlpha>mc._alpha)*2-1), ID=setInterval(function(){
trace("call: "+dir)
if (Math.abs(mc._alpha - desAlpha) < rate){
mc._alpha = desAlpha;
clearInterval(ID);
}else{
mc._alpha += fade;
updateAfterEvent();
}
}, interval);
}
//calling the fade
cell1._alpha = 0;
cell1.customFade(100, 20, 50);
cell2._alpha = 0;
cell2.customFade(100, 15, 50);
cell3._alpha = 0;
cell3.customFade(100, 10, 70 );
cell4._alpha = 0;
cell4.customFade(100, 10, 75);
//==========================
So I want to control to the start time of the fade.
Either with set interval or a global timer.
I am not sure how to do either or if that is even the answer,
Thanks for any insight,
Justin
I got the file. But it was not quite the answer.
Here is what I have now.
//===============
//global timer skeleton
global.myTimer = new Object();
_global.myTimer.id = setInterval(_global.myTimer.callback, 1000);
_global.myTimer.callback = function()
{
//-- Do what ever you want....
};
//===================================
//create holder clips, set x&y, load images
this.createEmptyMovieClip("cell1", 1)
this.createEmptyMovieClip("cell2", 2)
this.createEmptyMovieClip("cell3", 3)
this.createEmptyMovieClip("cell4", 4)
cell1._x=0
cell1._y=0
cell2._x=200
cell2._y=0
cell3._x=200
cell3._y=200
cell4._x=0
cell4._y=200
loadMovie("images/g1.jpg", "cell1");
loadMovie("images/g2.jpg", "cell2");
loadMovie("images/g3.jpg", "cell3");
loadMovie("images/g4.jpg", "cell4");
//====================================
//crazy prototype function thing that does the fade
MovieClip.prototype.customFade = function(desAlpha, rate, interval){
if (!interval) interval = 50;
var mc=this, fade=rate*((desAlpha>mc._alpha)*2-1), ID=setInterval(function(){
trace("call: "+dir)
if (Math.abs(mc._alpha - desAlpha) < rate){
mc._alpha = desAlpha;
clearInterval(ID);
}else{
mc._alpha += fade;
updateAfterEvent();
}
}, interval);
}
//calling the fade
cell1._alpha = 0;
cell1.customFade(100, 20, 50);
cell2._alpha = 0;
cell2.customFade(100, 15, 50);
cell3._alpha = 0;
cell3.customFade(100, 10, 70 );
cell4._alpha = 0;
cell4.customFade(100, 10, 75);
//==========================
So I want to control to the start time of the fade.
Either with set interval or a global timer.
I am not sure how to do either or if that is even the answer,
Thanks for any insight,
Justin
#6
Posted 04 April 2006 - 02:29 PM
now this is a nice nutcracker... 
I'm working on it.. it's just a matter of years now
I'm working on it.. it's just a matter of years now
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
