PDA

View Full Version : Need help with loader/preloader...



Shadowdancer
09-09-2004, 06:49 PM
Hi there, I'm new here.

I just got started with Flash MX 2004, and I have ZERO experience with it prior to Monday.

My first attempt at a project with it has produced a file that is 14.4 MB in length. It's a string of AVI files intersperced with manipulated BMP files, all set to the tune of "Burn" by The Cure...

In case anyone cares, the .SWF file is loaded at: http://www.runescapehaven.com/Shadowdancer/flash/testflash.html

The actual .SWF is at: http://www.runescapehaven.com/Shadowdancer/flash/intro.swf

I need help with a few things:

- How do I get it to load quickly?
- How do I get it to load COMPLETELY before playing (so as not to mis-time the music)
- How do I put a "Skip Intro" button on it and make it work?
- How do I make it spring to the main site page once it's done playing?

Thank you for your time.
- Mike

NTD
09-09-2004, 10:46 PM
Hi,

It sounds as though there are a few methods you need to research. A 14 mb file is extremly large for an intro. One thing you can do is use a base movie and work with the loadMovie method to load the movies as needed instead of all in one file. Some methods to look into.....

loadMovie()
loadMovieNum()

To make the entire movie load before playing, look into a preloader....

Something like this either on a scene above the content or in a movieclip.....
***Preloader***
frame 1


ifFrameLoaded (2) {
gotoAndPlay(2);
}

frame 2


total = int(_root.getBytesTotal());
download = int(_root.getBytesLoaded());
if (total == download) {
_root.gotoAndPlay("gallery");
} else {
play();
}

frame 3


gotoAndPlay(2);


The skip intro button is just coded with a goto action......


on (release) {
_root.gotoAndPlay('frameLabel');
}

same thing with playing the main site when the movie is done.....


_root.gotoAndPlay('frameLabel');


Hope it helps
NTD

Shadowdancer
09-10-2004, 12:33 AM
Hi,

It sounds as though there are a few methods you need to research. A 14 mb file is extremly large for an intro. One thing you can do is use a base movie and work with the loadMovie method to load the movies as needed instead of all in one file. Some methods to look into.....

loadMovie()
loadMovieNum()

To make the entire movie load before playing, look into a preloader....

Something like this either on a scene above the content or in a movieclip.....
***Preloader***
frame 1


ifFrameLoaded (2) {
gotoAndPlay(2);
}

frame 2


total = int(_root.getBytesTotal());
download = int(_root.getBytesLoaded());
if (total == download) {
_root.gotoAndPlay("gallery");
} else {
play();
}

frame 3


gotoAndPlay(2);


The skip intro button is just coded with a goto action......


on (release) {
_root.gotoAndPlay('frameLabel');
}

same thing with playing the main site when the movie is done.....


_root.gotoAndPlay('frameLabel');


Hope it helps
NTD

I tried to load it using a Preloader, but I don't know how to do it at all.

Do I make the preloader a seperate .FLA file or what? I'm NEW, after all...I have no idea what things like "_root.gotoAndPlay('frameLabel');" do or how to implement them. :\

Shadowdancer
09-10-2004, 12:52 AM
It seems that it's a lot of effort to write a Preloader. The tutorials I found aren't clear as to how they work. For example, some say to open a new Movie Clip. Do I do this on the existing file I've made? Or do I open a new one? If so, they don't reference the file I'm trying to preload.

A little explanation would be helpful - or is it simply not worth my time to make a Preloader?

NTD
09-10-2004, 02:05 PM
Hi,

Preloaders are pretty easy to make, however, there are many different ways to make one and there are some things to take into account such as actionscipt exported in the first frame with attachMovie methods. In that situation a normal preloader wont work, but I doubt you have encoutered this as you appear new to actionscripting. The code I posted is a very generic preloader that can be used with any movie. How you set it up is your choice. You can put it in a movieclip or on the main timeline with the content or on a scene above the main content. Flash generally provides more than one way to achieve similar results. This creates a certain flexibility in design because it is up to the developer as to what works best in certain situations. Follow these steps and you will have a preloader than you can use in any movie......

