A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: Preloader : Flash 7 on AS 2

  1. #1
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148

    Preloader : Flash 7 on AS 2

    I got a Preloader with the following action on it -

    It used to work fine with Flash 6 on AS1.

    Now when i try to publish it in Flash 7 on AS 2.

    It does not work. Any idea how to get it working guys ?

    Thanks in advance !


    onClipEvent (enterFrame) {
    loading = _parent.getBytesLoaded();
    total = _parent.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    per = Math.round(percent);
    PP = per+"%";
    loadBar._width = per;
    if (percent>99) {
    _parent.gotoAndPlay(2);
    }
    }
    An eye for an eye makes the whole world blind
    - The Mahatma.

  2. #2
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    Im still using Flash Mx2004. Please can anybody tell me a way to get around this problem
    An eye for an eye makes the whole world blind
    - The Mahatma.

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,875
    try

    Code:
    
    
    stop();

    this.onEnterFrame = function()
    {
    bytesLoaded = _root.getBytesLoaded();
    bytesTotal = _root.getBytesTotal();

    percent = Math.round((bytesLoaded/bytesTotal)*100);

    per = percent+"%";
    loadBar._width = percent;

    if (percent>=100)
    {
    delete this.onEnterFrame;
    gotoAndPlay(2);
    }

    };
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  4. #4
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    Thanks for Replying !

    Let me check if this works !
    An eye for an eye makes the whole world blind
    - The Mahatma.

  5. #5
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    Well Im still not able to get this to work ! Any ideas guys ?
    An eye for an eye makes the whole world blind
    - The Mahatma.

  6. #6
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    Remove the code that you had before and write this code on the first frame of your main timeline:

    PHP Code:
    _root.onEnterFrame=function(){
    var 
    loaded=Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100)
    PP.text loaded+"%";// this line will work if 'PP' textbox is in your main timeline... 
    //...if you have PP texbox inside a movieclip then write...
    //mc_instanceName.PP.text=loaded+"%"
    loadBar._width loaded;// Again, this line will work if loadBar movieclip is in your main timeline...
    //... if you have it inside a movieclip then write...
    //mc_instanceName.loadBar._width = loaded
    if (loaded==100) {
    delete this.onEnterFrame;
    }} 
    Note that, PP has to be the textbox 'instance name' and not a 'var' name

  7. #7
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    I pasted this code -
    =============================
    stop();
    _root.onEnterFrame=function(){
    var loaded=Math.round((_root.getBytesLoaded()/_root.getBytesTotal())*100)
    trace(_root.getBytesLoaded());
    trace(_root.getBytesTotal());
    trace(loaded);
    PreLoader.PP.text = loaded+"%";
    PreLoader.loadBar._width = loaded;
    if (loaded>99) {
    delete this.onEnterFrame;
    //gotoAndPlay(2);
    }}
    ==============================

    Looking at the Traces -

    I can see -

    130871
    130871
    25
    130871
    130871
    25
    130871
    130871
    25
    130871
    130871
    25

    -------------------------------

    So the Bytes Loaded and Bytes Total is the same and hence the code is not working ! Anyway to get over this ?
    An eye for an eye makes the whole world blind
    - The Mahatma.

  8. #8
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    make the condition...
    Code:
    if(_root.getBytesLoaded()==_root.getBytesTotal()){
    gotoAndPlay(2);
    trace("complete")
    delete this.onEnterFrame;
    }

  9. #9
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    No I dont think the Preloader is working.
    Its not updating properly.
    Do you have any Preloader ?
    An eye for an eye makes the whole world blind
    - The Mahatma.

  10. #10
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    Thats really strange. I cant believe that your swf failed to get into that 'IF condition'. Impossible
    Did you upload and check??

    I think it has to be some other kind of silly error which you might have forgotten to notice.

  11. #11
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    ...And btw, is this your 'main' swf or 'child' swf?
    This preloading code will not work on a child swf

  12. #12
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    stop();
    onEnterFrame=function(){
    var a = _root.getBytesLoaded();
    var b = _root.getBytesTotal();
    trace(a);
    trace(b);
    var load = (a/b);
    //trace(_root.getBytesLoaded());
    //trace(_root.getBytesTotal());
    trace(load);
    loaded = Math.round(load*100);
    PreLoader.PP.text = loaded+"%";
    PreLoader.loadBar._width = loaded;
    if (_root.getBytesLoaded() == _root.getBytesTotal()) {
    gotoAndPlay(2);
    trace("complete");
    delete this.onEnterFrame;
    }
    }

    Althoug this works - i think its wrong.

    Coz the trace shows
    trace(_root.getBytesLoaded());853779
    trace(_root.getBytesTotal()); 853779

    at the first instance itself

    Separately if i do - it shows
    (_root.getBytesLoaded()); 130233

    (_root.getBytesTotal()); 853881
    An eye for an eye makes the whole world blind
    - The Mahatma.

  13. #13
    Banned deepakflash's Avatar
    Join Date
    Aug 2007
    Location
    [Object not found]
    Posts
    1,160
    Upload and test your preloader. I cant find anything wrong with the preloader code given to you.

    Btw, this preloading code will not work if you are using it on a child swf. So, is this a 'main' swf or 'child' swf?
    Last edited by deepakflash; 01-14-2009 at 12:03 PM.

  14. #14
    Peace - Just in Heaven koolbabs2000's Avatar
    Join Date
    Nov 2000
    Location
    Somewhere in Time
    Posts
    148
    This is Main swf - so that is not a problem really. Will upload and check it. Thanks a lot for your time and help ! Have fun
    An eye for an eye makes the whole world blind
    - The Mahatma.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center