Skip to main content
Inspiring
October 8, 2006
Question

MovieClipLoader Class Problem

  • October 8, 2006
  • 7 replies
  • 324 views
Dear all
I have a movie wher in the first frame i need to load a jpeg that will act
like the background of the movie so it take time more than the content and i
decided to load it first to an emptymovieclip on the stage first and if it
is loaded then it will continue playing my movie as the rest of contents
will show.

and here is how i manage things but it is not working so i am waiting for
any suggesstions
i need to show a loader bar while loading this bg and when finish
_root.gotoAndPlay (2);

the code i use is as following providing that i have an empty MC called
"my_mc"on the stage
and there is no loader showing or anything and it loads the pic then stops
and not continue to frame 2.


var myloader:MovieClipLoader=new MovieClipLoader();
myloader.loadClip("bg.jpg",this.my_mc);
var myListener:Object = new Object();
myloader.addListener(myListener);
myListener.onLoadProgress=function(target_mc:MovieClip,bytesLoaded:Number,bytesTotal:Number)
{
this.createEmptyMovieClip("progressBar_mc", 0);
progressBar_mc.createEmptyMovieClip("bar_mc", 1);
progressBar_mc.createEmptyMovieClip("stroke_mc", 2);
with (progressBar_mc.stroke_mc) {
lineStyle(0, 0x000000);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
}
with (progressBar_mc.bar_mc) {
beginFill(0xFF0000, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
endFill();
_xscale = 0;
}
progressBar_mc._x = this.width /2;
progressBar_mc._y = this.height/2;
}
myListener.onLoadStart = function(target_mc:MovieClip) {
progressBar_mc.bar_mc._xscale = 0;
};
myListener.onLoadProgress = function(target_mc:MovieClip,
bytesLoaded:Number, bytesTotal:Number) {
progressBar_mc.bar_mc._xscale = Math.round(bytesLoaded/bytesTotal*100);
if(bytesLoaded == bytesTotal){
this.gotoAndPlay(2);
}

};
myListener.onLoadComplete = function(target_mc:MovieClip) {
progressBar_mc.removeMovieClip();

};




This topic has been closed for replies.

7 replies

kglad
Community Expert
Community Expert
October 11, 2006
you're welcome.
Inspiring
October 10, 2006
Thank you so much it worked and i was wrong

Be Blessed

"kglad" <webforumsuser@macromedia.com> wrote in message
news:egf8uv$no2$1@forums.macromedia.com...
> you can't test onLoadProgress in the flash test environment. have you
> published your swf, uploaded it to a server and tested it online?


kglad
Community Expert
Community Expert
October 10, 2006
you can't test onLoadProgress in the flash test environment. have you published your swf, uploaded it to a server and tested it online?
Inspiring
October 9, 2006
It worked but with one error that is the progress bar doesn't work i mean
nothing is saying there is a loader and its _x and _y are not as written in
the action which is --- mc.progressBar_mc._x = Stage.width/2;
mc.progressBar_mc._y = Stage.height/2;

** So it is loading the picture first and then go to frame 2 but i need to
tell the user that he is waiting for something to load, check this for me
please.
Please Help me

And thank you

"kglad" <webforumsuser@macromedia.com> wrote in message
news:egch0q$eg4$1@forums.macromedia.com...
> does my_mc exist on the timeline that contains that code? (and change
> onLoadComplete to onLoadInit)


kglad
Community Expert
Community Expert
October 9, 2006
does my_mc exist on the timeline that contains that code? (and change onLoadComplete to onLoadInit)
Inspiring
October 8, 2006
it goes automatically to frame 2 without loading anything

Please feel free to tell me any other way to do it coz i am going crazy :)
if u see my way is bad tell me whatever will give the same effect
i need the loading of the bg wait untill it is fully loaded and show it then
goto and play my timeline and it will be wonderfull to make a progress bar
so the user will know he is waiting for something

Thank you Kglad

"kglad" <webforumsuser@macromedia.com> wrote in message
news:egbvvf$r3p$1@forums.macromedia.com...
> there are several problems with that code. try:
>
>
>
> mc=this;
> var myloader:MovieClipLoader = new MovieClipLoader();
> var myListener:Object = new Object();
> myloader.addListener(myListener);
> myListener.onLoadStart = function(target_mc:MovieClip) {
> mc.createEmptyMovieClip("progressBar_mc", 0);
> progressBar_mc.createEmptyMovieClip("bar_mc", 1);
> progressBar_mc.createEmptyMovieClip("stroke_mc", 2);
> with (mc.progressBar_mc.stroke_mc) {
> lineStyle(1, 0x000000);
> moveTo(0, 0);
> lineTo(100, 0);
> lineTo(100, 10);
> lineTo(0, 10);
> lineTo(0, 0);
> }
> with (mc.progressBar_mc.bar_mc) {
> beginFill(0xFF0000, 100);
> moveTo(0, 0);
> lineTo(100, 0);
> lineTo(100, 10);
> lineTo(0, 10);
> lineTo(0, 0);
> endFill();
> _xscale = 0;
> }
> mc.progressBar_mc._x = Stage.width/2;
> mc.progressBar_mc._y = Stage.height/2;
> };
> myListener.onLoadProgress = function(target_mc:MovieClip,
> bytesLoaded:Number,
> bytesTotal:Number) {
> mc.progressBar_mc.bar_mc._xscale =
> Math.round(bytesLoaded/bytesTotal*100);
> };
> myListener.onLoadComplete = function(target_mc:MovieClip) {
> mc.progressBar_mc.removeMovieClip();
> mc.gotoAndPlay(2);
> };
> myloader.loadClip("bg.jpg", mc.my_mc);
>
>


kglad
Community Expert
Community Expert
October 8, 2006
there are several problems with that code. try: