Creating a loading screen
Yup. I'm not too good at ActionScript. I've only been at it off and on for a week or so.
I'm working on an animation project, but it's gotten really long and complicated, and a good third of the time I try to test it, it lags horrendously, falls out of sync or just freezes. I already have a play button implemented, but that was only enough for so long. I'm working on making a loading screen now. Here's my code - progressBar_mc just a rectangle I'm using to represent the load progress, and percentageLoaded_text is a dynamic text box that I want to show percentage in.
So all of this is on the first frame, and the second frame has a play button, which works without issue. I want the movie to stop on the first frame until it is totally loaded and then go to the second frame, where the viewer can press the play button. I'm not getting any error messages, but the movie just stops on the first frame and doesn't proceed, the bar doesn't change and the text box remains empty.
import flash.events.Event;
stop();
this.loaderInfo.addEventListener(Event.ENTER_FRAME,loading);
function loading(e:Event) {
var total:Number = root.loaderInfo.bytesTotal;
var loaded:Number = root.loaderInfo.bytesLoaded;
var loadProgress:Number = Math.floor((loaded/total)*100);
var loadProgressTxt:String = loadProgress +"%";
progressBar_mc.scaleX = loaded/total;
percentageLoaded_text.text = loadProgressTxt;
if (total == loaded) {
gotoAndStop(2);
this.loaderInfo.removeEventListener(Event.ENTER_FRAME,loading);
}
}
If there's any more questions or if you need screen shots or anything, I'll get on that.
