Solved

Using a "GetBytesLoaded" type preloader with a loading MC?

Posted on 2001-08-28
9
270 Views
Last Modified: 2012-06-22
Hello,
We have a preloader on our site that uses the "getBytesLoaded" function.  It works great when loading the home page.  However, I would also like to use it when a movie clip is loaded from the home page (the home page is loaded into _level0).  Actually, I would like to use it when a mc (loaded into a target called "subtarget") is loaded from another mc (target = "target"), which is loaded from another mc (target="target1").  I suspect that I am having a problem getting the correct path, again.  I assume that the line that is causing the problem is the one in the preloader scene that checks to see how much of the BytesTotal is loaded.  I have tried the following:

if (_level0.target1.target.subtarget.getBytesLoaded() !=_level.target1.target.subtarget.getBytesTotal()){
    gotoAndPlay(1);
     }

I have also tried:
if (this.getBytesLoaded() != this.getBytesTotal()){
    gotoAndPlay(1);
     }
In both cases, the movie clip will play, but the loading bar in the preloader is not showing the progression of the loading (as it does when we use this preloader on the home page).

Any idea how I write this actionscript to check for the bytesloaded in a loading mc?
Thanks,
Stephen Pintauro


0
Comment
Question by:sjp060497
  • 4
  • 3
  • 2
9 Comments
 
LVL 6

Accepted Solution

by:
Jaymol earned 100 total points
ID: 6431819
Hi.

Try this....

if (_root.target1.target.subtarget.getBytesLoaded() !=_root.target1.target.subtarget.getBytesTotal()){


It's pretty much what you had already, but with "_root" instead of "_level0" which doesn't actually mean anything.

Good luck,

John.
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6433097
sip

see your if condition is wrong

if (_level0.target1.target.subtarget.getBytesLoaded() !=_level.target1.target.subtarget.getBytesTotal())
   

it should be

if (_level0.target1.target.subtarget.getBytesLoaded() !=_level0.target1.target.subtarget.getBytesTotal())

John has given correct answer. User _root or _flash like this

if (_flash.target1.target.subtarget.getBytesLoaded() !=_flash.target1.target.subtarget.getBytesTotal())

Cheers
RootDir
   
   
0
 

Author Comment

by:sjp060497
ID: 6436138
Well, I tried using the following:

if (_root.target1.target.subtarget.getBytesLoaded() !=_root.target1.target.subtarget.getBytesTotal())

The preloader bar loads, but it doesn't show any progress.  It simply loads with the bar "full" and then waits there until the "subtarget" movie clip begins playing.  
Any ideas?
Thanks,
Stephen
0
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 6

Expert Comment

by:Jaymol
ID: 6436165
Realistically, we'd need to see the script for the whole preloading procedure to answer what you are asking now.  Give us more detail and I'm sure we can help you.

John.
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6438811
sjp,

  Why don't you post your movie on net. we will take a look or send your move to rotdir@hotmail.com

Cheers
RootDir
0
 

Author Comment

by:sjp060497
ID: 6440233
Hello rootdir and John,
Thanks for the continued help.  I have a very busy day today, but I will definately post the movie and/or the actionscript I am using by tomorrow.
Thanks again,
Stephen
0
 
LVL 6

Expert Comment

by:Jaymol
ID: 6440235
Okay, ta.  We'll have a look at it then.

John.
0
 

Author Comment

by:sjp060497
ID: 6445086
Hi again,
OK....the script for the whole preloading procedure is as follows:

From the home page (which is at _level0), the user would select a button that would load a movie into a target called "target1".  From this loaded movie, the user would select a button that would load another movie into a target called "target".  From this movie, a user could select another button that would load a movie clip into a target called "subtarget".  I know this is a bad choice of target names.  When we get a chance, we will change them to something more intuitive.  

Anyway, the movie clip that is loaded into "subtarget" contains two scenes.  The first scene in the order is called "Preloader" and the second scene is called "Wiley".  The "preloader" scene contains 3 frames and two layers.  The first (actions layer) contains 3 frames.  The first frame is a blank keyframe.  The second frame contains the following actionscript:

if (_root.target1.target.subtarget.getBytesLoaded() != _root.target1.target.subtarget.getBytesTotal())
     {
     gotoAndPlay (1);
     }

Frame 3 of the actions layer contains the following script:

gotoAndPlay ("Wiley", 1);

The second layer in the "Preloader" scence contains just one keyframe in frame one, containg the preloader bar movie clip.  This is just a colered bar with an action layer as follows:

setProperty (this, _xscale,(_root.getBytesLoaded() / _root.getBytesTotal())*100);

Woops!!!!!
I think I just found the problem.  I changed the path in the earlier script to "_root.target1.target.subtarget", but I did not change the path in the actionscript for the preloader bar graphic above.  This would make sense as to why the bar shows up, but does not show the progress.  The _root movie is already loaded and so the above formula would already be at "100".  
Is that the problem?
Thanks,
Stephen

0
 
LVL 6

Expert Comment

by:Jaymol
ID: 6456208
That could be a proble, yeah. :)

Glad you've got it sorted.

John.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question