[FMX] how to give button multiple commands

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

on (release) {
targety = -534;
targety2 = -813;
targety3 = 110;
targetx1 = -100;
_root.createEmptyMovieClip(“container”, 1);
container._x = 100;
container._y = 25 ;
loadMovie(“style.swf”, “container”);
}

:slight_smile:

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?=)

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 :slight_smile:

thanks, will do.

*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!

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: (-:

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);

*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!

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?

*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?

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. :stuck_out_tongue:

No problem, am glad you got it working!