Groups | Blog | Home
all groups > flash actionscript > september 2004 >

flash actionscript : a couple of loadmovie questions


dresden phoenix
9/30/2004 6:21:49 PM
I may have just painted myself into a corner here, but before I spend hours
experimenting to see how I can get around this I thought I would tap the wisdom
of the Flash experts at this forum.

I have a flash presentation I created a few years ago. I am in the process of
updating and optimizing it. As I had originally devised it I had the whole
presentaiom load at once as one single movie. The updated .swf file is 4x as
big , so I thought I would break up some of the segments and load them into the
main movie using the loadmovie command.

Here is where things get sticky... I never thought I would resort to using
loadmovie, so action script I used to navigate between sections points to the
same instance name, just in different frames. In otherwords, I used different
movies from the main movie library, putting them into different frames but
nameing the instance in which they resided the same in all frames so that I
could have buttons that used exactly the same code throughout the main movie
timeline...

Works fine when all the movies are embedded into one .swf file.

But what I am trying to do now is load the movies into instances from external
..swf files. Seems simple. I am concerned about two things though.

#1. I only have one frame to work with for each part of the presentation, so
what I did is to create a standard prelaoder MC that ( in theory) will load the
corresponding external .swf file into the instance that contains the preloader.
My first question is: is there a way for the preloaded movieclip ( which
resides in instance name "currentportfolio" to continue loading the swf. into
"currentportfolio" so that the .swf file doesn't begging to play until its
fully loaded?)

#2. do the movies remain in memory? for example.. the user clicks to go to the
next part of the presentation...which subsequently loads to instance name
"currentportfolio" , but in a different frame in the main time line... if they
chose to go back to the previews frame,,, which also contains an instance name
""currentportfolio" but had loaded a different .swf file; would that .swf have
to load all over again?

this is to say... when FLASH loads a MC... does it "place it as a library
item" or merely as a temporary instance which is lost once the playhead moves
on and has to be loaded back if the play head is reversed to a previous frame
that would contain the same instance name but with different .swf supposedly
attached to it?
kglad
9/30/2004 7:54:50 PM
your first question doesn't exactly make sense. but you can load a swf and
complete loading before it starts playing. the easiest way to do that is to
put a blank keyframe in frame 1 of the to-be-loaded swf and put a stop() in it.
your preloader code will tigger a currentportfolio.play() statement when
loading is complete.

the answer to ? 2 is yes, your exteral swf will be stored in the browser's
cache and retrieved from there. however, you might want to take some steps to
prevent the momentary appearance of a preloader appearing if you have anything
on-stage as your preload code begins execution.
dresden phoenix
9/30/2004 9:35:09 PM
Kglad, thanks for your answers..

about my first question, the reason why I asked it is because the PRERLOADER
is loading the external .swf file into itself ( that's where I painted myself
into a corner.. I only have one frame to work with.. otherwise I would have to
adjust EVERYTHING, code and layout, in the root movie. So what I am doing is I
have a standard preloader_mc that LOADMOVIEs the external .swf files into its
own instance. Again for example.. the preloader residing in the mc instance
"currentportfolio" will load the "Advertising.swf" INTO " currentportfolio"...
I wanted to make sure that the whole .swf would load before the preloader was
"replaced" in the "current portfolio instance"

and #2 I suppose I could easily adjust the standard preloader to perform a
"if ((framesloaded/totalframes)=1 then gotoAndPlay(mc); that should work ,
right?
kglad
10/1/2004 1:22:50 AM
that's not going to work. the moment you execute
anyMC.loadMovie("yourswf.swf") everything that was anyMC is gone. you won't
have any preload code and you won't do anything other than load your external
swf.

to remedy both issues create a movieclip that contains your preload code and
graphics and whatever else starting on frame 3 of your preloader's timeline.
on frame 1 put or create your target movieclip and your loadMovie() statement.
on frame 2 check to see if it's loaded and if so stop() on that frame 2 so
nothing from your preloader shows on stage, otherwise procede to frame 3 where
your preloader code and dodads show-up on-stage.
AddThis Social Bookmark Button