381 posts
  • Has been part of the Envato Community for over 7 years
  • Has referred 50+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+2 more
Yvo says

Hi guys, this might have been asked and answered before, but don’t know exactly what to look for in the forum. I want to know if it is possible to control the timeline of an external swf loaded in with loadMovie.

Example: Let’s say I have a main file in which I have 2 button mc’s with instance names btn1 and btn2. I have a holder mc on which I can load my swf. Let’s call that external.swf. This external swf has a stop command in frame 1 and in that last frame of its timeline.

When I press btn1 I want it to load in the external.swf onto the holder just using the loadMovie command. Nothing difficult here of course. When it is loaded in it stays on frame 1 due to the stop command in frame 1. I want the external.swf to start going to frame 2 (and thus start playing until the last frame) when I press btn2. Is this possible? And if so, how?

8357 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

I know this is do-able as I do it all the time but in AS3 , not AS2 …

Once you have stored it to your holder variable maybe try this

holder.externalSWF.gotoAndPlay(2);

In AS3 i’d use:

// store loaded content
swf = MovieClip(e.currentTarget.content)

swf.gotoAndPlay(2);

easy :D

8357 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says

come to think of it there was a file not that long ago that allowed to go scroll through the frames of a loaded swf, maybe have a quick search for that, within the last week or so I think…

4806 posts Interactive Design
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Interviewed on an Envato blog
  • Made it to the Authors' Hall of Fame
+8 more
digitalscience says

Yvo, this is the code for AS2 :

btn2.onPress = function() {
    holder.gotoAndPlay(2);
};
607 posts
  • Has been part of the Envato Community for over 7 years
  • Has referred 1+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
sanju1979 says
Yvo, this is the code for AS2 :
 btn2.onPress = function() { holder.gotoAndPlay(2); }; 

sorry digital science thats incorrect MSFX is correct

so it wil be like

yourbutton.onPress = function() { _root.yourholderinmainmovie.yourexternalswffile.gotoAndplay(2); }

thanks

4806 posts Interactive Design
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Interviewed on an Envato blog
  • Made it to the Authors' Hall of Fame
+8 more
digitalscience says
Yvo, this is the code for AS2 :
 btn2.onPress = function() { holder.gotoAndPlay(2); }; 

sorry digital science thats incorrect MSFX is correct

so it wil be like

yourbutton.onPress = function() { _root.yourholderinmainmovie.yourexternalswffile.gotoAndplay(2); }

thanks

wrong :P when you load a swf into a holder movieclip, the name of the swf root is the holder instance name. In your code – how exactly do you get the instance name of yourexternalswffile ?? Because when u load a swf you can only identify it by the level or movieclip it’s loaded into.

8357 posts Community Moderator
  • Has referred 10+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Attended one of our Meetups around the world
+9 more
MSFX Moderator says
Yvo, this is the code for AS2 :
 btn2.onPress = function() { holder.gotoAndPlay(2); }; 
sorry digital science thats incorrect MSFX is correct

YEAH !! 8)

but no lol :p

DS is right, when you load an external SWF into Flash as it is actually an Instance of the Timeline, and therefore you cannot give it a name…

This gave me an initial headache in AS3 but then I worked it out…

var swf:MovieClip;
var swfHolder:MovieClip;

// once swf has loaded, in your Event.COMPLETE function

swfHolder = MovieClip(e.currentTarget.content);

swf = new MovieClip();
swf.addChild(swfHolder);
swf.name = "whateverNameHere";

If I had tried to name the swfHolder instance I would get a compiler error or run time, cant remember which… :D

381 posts
  • Has been part of the Envato Community for over 7 years
  • Has referred 50+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+2 more
Yvo says

Thanks very much for the effort guys!!! I’ll give it a try.

279 posts
  • Has been part of the Envato Community for over 6 years
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+4 more
FonZ says

First off, don’t use the loadMovie command. It sucks.

use something like this:

//** //Function to load a clip or picture //** function theLoader(loadUrl, loadHold) { //flip our loadStat loadStat = true; //create a new loader object var mcLoader:MovieClipLoader = new MovieClipLoader(); //create a new listener object var mcListener:Object = new Object(); //function to give a visual representation of the loading progress //on load init mcListener.onLoadInit = function(target:MovieClip) { //flip the load track variable loadStat = false; //if there is a next function, trigger it nextFunc(); //clear the trigger nextFunc = nada; }; //add a movieclip loader mcLoader.addListener(mcListener); }

//load the clip
mcLoader.loadClip(loadUrl, loadHold);

What you would do is create a holder (which you did), have an external file (which you have) and simply call the function

theLoader(“myswf.swf”, holderMc);

How does this help? Well NOT .. But it gives you a. more control over loading (maybe check the loadStat) b. an option to directly work on the clip once loaded, by adding instructions at the onLoadInit. There you could state, loadHold.gotoAndStop(1); or you could trigger a function like myFunction(loadHold) and the instance name gets passed without any problems.

If you keep running into trouble, add trace(loadHold._name) to the onLoadInit and it will display the name of the holder (DS is correct)..

you should basicly only use loadMovie when you don’t want to control, modify or whatever.

good luck

381 posts
  • Has been part of the Envato Community for over 7 years
  • Has referred 50+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 1+ items on Envato Market
+2 more
Yvo says

I know my question might sound like I’m a beginner, but I’m not. I was just wondering if it is possible, cause I’m trying something. I used loadMovie in my file, cause I did not need to have control over the loading. Just a very simple load in of an swf.

When making a gallery or something like that, I always use the movieClipLoader class, so I can use preloaders for images. Cheers for the help Fonz, but I was already aware of loading in images this way. ;)

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by