PDA

View Full Version

: Flash ActionScript Help Please


Gachinto
08-02-2011, 01:13 AM
Hello everyone. I've been trying to get this working for the past month. I searched as much as I could and everywhere that I could. Please help with my situation.

I'm loading external swf files to a movie container, but I want to show a preloader before it is ready and play. The problem is the preloader get stop prematurely and there is a gap between the preloader stopping and the movie playing.

**************************************************
BUTTON: (note that button is not on _root, but within containers after containers, and it will be extremely difficult to redo all that animation work)
on (rollOver, dragOver) { //as2 on button
gotoAndPlay(2); //animation of the button
_root.PrevCon._visible = false; //make movie container invisible
loadMovie("path here", _root.PrevCon); //load movie to container
_root.PreLoadCon.gotoAndStop(2); //frame 2 of preloader container plays it
}
on (rollOut, dragOut) {
gotoAndStop(1); //animation of the button
unloadMovie(_root.PrevCon); //unload movie from container
_root.PreLoadCon.gotoAndStop(1); //frame 1 of preloader container stops it
}
//this part is irrelevant but i purposely dun load it on release
on (release) {
_root.pro_btn.gotoAndPlay(2);
_root.gotoAndPlay(3);
}
**************************************************
MOVIE CONTAINER: (aka PrevCon)
onClipEvent (enterFrame) { //as2 on movie clip
if (this.getBytesTotal != 0) { //if something is loaded
if (this.getBytesLoaded() == this.getBytesTotal()) { //if it's complete
_root.PreLoadCon.gotoAndStop(1); //preloader animation stops
_root.PrevCon._visible = true; //movie is visible
}
}
}
**************************************************
PRELOADER CONTAINER: (aka PreLoadCon)
No script except stop() on frame 1 and 2 on action layer, and on animation layer frame 1 is clear and frame 2 has self play animation that keeps on looping.
**************************************************

Any help to solve this would be greatly appreciated. It has been many restless nights after work.

Cheers~

Gachinto
08-03-2011, 11:24 AM
Please? :)

c_loke
08-03-2011, 09:27 PM
rather than listening on the enter frame event, why dont you listen on the movie load event/movie ready. once the movie is done loading, then you for sure know the video is ready to play.

Gachinto
08-03-2011, 09:36 PM
rather than listening on the enter frame event, why dont you listen on the movie load event/movie ready. once the movie is done loading, then you for sure know the video is ready to play.

So I should change the function for Movie Container? What should I use to replace the first line?

*****
onClipEvent (enterFrame) {
*****

Gachinto
08-03-2011, 09:40 PM
onClipEvent(load)?

Gachinto
08-03-2011, 10:51 PM
I got it! Thank you so much you're a genius! I was afraid of a huge fix; but 1 word!