Anriëtte Myburgh
Anriëtte Myburgh

Reputation: 13527

Flash = Preload movie

Ok, so this might seem like a stupid question, please try and see my predicament (at least that's what I tell myself):

I have a flash, which loads button with Actionscript 2.0. Now, my swf is no longer than 1 frame, and in my Actionscript, I refer a lot to _root.

Is there a way I can preload my movie without interfering with the _root references. Because I tried doing an onEnterFrame trace of the movie like this:

_root.onEnterFrame = function() {
   trace(this.getBytesLoaded());
}

But this does not trace anything until the movie is loaded completely.

Any help would be much appreciated.

Upvotes: 0

Views: 323

Answers (2)

sthg
sthg

Reputation: 1135

The easiest way to do, is to split your flash into two frames.

  • On frame one, put the scrict minimum to display while loading.
  • Create an empty movieclip on frame one. Place this code on the mc:

onClipEvent(enterFrame){ if (_root.getBytesLoaded() >= _root.getBytesTotal()){ gotoAndStop(2); }

  • On frame two, put all the rest of your original code and assets.
  • In your library, un-check "Export in first frame" on items with linkage. Place all of these on the stage, on frame two, in an area invisible to the user. This will force the player to preload them.

This technique has saved me from the same trouble many times before. Good luck.

Upvotes: 1

Jotham
Jotham

Reputation: 1152

I would suggest checking out the _lockroot function.

It can be found documented in the Flash help here:

Learning Actionscript 2.0 in Adobe Flash -> Best Practices and Coding Conventions for ActionScript 2.0 -> ActionScript coding conventions -> Handling scope -> Using _lockroot I hope this helps

Upvotes: 1

Related Questions