Skip to main content
August 14, 2011
Question

Preloading parent movie clip...

  • August 14, 2011
  • 1 reply
  • 875 views

function loadProgress(e:ProgressEvent):void {

var percent:Number = Math.floor( (MovieClip(parent).bytesLoaded*100)/MovieClip(parent).bytesTotal );

percentMC.percentTxt.text = percent;

}

function loadComplete(e:Event):void {

MovieClip(parent).gotoAndPlay(2);

}

loaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);

loaderInfo.addEventListener(Event.COMPLETE, loadComplete);

in my opinion, the way i have the code written makes perfect sense....but for some reason, the parent MC stays on frame one, and no preloader text is being shown.....is there something i am missing?

i am NOT loading an external SWF  -  however, this method has never given me issue until i migrated off of the root timeline and a little deeper into the timline...

here is the set up (for clearity)....

my root timeline has animations and is the skeleton of this particular swf....

at the end of this timeline is an MC (which we will call MC1)...inside of MC1 is another sequence of animations.....at the end of MC1's timeline is MC2...

inside MC2 is 10 frames....

the first frame has a "Stop" action on it, and another MC (which contains the preloader and the code above)...

on frame 2 of MC2 is the begining of another sequence of animations (which never gets played for some reason....thats where im stuck)...

can anyone shed any light as to why the above code is not functioning at all? no errors nothing....

This topic has been closed for replies.

1 reply

robdillon
Participating Frequently
August 14, 2011

What is loaderInfo? Did you create an instance of loader object someplace? You say that you are not loading an external swf, are you loading in anything? Your loadProgress function's calculation doesn't seem to make any sense. In order for the object that holds this function to call back to the parent object and get that parent object's loading values, that parent object would already have to exist, and be loaded. So there won't actually be any load progress to track, so the function would never run. But then there is no loader object to begin with.

What is it that you really want to accomplish here?

August 14, 2011

this kind of method is used fairly often....

the code is written out the same way its basically always used - with the exception of the "MovieClip(parent)" being implimented....normally you would put "root" - since most often it is the main timeline being loaded....

even if the parent movie clip doesnt have anything to load - this would mean the process (or event) is already complete....with that said, it should be told to gotoAndPlay(2); and it isnt.....it remains on frame 1....which tells me - the preloader doesnt know what its looking for....

all i need to know is how to tell the MC to preload the parent MC - the code i have above should work - but i cant spot the error...

robdillon
Participating Frequently
August 14, 2011

If you are loading one movie clip from another, that loaded clip becomes a child of the clip that loads it. If you want to re-order the clips once they have been loaded, then you can do that. You cannot load a movieClip to be the parent of another, already existing, movieClip.