|
-
</hate>
setInterval- Should be easy
Hey all. So I'm making a website, all flash. I have a content window where my external .swf's are loaded into. I'm using kind of a verticle wiping look to transition between .swf's. I want my button to wipeout the current .swf (already set up) wait 2 seconds, then wipe in the .swf corresponding to the button I pressed. I'm a little confused on where to put the function, and exactly how to call it froma button.
I have this on the first frame of my movie:
code: funtion newswait() {
loadMovie("news.swf",this.contents.holder);
trace("GOGOGOGO");
clearInterval(myTimer);
}
myTimer=setInterval(newswait,1500);
...and I have this on the button that I want to call the function:
code: on(press) {
//This wipes out the loaded .swf
this.contents.holder.play();
//I want a 2 second wait here, then execute the function.
newswait();
}
What am I doing wrong? Thanks in advance!
Last edited by dtone314; 10-19-2005 at 08:51 PM.
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
</hate>
bump... Hasn't anyone used setInterval before?
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
Senior Member
yes..many of us have..however I think you are going about this wrong.
I think you should "wipe in"...and have a preloader on the frame where the "wipe" is completely "in"...check for the external.swf to be loaded...and if so...go ahead and play the "wipe out" animation...
what is the result you are getting currently??
can you post yoru .fla seems liek it is initilized form the beginning..and is firing every 1.5 seconds..including the loading of said content as well..
-
</hate>
Just to clarify: The wiping motion is in the swf that is being loaded. I have a button that simply tells the loaded swf to play(); which makes it do the wipe out. This command works fine by itself, but when I put the function name in the line under that telling it to play(); it loads immediately, there is no pause or wipe out. My version of flash can only save as far back as MX 2004. Hope you have it :-). File is too large for FK, so you can download it here. The wiping swfs are here and here.
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
Senior Member
Nope...I wont touch anythign MX 2004 related..sorry..and I havent installed FLASH 8 yet...waiting for feedbakc still..
However...I woudl suggest you make your "wipe out" animation seperate fomr the external.swf...and make it on its own LAYER in the main/_root movie..
with a "blank/empty" container clip under this "wipe transition" layer..
this way you can use the same "transition" for ANY content you load into the empty clip..external.swf's..or dynamic.jpg's..whatever..
like here.. ths was made using this type of "logic" one preloader, one transition for anything I want to load..
http://www.dmstudios.net/test_2/
-
Senior Member
once you set yout setInterval..is fires... so before it gets "cleared"..it is triggered..which is why you see it play automatically.
-
</hate>
How could I make it so the function is only called onPress of my button?
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
Senior Member
hahah...damn..I just did this the other day too.. I bet its her somewhere..
have you tried declaring the setInterval as a variable? or calling it from within the fucntion?
Do you have AS2.0 specific code?
-
Senior Member
here is how I did mine... I actually had to comment out the clear/delete staements for it work correctly....(reason is still unclear to me as why it is working that way)
Code:
var cDamage = setInterval(circleDamage,200);
function circleDamage() {
if (_root.fight == "yes"){
_root.circleHP = _root.circleHP - _root.squareDamage;
}
};
this.onEnterFrame = function() {
this._x = this._x - _root.speed;
if (this.hitTest(_root.square_mc)) {
_root.fight = "yes";
_root.speed = 0;
//clearInterval(cDamage);
//delete setInterval;
}
if (_root.circleHP <= 0) {
_root.circle_mc._visible = false;
_root.speed =2;
_root.circleDamage = 0;
_root.fight = "no";
}
}
-
Senior Member
oh..ok..now I remember....I couldnt control my setInterval either..it was either constantly firing...not clearing...or not working...
so I had my setInterval fire (since I couldnt control it)...but in the function I had an if statement checkking for a variable before it would execute.
-
Senior Member
try this maybe?
Code:
funtion newswait() {
if (newswait == "ok") {
loadMovie("news.swf",this.contents.holder);
trace("GOGOGOGO");
clearInterval(myTimer);
}
}
myTimer=setInterval(newswait,1500);
button:
Code:
on(press) {
//This wipes out the loaded .swf
this.contents.holder.play();
//I want a 2 second wait here, then execute the function.
newswait == "ok"
newswait();
}
-
</hate>
In theory, that should work. Good idea. About using the same wiping animation for all: I would like to do that, but I'm not exactly sure how to go about it. I have a window with 60% alpha (parts of bg show through) and on that the text/content is loaded. How could I do something like that? Possible a mask on loader component?
-I'll let you know if that setInterval stuff works as soon as I test it. Thanks for your help!
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
</hate>
Hmm... that code did not work afterall... I'm not quite sure where to go, any suggestions?
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
Senior Member
it looks like your trying to PLAY it before you even load it..
the buttons PLAYS the contents of HOLDER_mc.....than after calls a function that tries to load it??
also..maybe try declaring or checking for your variables at _root level.
-
</hate>
the swf inside the holder is set up like this: Wipe In>Stop>Wipe Out>Stop. When I tell the swf inside the holder to play, it Wipes out, believe me, it works. After it's Wiped out should I unload the currently loaded swf before loading a new one?
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
</hate>
...there will be a swf loaded to start... like my "news" section will be showing.
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
</hate>
if seeing this would help you out, it's at http://www.theautumnrun.com/newSite.html
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
-
</hate>
SOLUTION! Ok, so after pondering this all night, I came up with this. The myTimer at the end is what was causing it to fire immediately. So this is what we do:
First Frame:
code: var myTimer;
function newswait() {
loadMovie("news.swf",this.contents.holder);
trace("GOGOGOGO");
clearInterval(myTimer);
}
function startWait(){
trace('startWait');
myTimer = setInterval(newswait, 2000);
}
and this is for the button:
code: on(press) {
this.contents.holder.play();
startWait();
}
And it works beautifully! Thanks a lot for you're help Whispers, appreciate your time.
- dtøne-
Flash CS4 | AS2
Life is a journey, not a destination.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|