Open a new blank movie. On the first frame of that movie paste this code....


ifFrameLoaded (2) {
gotoAndPlay(2);
}


On the second frame of your new movie paste this code...



total = int(_root.getBytesTotal());
download = int(_root.getBytesLoaded());
if (total == download) {
_root.gotoAndPlay("main");
} else {
play();
}



On the third frame create a loop back to the second frame until the loading is done.......


gotoAndPlay(2);



Insert a new scene below the current scene with the code and insert a few pictures. On the first frame of the new scene, give it a label of "main". Preloaders are a good habit as it keeps the user informed as to what is going on. However, most preloaders will not even be seen if the content loading is small enough.

Now, with that said, one of the main features of Flash is movieclips. They can be considered independent mini flash movies. The code above could be pasted into a movieclip and put on the first frame of a movie. When the content loads, it could send the playhead to the second frame of the movie and do away with multiple scenes altogether. It depends on what meets your needs.

One other thing to mention is informing your user of the progress of the preload. To do that you would need a movieclip on a seperate layer of the preload scene that would update a text field of the percent loaded. You can even use a graphic to scale along with the percent loaded. Here is a demo of a generic preloader........

http://ntdesigns.net/demo/genericPreloader.fla

Hope it helps
NTD

Shadowdancer
09-10-2004, 08:44 PM
I was trying to insert something like the code you posted into my pre-existing movie (I don't understand how to get it to load an external one), but my movie plays right from frame #1.

I wish I could show you how the .FLA file looks. :\

Is it possible to put that code you posted into a new file and have it load my existing .SWF file?

Shadowdancer
09-11-2004, 12:12 AM
By "open a new blank movie" do you mean a new Movie Clip object on the existing .FLA file? :oops:

Shadowdancer
09-11-2004, 12:15 AM
I downloaded that .FLA file. It appears to only have a single layer with NOTHING on it.

:\

NTD
09-11-2004, 12:47 AM
Hi,

The file I posted has two scenes. The first scene is the preloader and the second scene is where the main content would go. You can take the first scene in that movie and copy the frames to any other movie. In the demo, there is not enough content on the main scene for the preloader to be noticed. It will load to quickly. The actionscript is on the first three frames of scene 1. The content would be in scene 2. Select the edit scene button to go to each scene to view or modify it.

Shadowdancer
09-11-2004, 02:12 AM
Hi,

The file I posted has two scenes. The first scene is the preloader and the second scene is where the main content would go. You can take the first scene in that movie and copy the frames to any other movie. In the demo, there is not enough content on the main scene for the preloader to be noticed. It will load to quickly. The actionscript is on the first three frames of scene 1. The content would be in scene 2. Select the edit scene button to go to each scene to view or modify it.

Alright, do I insert a scene into my movie first and then copy the frames over?

Shadowdancer
09-11-2004, 02:20 AM
I think I have an idea how to do it.

How do I insert the Library items into my main file from the one you provided? :\

Shadowdancer
09-11-2004, 02:30 AM
Alright, I did as you said, and managed to insert a new scene in front of my main movie.

I get the animation with "Loading..." but the bar shows 100% and it seems to loop forever without actually playing the movie itself.

What am I doing wrong? :?

NTD
09-11-2004, 02:03 PM
In this part of the preloader code......


total = int(_root.getBytesTotal());
download = int(_root.getBytesLoaded());
if (total == download) {
_root.gotoAndPlay("main");
} else {
play();
}


It is telling the timeline that if total is equal to download to go to a frame labeled "main" and play. You need to put a frame label on the first frame of the main scene following the preloader scene.

Shadowdancer
09-11-2004, 02:26 PM
In this part of the preloader code......


total = int(_root.getBytesTotal());
download = int(_root.getBytesLoaded());
if (total == download) {
_root.gotoAndPlay("main");
} else {
play();
}


It is telling the timeline that if total is equal to download to go to a frame labeled "main" and play. You need to put a frame label on the first frame of the main scene following the preloader scene.

Okay.

I'll try to do that. :shock:

Shadowdancer
09-11-2004, 02:31 PM
:oops:

I looked, I really did. Nowhere in the help file does it tell me how to label a frame. :?

I don't suppose you could enlighten me please? :oops:

Shadowdancer
09-11-2004, 02:37 PM
I got it figured out. However, there's nearly 60 layers to my movie. I labelled frame 1 of the top layer as "main", and when I tested the movie it behaved like the preloader didn't exist. :\

Shadowdancer
09-11-2004, 02:45 PM
I don't understand. It simply does not work.

NTD
09-11-2004, 08:06 PM
Hi,

To put a label on a frame, select the frame, open the properties panel and where it says 'frame'..... insert the label of your choice. Something else you could do if you downloaded the demo file is to replace the content in scene 2 of the demo file with your own content. You could also copy the frames of the preloader into a scene above the content scene you have in your current movie. If you ever create something in one movie that you want to use in another, copying frames from one movie to another will save having to recreate things from scratch. Any objects in the frames will automatically be copied to the library.

Edit**** If there is not enough content, the preloader will load so quickly(especially on broadband), that you will not see it.

Here is a demo of this exact preloader in action........
Demo....

http://ntdesigns.net/Virtual.swf

Shadowdancer
09-11-2004, 08:25 PM
Hi,

To put a label on a frame, select the frame, open the properties panel and where it says 'frame'..... insert the label of your choice. Something else you could do if you downloaded the demo file is to replace the content in scene 2 of the demo file with your own content. You could also copy the frames of the preloader into a scene above the content scene you have in your current movie. If you ever create something in one movie that you want to use in another, copying frames from one movie to another will save having to recreate things from scratch. Any objects in the frames will automatically be copied to the library.

Edit**** If there is not enough content, the preloader will load so quickly(especially on broadband), that you will not see it.

Here is a demo of this exact preloader in action........
Demo....

http://ntdesigns.net/Virtual.swf

Forgive me...

You could also copy the frames of the preloader into a scene above the content scene you have in your current movie.

This is precisely what I have done. But I seem to be having no luck.

Perhaps I could post the .FLA file for you to download and examine, if it's not too much bother? I'd be grateful.

NTD
09-12-2004, 05:46 AM
Hi,

If you save it in MX format and zip it up, I will take a look. If you can make it a demo file without a large amount of content, it would be easier to see any problems.

Shadowdancer
09-12-2004, 10:37 AM
Hi,

If you save it in MX format and zip it up, I will take a look. If you can make it a demo file without a large amount of content, it would be easier to see any problems.

I have no clue how to make it a "demo" file.

I will zip the .FLA file and post it on my site's server for you to examine though, and I'll PM you the link.

Thanks!

Shadowdancer
09-12-2004, 10:50 AM
I ran into a problem uploading the ZIP file - insufficient space.

How do I make it a demo? :\

NTD
09-13-2004, 06:26 AM
Hi,

I will post a better demo in a day or so. Things are kind of busy.

NTD

NTD
09-13-2004, 09:49 PM
Hi,

The generic preloader I posted works fine. I didn't have time to test it until today. To test it, put some pictures in the content scene. The problem with testing preloaders locally is that they load so fast you never see the preloader in action. Try this.......

Select 'control'>>'Debug Movie'

Now, from the top menu, select Debug again and select the 56k modem setting. Now select 'view' .. 'show streaming'

Now press the play button on the debug controller. This will show you the preloader working at dial up speed.

One thing to notice is that the percent text field has white text. If you use a white background, you will need to change the text color.

NTD