Login or Sign up Help | Site Map
Connecting Tech Pros Worldwide

Load a swf with movieClipLoader from the click of a button

Question posted by: Max58kl (Newbie) on April 26th, 2008 03:09 PM
Hi

I am trying to load a swf file using the MovieClip loader object.

var myMCL:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
myMCL.addListener(myListener);

At the moment I have the swf loading as soon as a frame is entered on the timeline.

this.button1.onPress = function() {
gotoAndStop("framex");
}

Code on frame

myMCL.loadClip("my.swf", 50);

Is there a way to load the swf as soon as the button is clicked.

Something like


button1.onRelease = function() {
myMCL.loadClip("my.swf", 50);
}

Any help would be welcome!
Would you like to answer this question?
Sign up for a free account, or Login (if you're already a member).
Max58kl's Avatar
Max58kl
Newbie
24 Posts
April 28th, 2008
08:44 PM
#2

Re: Load a swf with movieClipLoader from the click of a button
Hi

I seem to have solved the problem using the following code -


imgBtn.onRelease = function()
{
_root.createEmptyMovieClip("holder", 1)
loadMovie("main.swf", "holder");
_root.holder._xscale; //width scale
_root.holder._yscale; //height scale
}

If you want to load a jpg instead of a swf just change main.swf to main.jpg.
You can also specify the hight and width of the file you are loading using -


_root.holder._xscale = 225; //width scale
_root.holder._yscale = 175; //height scale

Reply
kelleyg's Avatar
kelleyg
Newbie
4 Posts
June 6th, 2008
06:26 PM
#3

Re: Load a swf with movieClipLoader from the click of a button
I use a master SWF called Index, with a main bar of buttons; each button opens a SWF from the assets folder -

For a button called genInfoBtn which, when clicked will open introduction.swf, I wrote this:

//this will load external SWFs
on (release) {
stop();
stopAllSounds();
_root.myMCL.loadClip("assets/swfs/introduction.swf", 5);
}

Reply
Reply
Not the answer you were looking for? Post your question . . .
170,098 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Top Flash / Actionscript Forum Contributors