Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
BabaBlackSheep

LoaderMax & XMLLoader: error using in external class

Recommended Posts

I am using the following code in FLEX+Eclipse and i get the error "TypeError: Error #2023".

In my xml , i am loading from local folder so i am using

<LoaderMax name="queue1" prependURLs="resources/images/" load="true">

 

Questions:

  1. If I define estimatedBytes at line loader = new XMLLoader ?  will it represent the all data loaded by XML or will it be the estimated size of XML it`s self ?
  2. In my code , loader`s name is "mainQueue".How can i access it in other class so i can retrieve its contents in that class ?
package {
    import flash.display.*;
    import com.greensock.*;
    import com.greensock.loading.*;
    import com.greensock.events.LoaderEvent;
    import com.greensock.loading.display.*;
    public class green {
        protected var queue:LoaderMax;
        protected var loader:XMLLoader;
        public function green() {
            LoaderMax.activate([ImageLoader, SWFLoader, VideoLoader]);
            loader = new XMLLoader("resources/resources.xml", {name:"mainQueue",onComplete:completeHandler, estimatedBytes:50000});
            loader.load();
        }
        protected function progressHandler(event:LoaderEvent):void {
            //trace("progress: " + event.target.progress);
        }
        
        protected function completeHandler(event:LoaderEvent):void {
            var image:ContentDisplay = LoaderMax.getContent("image1");
            TweenLite.to(image, 1, {alpha:1, y:100});
            trace(event.target + " is complete!");
        }
          
        protected function errorHandler(event:LoaderEvent):void {
            trace("error occured with " + event.target + ": " + event.text);
        }
    }
}

XML:

<?xml version="1.0" encoding="iso-8859-1"?>
<data>
    <LoaderMax name="queue1" prependURLs="resources/images/" load="true">
        <ImageLoader url="image1.jpg" name="image1"  />
        <ImageLoader url="image2.jpg" name="image2"  />
        <ImageLoader url="image3.jpg" name="image3"  />
    </LoaderMax>
    <LoaderMax name="queue2" prependURLs="http://www.greensock.com/assets/" load="false">
        <SWFLoader url="swf/child.swf" name="child" autoPlay="false" />
        <VideoLoader url="video/video.flv" name="video" width="400" height="300" scaleMode="stretch" autoPlay="false" />
    </LoaderMax>
</data>
Link to comment
Share on other sites

If I define estimatedBytes at line loader = new XMLLoader ?  will it represent the all data loaded by XML or will it be the estimated size of XML it`s self ?

 

 

From XMLLoader Docs:

 

estimatedBytes : uint - Initially, the loader's bytesTotal is set to the estimatedBytes value (or LoaderMax.defaultEstimatedBytes if one isn't defined). Then, when the XML has been loaded and analyzed enough to determine the size of any dynamic loaders that were found in the XML data (like <ImageLoader> nodes, etc.), it will adjust the bytesTotal accordingly. Setting estimatedBytes is optional, but it provides a way to avoid situations where the progress and bytesTotal values jump around as XMLLoader recognizes nested loaders in the XML and audits their size. The estimatedBytes value should include all nested loaders as well, so if your XML file itself is 500 bytes and you have 3 <ImageLoader> tags with load="true" and each image is about 2000 bytes, your XMLLoader's estimatedBytes should be 6500. The more accurate the value, the more accurate the loaders' overall progress will be.

 

---

 

In my code , loader`s name is "mainQueue".How can i access it in other class so i can retrieve its contents in that class ?

 

 

Did you try LoaderMax.getLoader("mainQueue") http://api.greensock.com/as/com/greensock/loading/LoaderMax.html#getLoader()

 

From the code shown its very difficult to know what is throwing the error TypeError: Error #2023 as there is no description of what or where it is coming from.

 

Does this help: http://jongrant.wordpress.com/2011/11/09/as3-typeerror-error-2023-class-must-inherit-from-sprite-to-link-to-the-root/

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×