Preloader code

I'm using the code from this tutorial for a preloader.  Though I am not using a dynamic text field like the tutorial says.
I took the line referring to the dynamic text field out of the code, but it's still not working?
The animation has 2 frames with movie clips in each. One for the preloader and one for the main content.
Do I need to put somekind of stop or non-looping code in here so it doesn't go back to frame 1(preloader)??
http://schoolofflash.com/blog/2008/04/flash-cs3-tutorial-actionscript-3-preloader/
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onProgress(e:ProgressEvent):void
    var loaded:Number = e.target.bytesLoaded;
    var total:Number = e.target.bytesTotal;
    var pct:Number = loaded/total;
    loader_mc.scaleX = pct;
function onComplete(e:Event):void
    nextFrame();

You would do well to have stop(); commands in both frames, though I believe nextFrame() includes a stop action in its landing procedure.
You might want to consider an alternative approach for a preloader design.  Here's a link to another tutorial...
http://www.gotoandlearn.com/play?id=85

Similar Messages

  • Preloader Code: Error 1061

    I bought a preloader on Flashden.com and it didn't come with much instruction.
    Here is what I have done:
    My index file has my timeline with actions, preloader, and then my movie clips for my opening page. I have placed my preloader movieclip in frame 1 and it ends on frame 2. In frame one on the actions layer I have stop();
    I then have all of my movie clips on frame 3 with my actions for my movieclips on frame three. I added a name to frame 3 named index
    My preloader movieclip has this code:
    stop();
    this.addEventListener(Event.ENTER_FRAME, loading);
    function loading(evt:Event):void
        var percentageLoaded:Number = Math.round(this.stage.loaderInfo.bytesLoaded/ this.stage.loaderInfo.bytesTotal*100);
         this.loaderInformation.loadingtxt.text = "Loading "+percentageLoaded+"%";
        if(percentageLoaded>=100)
            this.removeEventListener(Event.ENTER_FRAME, loading);
            this.parent.gotoAndPlay("index");
    When I test the file I get a 1061 Error saying Call to a possibly undefined method gotoAndPlay through a refernece with static type flash.disply:DisplayObjectContainer.
    Any ideas on what I can do to correct this? I contacted the person I purchased it from but have not heard back yet.
    Thank you!
    Mariah Danielsen

    Try casting the parent as a MovieClip...
           MovieClip(this.parent).gotoAndPlay("index");

  • Preloader code is not well working in flash8

    hi m using flash8 and for preloader i used script given
    below, It's not works well when i upload my file to net.The problm
    is , it somtimes stoped at 80%, somtime on 70%, somtimes at40% and
    so on,
    onClipEvent (load)
    total = _root.getBytesTotal();
    onClipEvent (enterFrame)
    loaded = _root.getBytesLoaded();
    percent = int(loaded / total * 100);
    gotoAndStop(percent);
    if (loaded == total)
    _root.gotoAndPlay(2);
    } // end if
    i make a movie clip and placed the code on movie clip.
    pls solve this.
    i think it better for mx but not for 8 version.

    Have you tried this tutorial?
    http://www.adobe.com/devnet/flash/articles/preloader.html

  • Preloader code running every time page loads

    Hi everyone,
    I purchased a preloader from Adobe Exchange  for my flash animation. I've noticed though that even though it works, whenever I refresh the page that the swf file is on, or even navigate away and then come back to the same swf page, the preloader starts operating again as if the file was being downloaded for the first time.
    I thought that once a swf was downloaded it didn't need to be done again. The code from the preloader is as follows:
    onClipEvent(load){     
            //show text Loading
            this.text = true;      
            //show reflection
            this.reflection = true;
            //show percents
            this.percents = true;
            //set color
            this.color = "0x003976";
            //set gradient color for reflection
            this.bgColor = "0xffffff";
            //set speed (1-9)
            this.speed = 6;
            //loop infinite, not loading
            this.infinite = false; 
            //loaderTarget (if null self swf preload)
            this.contentTarget = null;             
            //auto stop timeline
            _parent.stop();
    Could it have something to do with the fact that it's an onClipEvent?
    Appreciate any advice.

    I don't know what you have, but if it is an fla file with the preloader you should be able to edit the preloader any way you like, including removing the ending animation.
    I have no familiarity with Adobe Exchange.

  • Preloader code in wordpress template

    I used this code as a preloader on a site a made a few months ago.
    I'm trying to use it again in a wordpress template using PHP and it's not working.
    The movies loads, but doesn't load the main .swf??
    Any ideas why this would work on one site and not another? Is it a PHP conflict?
    var l:Loader = new Loader();
    l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
    l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
    l.load(new URLRequest("ns_headermovie.swf"));
    function loop(e:ProgressEvent):void{
    function done(e:Event):void
        removeChildAt(0);
        addChild(l);

    Hi,
    Why you are using this line
    removeChildAt(0);
    I think to remove preloader.
    I suggest you to use :-
    removeChild(this.getChildByName('PreloaderName"));
    Let me Know how its work

  • Preloader code will not start next frame when finished

    I have this code in frame 1
    "stop();
    //Preloader
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
    function updatePreloader(evtObj:ProgressEvent):void
    //container for the progress of the site (download)
    var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
    preloader_txt.text = percent+"%";
    if (percent==100){
    nextFrame();
    In frame 2 the animation/flash application starts.
    The preloader works fine BUT when it gets to frame 2 it stops. I cannot get it to start. I think it is a simple issue but I cannot see it
    Any help would be appreciated..
    Thanks
    Richard

    use:
    RickRoo wrote:
    I have this code in frame 1
    "stop();
    //Preloader
    loaderInfo.addEventListener(ProgressEvent.PROGRESS, updatePreloader);
    function updatePreloader(evtObj:ProgressEvent):void
    //container for the progress of the site (download)
    var percent:Number = Math.floor((evtObj.bytesLoaded*100)/evtObj.bytesTotal);
    preloader_txt.text = percent+"%";
    if (percent==100){
    play();

  • Website preloader code ?

    Code help please !
    Would anyone be kind enough to share AS3 code for a preloder.
    I need my custom made progress wheel in frame 1 to act as a
    preloader and navigate to frame 2 when the file fully loads.
    Thanks,
    Fred... 

    My website is totally finished but the buttons don't work properly
    on frame 1 unless the entire file is loaded. So I wanted to move everything
    over a frame and put the custom made "progress wheel" movie clip
    I created into frame 1 so it spins until the movie fully loads, then it
    should
    navigate to frame 2 which would now be the main page with the buttons.
    Thank you for taking your time to try and help me.
    Fred Hughes...

  • 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:

  • Preloader Code Help

    I have a preloader on my website that seems to be very
    temperamental, sometimes it works and sometimes it doesn't. I have
    posted the script below, please let me know what I can do to fix
    the main probelm of the load bar freezing at 0%.
    onClipEvent (enterFrame) {
    loading = _root.getBytesLoaded();
    total = _root.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    per = int(percent);
    percentage = per+"%";
    loadBar._width = per;
    if (percent>99) {
    _parent.gotoAndStop(2);
    Thanks

    I have a preloader on my website that seems to be very
    temperamental, sometimes it works and sometimes it doesn't. I have
    posted the script below, please let me know what I can do to fix
    the main probelm of the load bar freezing at 0%.
    onClipEvent (enterFrame) {
    loading = _root.getBytesLoaded();
    total = _root.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    per = int(percent);
    percentage = per+"%";
    loadBar._width = per;
    if (percent>99) {
    _parent.gotoAndStop(2);
    Thanks

  • Flash MX Preloader for external JPGs

    Hey all! Any help would be greatly appreciated. In all
    honesty, I have searched and studied and worked to get this myself,
    which I do alot with code, etc. BUT I am going to admit I'm a "make
    it pretty on the outside" kind of guy, and coding makes my eyeballs
    fall out and well, honestly, I just don't get it. My brain can not
    wrap itself around this. Sigh! So I could use your help a little.
    This is what I'm wanting to do. I have a website,
    www.luxeillustrato.com, and if you go to the portfolio area, and
    click on any of the sections (take fine art for example); it will
    showcase my works by loading external jpg files each time you click
    the forward arrow button.
    You can see I have preloaders on the site, that work fine. My
    main page has a movie target with the instance name of photoM. You
    click "artist", and it loads a new swf file into the photoM target.
    IF you click on "portfolio", "fine art", it loads the fine art swf
    file into photoM, using a preloader. THEN, if you click on the
    forward arrow button, a new jpg image of my work is loaded into the
    fine art movie target with the instance name of just
    photo. As you can see, you have to wait until the jpg image
    loads (and you start to wonder if it's doing anything.)
    The problem is, it is not preloading the external jpgs, it's
    just preloading the fine art swf. My preload code is currently:
    stop();
    onEnterFrame = function () {
    totalBytes = _parent.getBytesTotal();
    loadedBytes = _parent.getBytesLoaded();
    percent = Math.ceil((loadedBytes/totalBytes)*100);
    gotoAndStop(percent);
    info_txt.text = percent+" %";
    if (percent>=100) {
    _parent.gotoAndPlay("inter");
    I already have the preload animation bar created (as you can
    see on the site.) What do I need to do to alter the code above (or
    replace it) in order to have the external jpgs be preloaded as
    well? For example's sake, let's just say I have four jpgs, titled
    "door.jpg", "orange.jpg", "boyfriend.jpg", and "untitled.jpg" (in
    case these are needed for the code. They may not be.)
    I hope this is easy to understand. If NOT, just tell me. I'll
    simplify. And seriously, thanks!

    put a stop() on the first frame of your external swf in an otherwise empty first frame.  when preloading is complete apply a play() to your loader's content cast as a movieclip:
    function contentLoaded(evt:Event):void {
        //Optionally change to a clip holder and set progressbar visibility.
        addChild(contentLoader);
    MovieClip(contentLoader.content).play();

  • Preloader :Error #1009: Cannot access a property or method of a null object reference.

    Hi,
    I'm having a lot of trouble getting a preloader to work on my Flash website. I'm new to actionscript, the site works fine but when I place the preloader in frame 1, I get.
    Error#1009: Cannot access a property or method of a null object reference.
    Then it lists three areas. The buttons on the site don't work anymore.
    I've followed the Lynda com tutorials so don't know what is causing this error.
    Included is the word.doc with the error code, preloader code, the main flash frame 2 code and the debug information.
    Any help would be great.
    Thanks!

    You need to make sure 'cards' is named properly and is present when that line of code executes.  If it is somewhere down a timeline, it is not present.
    As far as your preloader code goes, what is infoLoader.  I have to assume it's some form of component since you don't have any code to instantiate it.

  • Audio problems preloaded Captivate swfs in custom player

    I have a slideshow-like custom Flash player that uses
    standard preloader code - it loads external swf movieclips into a
    holder clip, and stores references to them in an array. Once all
    external swfs are loaded, the first clip starts playing and
    navigation buttons allow the user to go through the "slides" at
    will.
    The problem: some Captivate-generated swf files have audio
    that starts playing as the clips are preloading, and the audio does
    not stop except with a stopAllSounds call. As needed, each loaded
    swf is copied (so to speak) from the array to a clip on the stage,
    loadedClip_mc, to be played and controlled. The player's pause
    button, which works as follows:
    loadedClip_mc.stop()
    has no effect on the sound of the loaded Captivate clips.
    Furthermore, the audio doubles-up when trying to play any
    slide, and clicking play (loadedClip_mc.play() )
    HERE IS THE MOST CONFUSING PART: this ONLY happens when the
    player and the movies to be loaded are uncached - after the files
    are visited for the first time, everything works great. Anytime you
    revisit the player it is fine. However, if it is the first time
    someone is visiting the custom player, or the browser cache is
    cleared, once you visit the page the audio for all Captivates start
    playing during preloading simultaneously and cannot be controlled.
    Thank you in advance for your help!

    Hi. I've experienced the same problem with audio and preload.
    Sorry for my english, but - I dont know if I've understood the
    matter- I think you are talking about to fix this problem using
    actionscript code. Please, would you answer me one question? If I
    can't change the code of the base clip generated by Captivate, is
    it possible to add some code in my loaded clips to stop that audio
    embedded in them when they are preloading? What would this code
    be?.
    I hope you understand me!
    Thank you.

  • Preloader error

    I have a preloader that will externally load my swf however when I run it it is producing this error VerifyError: Error #1014: Class flash.text.engine::FontDescription could not be found. My preloader code works on another swf but not on this one. My code is below. Any help would be apeciated.
    package {
        import flash.display.MovieClip;
        import flash.display.Loader;
        import flash.net.URLRequest;
        import flash.events.Event;
        public class preloader extends MovieClip {
            private var myLoader:Loader;
            private var myRequest:URLRequest;
            public function preloader() {
                myLoader = new Loader();
                myLoader.load(new URLRequest("portfolio.swf"));
                myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult);
            function showLoadResult(evt:Event):void {
                this.addChild(myLoader);

    I saved it on a different pc and now it works woo hoo !!!!! No idea of the problem..

  • JPGencoder and Preloader problem

    Hi guys, I have an swf which allows the user to take a snapshot of the stage, which works fine on its own.
    When I use an external preloader with it i get the error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
              at over/frame1()
    I have tried importing the JPGEncoder into the preloader but still get the same error.
    This is the preloader code:
    [AS]
    import com.adobe.images.JPGEncoder;
    var B:Loader = new Loader();
    B.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
    B.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
    B.load(new URLRequest("someurl.swf"));
    function loop(e:ProgressEvent):void
              var perc:Number = e.bytesLoaded / e.bytesTotal;
              percentText.text = Math.ceil(perc*100).toString();
    function done(e:Event):void
              removeChildAt(0);
              percentText = null;
              addChild(B);
    }[/AS]
    And the JPGEncoder code:
    [AS]
    import com.adobe.images.JPGEncoder;
    //============================================================================
    var matrix:Matrix = new Matrix();
    matrix.translate(stage.width, stage.height);
    snap_btn.addEventListener(MouseEvent.CLICK, snapShot );
    function snapShot( evt:MouseEvent ):void
        displayCapturedBitmapData();
    function getBitmapData( target:DisplayObject ) : BitmapData
    if ( bd )
    bd = null;
    //target.width and target.height can also be replaced with a fixed number.
    var bd : BitmapData = new BitmapData( 920 ,760 , true, 0x00000000);
    bd.draw( stage);
    var jpgEncoder:JPGEncoder = new JPGEncoder(90);
    var byteArray:ByteArray = jpgEncoder.encode(bd);
    var SERVICE_PATH:String = "SERVICEPATH.php";
    var imageFileName:String = "testjpg.jpg";
    // create a URL loader to send the data to the server
    var loader:URLLoader = new URLLoader();
    var url:String = SERVICE_PATH + "?name=" + imageFileName;
    var req:URLRequest = new URLRequest(url);
    // make sure the server knows it is getting an image
    req.requestHeaders =  new Array(new URLRequestHeader("Content-Type", "image/jpeg"));
    loader.dataFormat = URLLoaderDataFormat.BINARY;
    req.contentType = "image/jpeg";
    req.method = URLRequestMethod.POST;
    req.data = byteArray;
    // send the file
    loader.load(req);
    return bd;
    function displayCapturedBitmapData():void
    var bmp:Bitmap = new Bitmap( getBitmapData( stage ) );
    addChild(bmp);
    bmp.x = 695.65;
    bmp.y = 56.76;
    bmp.height = 190;
    bmp.width = 230;
    //==============================================
    [/AS]

    wrap all your code (except your functions and import statement) in an init function and add:
    this.addEventListener(Event.ADDED_TO_STAGE,init);
    your code is difficult to read because it's unformatted, so i'm not sure this is all the code not in a function but your new code should look something like:
    import com.adobe.images.JPGEncoder
    this.addEventListener(Event.ADDED_TO_STAGE,init);
    var matrix:Matrix
    function init(e:Event):void{
    matrix= new Matrix();
    matrix.translate(stage.width, stage.height);
    snap_btn.addEventListener(MouseEvent.CLICK, snapShot );
    p.s.  it looks like you're nesting named functions.  you should unnest them.

  • Preloader Syntax Error

    Need help with ActionScript 2.0 and Player 9. I am trying to
    update my flash pages with Player 9.0 and discovered an
    incompatibility with the preloader code. I keep getting this
    message:
    **Error** Symbol=preloader, layer=background, frame=1, Line
    6: Syntax error.
    _parent.bytes = int(isloaded/1000) add " KB of " add
    int(total/1500) add " KB";
    **Error** Symbol=preloader, layer=background, frame=1, Line
    7: Syntax error.
    _parent.percent = int(p) add "% LOADED";
    Total ActionScript Errors: 2, Reported Errors: 2
    Any help would be greatly appreciated. Thanks!

    With Flash CS3 the "add" operator was removed -- it had been
    depriciated sinc Flash 6 (I think).
    So use "+" instead. Like this:
    _parent.bytes=int(isloaded/1000) + " KB of "+int(total/1500)
    +" KB."

Maybe you are looking for

  • Error while assigning user to a position

    Experts, I m using SRM 3.0 with classic scenario. I would like to assign a user to a position but could not able to eventhough there is BP record. I could able to do the assignment in sandbox but not in the PRD with similar case. Also If I use users_

  • How to move entry from one container to another

    Hi! We are using DBMS_LDAP package to attempt to move an entry from an LDAP container to another container. We have tried modrdn2_s (takes a session, the old dn, the new dn, and a PLS_INTEGER indicating whether or not to delete the old entry; or at l

  • SolMan ChaRM - System landscape not ready yet

    Hi all, We are configuring ChaRM for an implementation use, therefore all the systems are not set up yet. Is it possible in SolMan to define logical component without "real" systems ? We saw that in STMS it was possible to create virtual systems, but

  • Java Script has been blocked, and says missing plugin.

    I have downloaded a bunch of internet browsers to try and fix the issue but the Java has been enabled on all of them and none of them are allowing Java Script 6 or 7 to work. is there soemthing i can do to rectify this problem. or has Java been block

  • How can I retrieve a LONG data type using ADO

    In VB I am using an ADODB object to retrieve data from an Oracle table that has a LONG data type column... specifically: SELECT TRIGGER_BODY FROM USER_TRIGGERS WHERE TRIGGER_NAME = 'MYTRIGGER' I have tried using the GETCHUNK method but it only return