A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Event.Open

  1. #1
    Senior Member
    Join Date
    Jun 2007
    Posts
    204

    Event.Open

    Trying to get the bytesTotal upon the beginning of downloading an external. Here's part of the code:

    PHP Code:

    myLoader
    .addEventListener (Event.OPENonOpen);
        

    function 
    onOpen (event:Event):void {
            
        
    trace (event.bytesTotal);
    }; 
    1119: Access of possibly undefined property bytesTotal through a reference with static type flash.events:Event.

    Anyone know what's going wrong and a correction?

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Location
    St. Louis
    Posts
    104
    bytesTotal is not a property of Event, but of the LoaderInfo object on the loader, so you'd need to do:

    myLoader.contentLoaderInfo.bytesTotal

    or

    event.currentTarget.contentLoaderInfo.bytesTotal
    Ben

  3. #3
    Senior Member
    Join Date
    Jun 2007
    Posts
    204
    Using:

    myLoader.contentLoaderInfo.bytesTotal

    Works but returns 0...not the the total bytes of the file??

    I'd prefer to use:

    event.currentTarget.contentLoaderInfo.bytesTotal

    But it's returning error #1069??

  4. #4
    Senior Member
    Join Date
    Apr 2003
    Location
    St. Louis
    Posts
    104
    i believe Event.OPEN broadcasts prior to receiving any data about the file, so you'd probably have to get it from the ProgressEvent.PROGRESS

    myLoader.contentLoaderInfo.addEventListener(Progre ssEvent.PROGRESS, this.fileLoadOpen);

    // and

    function fileLoadOpen(e:Event):void
    {
    trace(e.currentTarget.bytesTotal)
    }
    Ben

  5. #5
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    Event.OPEN is not recommended. It's nice for debugging but IE reacts differently than Firefox, Air and standalone players. IE broadcasts Event.OPEN regardless if the file was found or not while the others will only broadcast it if the file is found.
    Use ProgressEvent.PROGRESS as StunnedGrowth mentioned.

  6. #6
    Senior Member
    Join Date
    Jun 2007
    Posts
    204
    The only dilemma is I only wanted to get the info once...when the download started...is progress the only option?

  7. #7
    Senior Member
    Join Date
    Jun 2007
    Posts
    204
    Still haven't figured it out.

    Here's the goal:

    Have one loading animation track the main timeline download and several xml files. My thought was to create a variable ("total") to hold the total bytes of all the files. Adding to it at the beginning of each download. I'm yet to find a way to accomplish this....help.

    On progress I was planning on adding to a variable ("progress") to track the progress. The loading animation would evaluate the variables "total" and "progress".

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