View Full Version : [FMX] how to give button multiple commands
jcs
January 27th, 2003, 02:25 PM
I have this code on a button that relates to AS elsewhere in the movie (this works fine, BTW):
on (release) {
targety = -534;
targety2 = -813;
targety3 = 110;
targetx1 = -100;
}
and I want to add the following to the same on (release) command:
_root.createEmptyMovieClip("container", 1);
loadMovie("style.swf", "container");
container._x = 100;
container._y = 25 ;
But I don't know the proper syntax to make both work. Please advise. (Note: style.swf is in same local folder as the main movie)
Thanks,
JC
Guig0
January 27th, 2003, 02:30 PM
on (release) {
targety = -534;
targety2 = -813;
targety3 = 110;
targetx1 = -100;
_root.createEmptyMovieClip("container", 1);
container._x = 100;
container._y = 25 ;
loadMovie("style.swf", "container");
}
:)
jcs
January 27th, 2003, 02:42 PM
Thanks G!
While I have you, two more quesitons:
1. how would I use something like setInterval to load that movie a second after on(release)
2. I have four buttons like this. How best to unloadMovie when a different button is pressed?
eg. a button called "style" loads one movie, a button called "travel" loads a different movie into the same location. If "style" has loaded and I want to go to "travel," would I put unloadMovie as the first line on the "travel" button? Or no?=)
Guig0
January 27th, 2003, 02:47 PM
re:#1 - its very complicated, and i´m in a hurry (off to home now). do a search here @ kirupa on setinterval, senocular already had made this here...
re:#2 - just load all movies on the same level, and when you load another one the older will be raplaced :)
jcs
January 27th, 2003, 02:51 PM
thanks, will do.
h88
January 27th, 2003, 03:03 PM
Originally posted by Guig0
re:#1 - its very complicated, and i´m in a hurry (off to home now). do a search here @ kirupa on setinterval, senocular already had made this here...
Woah...complicated? Well basicaly The setInterval function is used to create an event that repeats continuously until the Flash movie is closed or the clearInterval function is passed.
Anywho, i didn't see senocular's post, but here you go:
Simply, just insert your loading process into a function, and then on load, (which i'll be working on it now) clear that interval! after the function, set an interval to that function for something like, 5000 millisecond. I'll try making a code for that one now!
jcs
January 27th, 2003, 03:21 PM
so something like...
on (release) {
targety = -534;
targety2 = -813;
targety3 = 110;
targetx1 = -100;
_root.createEmptyMovieClip("container", 1);
container._x = 100;
container._y = 25 ;
function pause(){
_root.loadMovie("style.swf", "container");
clearInterval(delay);
}
delay = setInterval(pause, 6000);
stop();
:q: (-:
h88
January 27th, 2003, 03:23 PM
Done!
myLoadVars = new LoadVars();
myLoadVars._parent = this;
myFunction = function () {
myLoadVars.onLoad = function(success) {
if (success) {
var nm = this._parent.createEmptyMovieClip("swfHolder", 1);
nm.loadMovie("myfile.swf");
clearInterval(myInterval);
} else {
trace("error loading your movie");
}
};
myLoadVars.load("myfile.swf");
};
myInterval = setInterval(myFunction, 2500);
h88
January 27th, 2003, 03:26 PM
Originally posted by jcs
function pause(){
_root.loadMovie("style.swf", "container");
clearInterval(delay);
}
delay = setInterval(pause, 6000);
ehh emm, no! Your clearing the interval this way, and therefore, your file will never get loaded, the example in my above post shows the working way, as i said, when your file get loaded, then the interval will be cleared!
jcs
January 27th, 2003, 03:55 PM
HA! It's gota be amusing for those of you in the know watching newbies like myself stumble through some tidbits of code! :beam:
works like a charm, except:
a couple seconds after the function is called and the movie loaded, the movie on main movie reloads behind the emptyMovieClip. Only does it once, that I can tell.
Thoughts?
h88
January 27th, 2003, 04:29 PM
Originally posted by jcs
a couple seconds after the function is called and the movie loaded, the movie on main movie reloads behind the emptyMovieClip. Only does it once, that I can tell.
Thoughts?
Did you add a stop action in the last frame of your main movie?
jcs
January 27th, 2003, 05:10 PM
i have, but it was still happening. However I closed and reopened and the problem has taken care of itself.
will let you know, though.
Thanks a lot, h88. :P
h88
January 27th, 2003, 05:17 PM
No problem, am glad you got it working!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.