Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / Flash / Flash Actionscript / July 2008



Tip: Looking for answers? Try searching our database.

another loadMovie question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
dtodab - 22 Jul 2008 03:11 GMT
hello.
i'm trying to target a specific frame within a loaded external swf. i read in
an earlier post the attached code, but it doesn't seem to be working for me. i
would appreciate any suggestions on how to achieve this.

b5.onRollOver = over;
b5.onRollOut = out;
b5.onRelease = function () {
    _root.loadMovie("bagosy_Promo.swf")
    gotoAndStop("Contact");
};
b5.buttText.buttonText.text = "CONTACT"
Rothrock - 22 Jul 2008 04:13 GMT
The code you have given has no chance of working. So that previous post was in
error as well. There is no way to go to a frame (labeled or numbered) before
that frame is loaded, in other words until it is loaded in it doesn't exist!

This kind of code says, "Okay flash start loading this movie, now go to a
frame." There is no waiting in there for the movie to finish loading.

So you need some way of waiting until the movie has loaded and then doing the
gotoAndStop.

I've got to rant for a moment here. Not directed at you, obviously you are
new(ish) to Actionscript and don't know. But for heck's sake why in this day
and age are people still using loadMovie? Since Flash 7 came out in 2003 there
has been a better way. Why aren't people learning this? What can we do to
change it? Okay, end rant!

The best way to do this is to use the MovieClipLoader class. That has built in
ways to know when the file has been loaded and then you can do what you need to
do.

var myMCL:MovieClipLoader=new MovieClipLoader();
var listener:Object=new Object();
listener.onLoadInit=function(target:MovieClip){
target.gotoAndStop("Contact");
}
myMCL.addListener(listener);

b5.onRelease=function(){
myMCL.loadClip("bagosy_Promo.swf",someClip);
}

So that code mostly does the same thing as before. However you were using the
accursed loadMovie to load into the _root. It is generally a bad idea to
replace the contents of the _root (or _level0) with some new content. There are
a few little things that occasionally go wrong. But I just find it to be a bad
idea. In this case the code that you hope to execute lives (I'm guessing)
somewhere in _root or a child of _root. So if you replace root how could that
code execute?

So in my example I have the loadClip loading your swf into a movieClip called
someClip. That is some clip that you have made to receive the content, maybe
using createEmptyMovieClip or some other way.

Anyways, so what does this code do? Well the MovieClipLoader class is
explained in the help files, so read that. But then we create an object just to
put our stuff in a nice place. We add a handler function that will get called
when the MovieClipLoader throws an onLoadInit event. This is the event that
happens when the clip is fully loaded and ready to go.

Next we tell the MovieClipLoader that it should announce its events to the
listener object. And we are all ready to wait until the b5 button is pressed.
On the release of that button we tell the MovieClipLoader instance to load an
external file into some movieclip.

So the loading starts and when the clip has finished loading the
MovieClipLoader announces to its listeners that the onLoadInit event has
happened. There are other events as described in the help files. And they have
all been announced, for example the onLoadProgress event was announced
everytime there was some progress in the loading. But since there was no
handler the event announcement fell on deaf ears as it were.

Anyways since the listening object has an onLoadInit event handler defined the
function executes and tells the target (the clip that the content was loaded
into) that it should goto and play the "Contact" label.

Makes sense? If you have any questions post back.
dtodab - 22 Jul 2008 14:23 GMT
thanks for taking the time to provide a detailed explanation of the preferred method.
much appreciated.
Rothrock - 23 Jul 2008 00:33 GMT
Sure. Sorry if I was grumpy. I know you are just learning, but what sources are
still encouranging people to use loadMovie? I think I need to make it my
mission to get people off loadMovie!

Some how we have to figure out a way that people get introduced to the
MovieClipLoader first and don't meet loadMovie until they already know MCL!
Anyways, good luck and let me know if you need anything else!
JCaroon - 30 Jul 2008 17:57 GMT
Hi Rothrock.

I am trying to something similar to the other person you helped.  I'm very new
to AS and I have a problem.

I am using this code from a tutorial.

_root.currMovie = "homenav";
container.loadMovie(_root.currMovie+".swf");

I want to go to a specific frame in the homenav.swf.  I realize that it needs
to be loaded but I dont know then next step.

Thanks,
Josh
Rothrock - 30 Jul 2008 19:40 GMT
The code is almost exactly the same as given above. Just take the loadClip call
out of the button event handler and change the name of the swf that you are
loading to the name of your file.

Also in the loadInit event handler you will go to the frame you want to go to.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.