AS3 Preloader matching stage.stageWidth (simple)

Hello,
Experimenting with Flash as usual.
Preloader's are always something that have caused me trouble.
Here's what I typically use for a timeline based preloader in AS3:
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
loadBar.scaleX = loaded/total;
loaderText.text = Math.floor((loaded/total)*100)+ "%"; (if percentage text is wanted)
if (total == loaded) {
gotoAndPlay(3);
this.removeEventListener(Event.ENTER_FRAME, loading);
This works perfectly well, but isn't that pleasing aesthetically.
I'm really interested in a preloader that loads right across the stage however - regardless of if the stage is resized.
I should imagine it'll involve implementing = Math.round(stage.stageWidth); at some point?
If anybody knows how this is achieved, through actionscript, in the timeline, I'd really appreciate the support
Thanks a lot!

I haven't been able to make this work straight away with this code:
var lbW:Number
var stageW:Number
var ratioNum:Number
resizeF(null);
stage.addEventListener(Event.RESIZE,resizeF);
function resizeF(e:Event){
lbW = loadBar.width
stageW = stage.stageWidth
ratioNum = stageW/lbW;
this.addEventListener(Event.ENTER_FRAME, loading);
function loading(e:Event):void {
var total:Number = this.stage.loaderInfo.bytesTotal;
var loaded:Number = this.stage.loaderInfo.bytesLoaded;
loadBar.scaleX = ratioNum*loaded/total;
if (total == loaded) {
gotoAndPlay(2);
this.removeEventListener(Event.ENTER_FRAME, loading);
But I shall explore and try and fix it.
Thanks so much for your time and expertise!
Really do appreciate it!

Similar Messages

  • HELP - Add a skip intro btn to AS3 preloader

    Hello, I'm a bit of a newbie to AS3 and new some help!
    I've created a preloader.swf that (when loaded) loads an external swf. I would also like to add a skip intro btn, but when I do, the preloader seems to loop over and over (blinking - I know, high tech).
    This is the preloader code. I have it in the first frame of the preloader.swf:
    stop();
    var myRequest:URLRequest = new URLRequest("flash/index.swf");
    var myLoader:Loader = new Loader();
    myLoader.load(myRequest);
    myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);
    var myPreloader:Preloader = new Preloader();
    function showPreloader(event:Event):void {
        addChild(myPreloader);
        myPreloader.x = stage.stageWidth/2;
        myPreloader.y = stage.stageHeight/2;
    function showProgress(event:ProgressEvent):void {
        var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
        myPreloader.loading_txt.text = "Loading - " + Math.round(percentLoaded * 100) + "%";
        myPreloader.bar_mc.width = 198 * percentLoaded;
    function showContent(event:Event):void {
        removeChild(myPreloader);
        addChild(myLoader);
    On it's own, it works fine.
    Then I added a MC with the instance name "skipIntro", and then added this script to the script above:
    skipIntro.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_2);
    function fl_ClickToGoToWebPage_2(event:MouseEvent):void
        navigateToURL(new URLRequest("/residences/residences.php"), "_blank");
    Any help? Thanks.

    There doesn't appear to be anything wrong with the code.  Does it start behaving correctly again if you comment out that code?  Do you get any error messages?  The behavior you describe (looping/blinking) is indicative of an unhappy processor.

  • As3 preloader problem - Captivate5

    Hello all,
    Been searching around for this for a bit in a the forums and cant find anything on it here goes:
    I have a project that i built with a ToC for my company.  And i have a as3 preloader as well.
    Problem:
    Preloader is fine and centered in the middle of my project with out a ToC but when i add the Toc the preloader will not center in my project i have tried to alter it in the html file insterting <center> tags and such and also externalizing the skin or FMR SWF also removing and placing it back in and not getting a fix for it. I realize this maybe a simple fix but i cant find anything in the forums here discribing exactly this issue.
    can anyone help
    thanx
    bobby

    Hi,
    Going out on a stretch here but did you, by any chance, added external swf or widgets that would have set the values of either Stage.scaleMode or Stage.align. That could explain the effects you are seeing.
    Whyves
    www.flash-factor.com

  • Stage.stageWidth in Percent not Pixels

    Hi All,
    I am trying to set masks and other component positions in relation to Stage size.
    AS3 CS5
    I trace stage.stageWidth on a 800x600 pixel stage and I get - 100
    My stage will scale within a Director piece.
    Is this a bug? Modal condition? Releated to scaling??
    Thanks,
    Jim

    Now this is interesting.
    stop();
    trace ("The Stage width is " + root.stage.stageWidth);
    trace ("The Stage height is " + this.stage.stageHeight);
    var temp:Number = new Number();
    temp = stage.width;
    trace(temp);
    The first time I run the swf-compile (ctrl-Enter) - It Output the following:
    Page1 is now loaded
    The Stage width is 100
    The Stage height is 100
    0
    While the SWF is still selected (being viewed) I hit ctrl-Enter again and I get this add to it:
    Page1 is now loaded
    The Stage width is 1874
    The Stage height is 763
    0
    This is the size of my stage window in the FLA development window.
    I drag it out of the projects bar to be an independent window and it gives me what I expected:
    Page1 is now loaded
    The Stage width is 800
    The Stage height is 600
    0
    Note I can make the window any size and I get the same right -expected - answer, except when it overlaps other Flash dev. window objects or a display border.
    food for thought,
    Jim

  • Acessing root stage.stageWidth

    Hi,
    So I'm trying to do a simple graph with rollover definitions. I have the graph on one layer in the root along with the definitions. On a hit testing MC I have the following:
    var defbox:info = new info();
    var mcName  = this.name;
    var xPos =  (MovieClip(parent).stage.stageWidth)/2;
    var yPos =  (MovieClip(parent).stage.stageHeight)/2;
    this.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
    function mouse_over(event:MouseEvent):void {
         this.removeEventListener(MouseEvent.MOUSE_OVER, mouse_over);
         this.addEventListener(MouseEvent.MOUSE_OUT, mouse_out);
         this.addChild(defbox);
         defbox.x = xPos-350;
         defbox.y = yPos-350;
         defbox.alpha = .95;
         defbox.title.title.text = MovieClip(parent).titles[mcName];
         defbox.def.text = MovieClip(parent).definitions[mcName];
         defbox.def.autoSize = "center";
         defbox.body.height = defbox.def.height + 25;
         defbox.title.y = defbox.body.y -8;
    function mouse_out(event:MouseEvent):void {
         this.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
         this.removeEventListener(MouseEvent.MOUSE_OUT, mouse_out);
         this.removeChild(defbox);
    The problem is that the loaded MC namely, defbox is does not appear at stage.width/2 (or height). It appears to be loading somewhere relative to the hit tester (the mc where the defbox mc is being loaded). I can't seem to access the root stage. I'm pretty sure that all the MCs registry points are normal. Any suggestions? Thanks.

    use:var defbox:info = new info();
    var mcName  = this.name;
    var pt:Point = new Point(stage.stageWidth)/2,stage.stageHeight)/2);
    var newpt:Point = this.globalToLocal(pt);
    defbox.x=newpt.x;
    defbox.y=newpt.y;
    this.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
    function mouse_over(event:MouseEvent):void {
         this.removeEventListener(MouseEvent.MOUSE_OVER, mouse_over);
         this.addEventListener(MouseEvent.MOUSE_OUT, mouse_out);
         this.addChild(defbox);
         defbox.x = xPos-350;
         defbox.y = yPos-350;
         defbox.alpha = .95;
         defbox.title.title.text = MovieClip(parent).titles[mcName];
         defbox.def.text = MovieClip(parent).definitions[mcName];
         defbox.def.autoSize = "center";
         defbox.body.height = defbox.def.height + 25;
         defbox.title.y = defbox.body.y -8;
    function mouse_out(event:MouseEvent):void {
         this.addEventListener(MouseEvent.MOUSE_OVER, mouse_over);
         this.removeEventListener(MouseEvent.MOUSE_OUT, mouse_out);
         this.removeChild(defbox);
    The problem is that the loaded MC namely, defbox is does not appear at stage.width/2 (or height). It appears to be loading somewhere relative to the hit tester (the mc where the defbox mc is being loaded). I can't seem to access the root stage. I'm pretty sure that all the MCs registry points are normal. Any suggestions? Thanks.

  • Cannot access Stage.stageWidth

    with this:
    trace(Stage.stageWidth)
    i get this error:
    1119: Access of possibly undefined property stageWidth
    through a reference with static type Class.

    the stage class is accessible through any object on the
    stage.
    say you have a movieclip on the stage named myMC. Then
    accessing stage width is done like this...
    MovieClip(myMC).stage.stageWidth;
    In AS3, Flash no longer cares about the depth of loaded
    movies. There is only one stage in AS3 so accessing the stage from
    an external movie loaded in is the same as accessing a movie clip
    you place on the stage from your library.

  • Viewing Flash Applications on a Mac: stage.stageWidth/stage.stageHeight Return 0 in Firefox/IE

    I am using SWFOBJECT to embed my flash content.
    I have been worried about stage.stageWidth and stage.stageHeight returning 0 in Firefox/Internet Explorer; this problem is referred to in question #21 on the SWFOBJECT FAQ (http://code.google.com/p/swfobject/wiki/faq).
    I have been told that this problem is particularly prevelant on Macs.
    The SWFOBJECT FAQ (question 21) indirectly suggests that this problem does not occur with static publishing.  Is this correct?  Is it still advisable to implement a solution to this stageWidth/stageHeight problem, even if you are using static publishing?
    Thank you.

    Bug 3637793
    https://bugbase.adobe.com/index.cfm?event=bug&id=3637793

  • On Firefox stage.stageWidth stage.stageHeight return wrong values

    Hello,
    I have a problem on firefox windows 8, stage.stageWidth and stage.stageHeight return wrong values,
    swfobject.embedSWF("mySwf.swf", "mySwf", "500", "500", "14.0.0","expressInstall.swf", flashvars, params, attributes);
    on ie, Chrome stage.stageWidth and stage.stageHeight return 500
    on iFirefox stage.stageWidth and stage.stageHeight return 750 and my animation is smaller (66%)
    Thanks

    In order to target iPhone 5 you need to use AIR 3.5 beta or AIR 3.4
    pointing to iOS 6 SDK. Be sure to include the [email protected] to
    trigger the iPhone 5 size. In other words, the app has to be built
    targeting the iOS 6 SDK and have the new default png to trigger the full
    size on the iPhone 5.
    AIR 3.5 beta includes the bits that to target iOS 6 SDK, but you can
    target iOS 6 with AIR 3.4 by using the external SDK path in the package
    ANE prompt in FB 4.6
    http://labs.adobe.com
    iBrent

  • Stage.stageWidth and some browsers

    Has anyone else encountered this? When I program banner ads, I use a variable to calculate the center of the banner, something like:
    var MiddleX = stage.stageWidth/2; //If stage is 300 pixels wide MiddleX would be 150
    I then use that variable to position text dead center, something like:
    mcText.x = MiddleX;
    What I have discovered is that some browsers don't care for this. So instead of centering the text they position it at 0. The quick fix was to just put in a number rather than have it calculate.
    I don't think the code is flawed. Just wondering why some browsers hiccup on this code. It seems pretty basic.

    there could be some issues with scaling unless you assign the scaleMode to noScale.

  • Cs4 as3 preloader

    Hi,
    Is there a surestarter preloader in AS3 with CS4? Meaning here, showing a progress bar or percentage value before loading the main swf, right away at the start of the  loading.
    I tried 3 different versions:
    1- I used the code from a video (and accompanying files), and simply changed the content.swf to my own swf file (rename my swf content.swf), so that the original code would load my swf instead of the original content.swf. (original content.swf was too small to see anything before loading, because my loading speed is too fast).
    Here is the code from the original preloader (loads a small swf which then loads the main swf file):
    var l:Loader = new Loader();
    l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
    l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
    l.load(new URLRequest("content.swf"));
    function loop(e:ProgressEvent):void
    var perc:Number = e.bytesLoaded / e.bytesTotal;
    percent.text = Math.ceil(perc*100).toString();
    function done(e:Event):void
    removeChildAt(0);
    percent = null;
    addChild(l);
    and here is the link to the file:
    http://www.raidcanada.com/preloader-org-test.html
    2- used the code suggested, which does the preloading directly in the main swf file:
    stop(); 
    //Import the required assets
    import flash.display.*;
    //Stop the playhead while loading occurs
    this.stop();
    //Create a listener to call the loading function as the movie loads
    this.loaderInfo.addEventListener (ProgressEvent.PROGRESS, PL_LOADING);
    /*This is the main function, basically it grabs the total and loaded bytes,
    calculates a percentage, and displays it by stretching the bar and adjusting
    the textfield display. If your bar/textbox instancenames are NOT lbar/lpc,
    you'll need to adjust this code to match your instance names*/
    function PL_LOADING(event:ProgressEvent):void {
    var pcent:Number=event.bytesLoaded/event.bytesTotal*100;
    //Stretch the bar
    lbar.scaleX=pcent/100;
    //Display the % loaded in textfield
    lpc.text=int(pcent)+"%";
    //If the movie is fully loaded, kick to the next frame on the main timeline
    //You may wish to change the gotoAndStop(2) to a gotoAndPlay(2)
    if(pcent==100){
    this.gotoAndPlay(2);
    This one doesn't work either, and if you refresh the page, you get only the bar, instead of refreshing the main swf.
    http://www.raidcanada.com/test/test-2.html
    3- use the code suggested to replace the preceding version:
    stop();
    addEventListener(Event.ENTER_FRAME,checkLoad);
    function checkLoad(e:Event):void {
    var pcent:Number=this.loaderInfo.bytesLoaded /this.loaderInfo.bytesTotal*100;
    lbar.scaleX=pcent/100;
    lpc.text=int(pcent)+"%";
    if (pcent==100) {
    removeEventListener(Event.ENTER_FRAME,checkLoad);
    this.gotoAndPlay(2);
    This one loads correctly (without the percentage or progress bar) and the refresh is OK.
    http://www.raidcanada.com/test/test-1.html
    The idea is to have this page load correctly showing a percentage sign and a progress bar until the loading is complete for this page:
    http://www.raidcanada.com/entete-multi-hiver-1-test.html
    Every time I test the swf directly in Flash CS4 with the simulated download, I get the progress bar and percentage correctly.
    I also tried with Firefox and get the same results.
    FLAs are at:
    http://www.raidcanada.com/test/test-1.fla
    http://www.raidcanada.com/test/test-2.fla
    and screenshots of FLASH (showing the progress bar in "test movie" with simulated download):
    http://www.raidcanada.com/test/screenshot-test-1.jpg
    http://www.raidcanada.com/test/screenshot-test-2.jpg
    Am I missing something?
    THank you in advance

    Hi,
    I am using Internet Explorer 8, version 8.0.7600.16385 with Windows 7 Ultimate or Firefox 3 version 3.5.9
    If I flush the cache and load the page:
    http://www.raidcanada.com/entete-multi-hiver-1-test.html
    It takes about 5 seconds with a blank screen before I get the main swf displayed.
    If I load the page: http://www.raidcanada.com/test/test-1.html
    It takes about 1 second with a blank screen before I get the main swf displayed. The main swf file is much smaller.
    I also did a lot of tests, and still the same problem. Temporarely, on the production site, I ended up installing a static Image saying "Loading", without the code, which then loads the large swf. But some customers are seeing the "Loading" for 14 sec to 24 seconds, depending of the swf file.
    I know the code suggested is probably working with CS3 and AS2, but I need to make it work with CS4 and AS3, because my other code is all in AS3, built with CS4. As I said before, if I make a simulation, the simulation is perfect.
    Thanks

  • Flash CS5 AS3 Preloader Issues

    Hi.
    I'm a complete novice with Flash and at risk at looking like 'Dumbest Poster of the Year', I'm requesting help/advic over a couple of issues.
    My first concern is with a very simple preloader I've made for a movie. Here is the code (posted in first frame of movie; nothing else is in the frame except for the preloader itself):
    import flash.events.Event;
    stop();
    addEventListener(Event.ENTER_FRAME, loaderF);
    function loaderF(e:Event):void{
    var toLoad:Number = loaderInfo.bytesTotal;
    var loaded:Number = loaderInfo.bytesLoaded;
    var total:Number = loaded/toLoad;
    if(loaded == toLoad) {
      removeEventListener(Event.ENTER_FRAME, loaderF);
      gotoAndPlay(2);
    } else {
      PreLoader.PreLoaderFill.scaleX = total;
      PreLoader.PercentLoaded.text = Math.floor(total*100) + "%";
    When I simulate a download, the preloader works fine in all the settings except for 'T1'. On this setting, the movie loads to about 20% then the preloader stops, the movie begins and I receive the following error message in the output panel:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at FlashFront1_fla::MainTimeline/loaderF() .
    The movie itself plays fine on all settings, including 'T1'. Debug doesn't report any issues on preloader or movie.
    Can anybody give me any idea what the source of the issue is? Should I even be concerned about it givne that the movie plays without a problem?
    My second question relates to the 'Simulate Download' pre-settings in Flash. I know their are people out there still on 56K dial-up, or with 'broadband' running at 500 KBS (in the UK at least), but nevertheless, the download simulation settings seem like they are all geared to internet as it was in 1997 and are hardly reflective of the capacity of modern connections. Why is this?
    My movie is not large (about 320KB). Should I even be bothering with a preloader or am I wasting my time for a small minority audience (much like the web designers who still produce sites for the 12 people in the world still browsing in 800 x 600 res)?
    Thanks for any help/advice.

    Flash movies stream down and finish "loading" when the first frame and content that loads on the first frame is available, though frame 1001 might not be downloaded yet. You would think you'd be kinda safe with frame 2 on a T1, but I think the issue is things aren't updating in the right order  rather than things not really being downloaded. Heck, it could even just be the T1 simulation that's causing problems.
    Debug Movie probably isn't showing issues because it slows the timing enough to make everything ok. You could try trace statements too to see how far the code gets.
    Also, you might try a full scale AS3 loader like this one http://www.republicofcode.com/tutorials/flash/as3loader/
    I've found the Event.COMPLETE listener for the loader like this:
    my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, finishLoading);
    to be pretty accurate so far in regards to content truly being loaded where as previous methods gave false positives for loading.

  • AS3 preloader - code overload

    Is there an easier way to create a custom preloader animation
    in AS3? The
    only information I can find on the web tends to have about
    two pages of code
    with stuff like "packages" and "public/private functions"
    which I've never
    used and unfortunately do not understand. The idea seems
    simple to me [(var
    ratio = (bytesLoaded/bytesTotal)*100) then have a movie clip
    (load_mc) one
    hundred frames long displaying 00-99 respectively for each
    frame. Then find
    some way to call a function that says
    [load_mc.gotoAndStop(ratio);]. I've
    seen AS2 tutorials on this subject and they all kinda follow
    this general
    idea. Why then in AS3 do you need two pages of code for an
    action that
    required 5 or 6 lines of code in a previous version of
    ActionScript (AS2)?
    No..no...sorry that's not my question. **sighs** I just need
    to know if
    there is an easier-to-understand method to creating
    prealoaders in AS3? I'm
    making an intro movie for a new website and the final swiff
    will probably be
    close to 1 MB so I want to display a simple loading animation
    instead of a
    blank screen. Any help is greatly appreciated.

    Yes, AS3 can look very complex, and many times it is. You
    don't need to create packages to use AS3. You can, but you don't
    have to. Writing classes in packages allow you to create libraries
    of reusable code. You can just write code that will work for you in
    a frame script space in a layer of your movie. In many cases, and
    for simple movies, this works just fine.
    To create a preloader animation, you can use the UILoader and
    ProgressBar classes. You can also use the Loader class. Here's an
    example that uses the Loader class:

  • AS3 Preloader (without Flex SDK or Flash CS)

    I use FlashBuilder but not the Flex SDK, just pure Actionscript. I have a swf application that is too long to download, so I would like to display a progressbar while the swf is being downloaded from the host.
    My main class is a Sprite. I tried to add a progressEvent.PROGRESS listener on root.loaderInfo in the constructor of my main Sprite, but then a PROGRESS event is fired only when all the swf is downloaded. Useless.
    On a Flex project, you have a Preloader included in the main Application, that displays a progressBar while the application swf is being downloaded from the server and initializing.
    That's what I want.
    Does someone understand how the Flex Preloader works ?
    Do you know how to do that without Flex SDK ?

    Here is the Preloader class :
    public class Preloader extends MovieClip
      public function Preloader()
        super();
        stop();
        if (root && root.loaderInfo)
        root.loaderInfo.addEventListener(Event.INIT, initHandler, false, 0, true);
      private function initHandler(e:Event):void
        root.loaderInfo.removeEventListener(Event.INIT, initHandler);
        displayProgressBar();
        root.loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
        root.loaderInfo.addEventListener(Event.COMPLETE, completeHandler, false, 0, true);
      private function progressHandler(e:ProgressEvent):void
        displayProgressBar(e.bytesLoaded, e.bytesTotal);
      private function completeHandler(e:Event):void
        root.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
        root.loaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
        removeProgressBar();
        nextFrame();
        var mainClass:Class = Class(getDefinitionByName("MainApplication"));
        if(mainClass)
          var app:Sprite = new mainClass();
          stage.addChild(app);
        stage.removeChild(this);
      private function displayProgressBar(bytesLoaded:int = -1, bytesTotal:int = -1):void
       // add a progressBar and display the progress
      private function removeProgressBar(bytesLoaded:int = -1, bytesTotal:int = -1):void
       // remove the progressBar

  • AS3 PreLoader Troubles

    I have been trying to make my simple animated preloader work and am just about ready to throw in the towell.
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import flash.net.URLRequest;
    myLoader.addEventListener(Event.COMPLETE, onComplete);
    myLoader.addEventListener(ProgressEvent.PROGRESS , onProgress);
    function onProgress(e:ProgressEvent):void
        var pct:Number = e.bytesLoaded / e.bytesTotal;
    function onComplete(e:Event):void
        preloader_mc.X = -1000;
    myLoader.load(new URLRequest("D.swf")); 
    PLEASE HELP!!!!!

    use:
    import flash.events.ProgressEvent;
    import flash.events.Event;
    import flash.net.URLRequest;
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS , onProgress);
    function onProgress(e:ProgressEvent):void
        var pct:Number = e.bytesLoaded / e.bytesTotal;
    function onComplete(e:Event):void
        preloader_mc.X = -1000;
    myLoader.load(new URLRequest("D.swf")); 

  • CS5, AS3 - Preloader

    I've been searching for guides/tutorials, basically any sort of help in making a preloader for a game. Also looked through previous posts on this forum.
    Whenever I have a preloader made without any errors and I click test movie (ctrl-enter), it skips the preloader and goes straight to my game's menuscreen. Fair enough, so I click simulate download, the window turns white, after that it turns grey with 3 or 4 dots blinking, as if it were a preloader, except not mine, after a while it goes into my games menuscreen again, completely bypassing the preloader.
    A walkthrough for a simple preloader (just a percentage going from 0 to 100), some code I can copy-paste, anything to make it work, I've tried all I can think of.
    /beg for help.

    that code's in frame 1 of your main timeline, correct?  if yes, copy the trace output using the following and paste it here:
    stop();
    trace(this.currentFrame,this);
    import flash.events.ProgressEvent;
    import flash.events.Event;
    this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
    this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
    function onLoading(evt:ProgressEvent):void {
        var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
        loadbarText.text = "LOADING: " + (loaded*100).toFixed(0) + "%";
    trace(loadbarText.text);
    function onComplete(event:Event):void {
        this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoading);
        this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
        loadbarText.visible = false;
        gotoAndPlay(2);

Maybe you are looking for