Flash MX - Loading and controlling movies in the main_mc.

  • andrewmeda
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: London

Post 3+ Months Ago

Hello,

I am very new to actionsripting - been playing round with flash but never delving deeper... until now...

This pup needs some help with the following:-

1. Loading a series of movies at the beginning of the main_mc.

ie: movie_1.swf, movie_2.swf, movie_3.swf, and so on...
(so that the user does not have to wait for each .swf file to load - I would like to load ALL .swf files so they are ready to play immediately after eachother).

2. By using a 'nav bar', which will have 'next movie', 'previous movie' and 'pause', I would like to:-

A. Go to the next .swf file in order (ie. from 1 to 2, form 2 -3 etc...)
B. Go to the previous .swf file in order.
C. Pause the .swf file that is currently playing, and to play when the button is hit again. (pause/play function).

Please help this lost mutt!

Thanks.
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

##-CONTAINER CLIP-##

Create yourself a new empty mc [Insert > Symbol > MovieClip] and give it the name holderClip, press enter.

Next open your stage Library [Ctrl+L], find your empty mc and drag+drop to where you want the top left corner of you externaly loaded mc to be. Give your mc the instance name container.

Next create yourself a button of some sort and place the following code in the actions panel:

PHP Code: [ Select ]
 
on(release) {
 
_root.container.loadMovie("externalMovie.swf");
 
}
 
 
  1.  
  2. on(release) {
  3.  
  4. _root.container.loadMovie("externalMovie.swf");
  5.  
  6. }
  7.  
  8.  


That loads your movie.

If you want to control that external movie from your main movie, reference to is using the following syntax:

PHP Code: [ Select ]
 
_root.container._doSometing;
 
 
  1.  
  2. _root.container._doSometing;
  3.  
  4.  


##-PRELOADER-##

http://www.flashbax.com/flash_preloaders.htm
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Quick comment on that preloader tutorial you posted Enigma.

_framesloaded and _framestotal are Flash 4 and belows way to preload, it's not really that accurate.

In that tutorial it already reads the getBytesLoaded() and getBytesTotal() so it should just use that in the if statement.

Code: [ Select ]
if (loadedBytes == totalBytes){ ... }
  • eurosickwitit
  • Beginner
  • Beginner
  • eurosickwitit
  • Posts: 62

Post 3+ Months Ago

If you're really confused with flash and don't know how to make a preloader go to http://www.kirupa.com. I think it's the best flash resource right now on the web. A lot of useful tips and tricks. That's how i started.
  • andrewmeda
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: London

Post 3+ Months Ago

Hello,
Thanks a lot for your replies so far everyone. Much appreciated...

I have been to kirupa.com - a VERY good resource of stuff - been reading stuff of the site for the past 2 days.

Anyhow, I have a preloader working... ALTHOUGH, I have got it to load the contents of frame 2... but there is no movies in Frame 2, as I haven't loaded anything into the 2nd frame yet... so the pre-loader only has 4kb to load...

Basically, I am trying (desparately) to build an online 'demo' for the company I work for...

So I will explain what I want to happen...

I have the main movie with an empty _content movieclip inserted in frame 2 of the main movie. The pre-loader is on Frame 1.

What I want to do is:-

1. To load 10 different movies from the beginning of the flash file (so there is only 1 pre-loader on the 1st frame of the main movie.
2. To use forward and back arrows to play the movies in order (1-10). I would also like to be able to go either to next or previous movie.
3. When I press the control back/forward buttons, I would like the movies(1-10) to start playing in the _content movieclip in frame 2.

From what I have been reading (and not really understanding) - I may have to create an array in the beginning (which calls/loads all the movies),
then for my nav buttons to call the movies in the array (ie. "movie_1.swf",
"movie_2.swf", and so on....)
For my back and next buttons to work, I think I have to call the movies using -1 (for back), +1 (for forward)...
I would also like to pause the movie that is currently playing using a button.

Please, if anyone can through me some code, with a laymans explanation, you would be very kind indeed.

I love geeking out so please feed this geek puppy!

Cheers,
Andrewmeda
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

You would need to add the preloader to each of your external movies. You could use 1 main preloader, but you need to have a good understanding of preloaders and actionscript before that makes sense.

And your next/back buttons can increment. Like..
Code: [ Select ]
on (release) {
    if (i<=10) {
        container.loadMovie('myMovie_'+i++);
    }
}
  1. on (release) {
  2.     if (i<=10) {
  3.         container.loadMovie('myMovie_'+i++);
  4.     }
  5. }
for your next button or
Code: [ Select ]
on (release) {
    if (i>0) {
        container.loadMovie('myMovie_'+i--);
    }
}
  1. on (release) {
  2.     if (i>0) {
  3.         container.loadMovie('myMovie_'+i--);
  4.     }
  5. }
for your back button.


Make sure the variable i is defined first though. Otherwise you will just get a bunch of undefineds and NaNs (Not a Number). So on a frame you will put
Code: [ Select ]
var i=0;






Note: i++ is the same as i = i+1 and i-- is the same as i = i-1, it just increments and de-increments by 1.
  • eurosickwitit
  • Beginner
  • Beginner
  • eurosickwitit
  • Posts: 62

Post 3+ Months Ago

Wait a minute, you want to preload all 10 right in the beginning?
  • eurosickwitit
  • Beginner
  • Beginner
  • eurosickwitit
  • Posts: 62

Post 3+ Months Ago

From what you said it seems as if you want to load all of them at the same time so that you don't have to preload them later. What i would do is just load the first one and then on each press of the button I'd preload the movie. It's more efficient. You don't know if someone wants to even look at them all, so why not save him some potential time. For the sake of my and your time visit this link http://kirupa.com/developer/actionscrip ... loader.htm
  • Tchuki
  • Mastermind
  • Mastermind
  • Tchuki
  • Posts: 1774
  • Loc: Edinburgh

Post 3+ Months Ago

lostinbeta wrote:
Quick comment on that preloader tutorial you posted Enigma.

_framesloaded and _framestotal are Flash 4 and belows way to preload, it's not really that accurate.

In that tutorial it already reads the getBytesLoaded() and getBytesTotal() so it should just use that in the if statement.

Code: [ Select ]
if (loadedBytes == totalBytes){ ... }


Cool, cheers LIB, I`ll remember that for next time. :D

Posted it as its a pretty easy tutorial to follow. I'll know better for next time though.
  • andrewmeda
  • Novice
  • Novice
  • User avatar
  • Posts: 15
  • Loc: London

Post 3+ Months Ago

Hi, thanks for your reply.

Yep, makes total sense loading each individual movie when user requires it... but for the nature of this project, I need to treat it like chapters in a book.

Each chapter will have little sub sections (small movies).

So, I want all the sub sections to be made available immediately - without them having to load. This will allow the user to flick through each sub section immediately, without waiting for each to load.


So, I want all 10 movies to load in the beginning (the total chapter).

Cheers.
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

So then why not just put everything in one file?

I mean, it's not recommended to do this, but if your plan is to make them load everything even if they aren't going to be looking at everything, then the easiest method would be to put everything in one file and slap a preloader at the beginning of that file.

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 2 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.