PDA

View Full Version : loading external swfs fade in fade out


atslopes
11-08-2003, 09:49 AM
ok i have a main movie im loading one swf then when i click a button want it that old swf to fade out and the new swf to fade in heres my code also how can i have a loadbar each time i load the external swfs does the loadbar have to be in the external swfs or on the main timeline
or can someone just point me to a tutorial tahnks

for the buton i have--

but.onPress = function () {
_root.createEmptyMovieClip("container", 1);
_root.container.fadeOut = true;
_root.container = "loaded3.swf"
loadMovie("loaded3.swf", "container");
container._x = 130 ;
container._y = 76 ;
}

on a blank frame i have--

but.onPress = function () {
if (fadeOut == true){
if (_alpha > 0){
_alpha -= 5
} else {
_alpha = 0
unloadMovie("loaded3.swf");
loadMovie (who, this)
fadeOut = false //this part to prevent the fadeout/load action from being repeated
}
}
but.onPress = function () {
function (out) {}
if (fadeIn == true){
if (_alpha < 100){
_alpha += 5
} else {
_alpha = 100
fadeIn = false
}

emergency_pants
11-11-2003, 11:54 AM
I knocked this together. Hope it helps.

It outlines a workable structure, using a function, an enterFrame script placed on the container and a button script to start the ball rolling.

You should be able to customise it easily enough and I've annotated the scripts.

I haven't addressed the load bar. I think you could have a "loadbar" movieClip on the main stage. An empty first frame and then a 100 frame status bar animation. Set the frameNumber of this clip to the percent loaded of the loading activeSwf clip.

Check out the Flash help for:
Movieclip._totalframes;
Movieclip._framesloaded;
something like this (not tested):


_root.percentLoaded=(_root.myClip._framesloaded/_root.myClip._totalframes)*100;
_root.loadbar.gotoAndStop(_root.percentLoaded);


replace "myClip" with the _root.activeSwf variable in the example clip.

Good luck with it!

papaan
02-28-2005, 12:42 AM
this thread seems to be useful to me but I am trying to understand how i can use this method to assign to different buttons. I have 30 different buttons calling 30 different .swf files into my main index movie. and trying to fade out the existing while fading in the next movie on top. your example shows only one button that calls 3 different swf files one after another. can you help?

thanks

emergency_pants
02-28-2005, 04:49 PM
have a look at this. It's changed slightly so that the enterframe script is in the main frame script.

The enterFrame() script runs the fade and load sequence.

The button sets the value swfNum

the loadSwf() function uses that swfNum value to load the correct swf.

atslopes
02-28-2005, 06:04 PM
what would be great emergency pants if you could make one with a loadbar or at least post up how to do one. that would make my day. thanks :)

papaan
02-28-2005, 06:08 PM
LOL. yes that would be great. I was thinking of including my preloader (with its own loadbar) into my external swf files and disabling Simon's "loading" messages below left.

But all in all this is a great help and very much appreciated Simon. Thank you!