Hey Peter,

First probelm I see is this...

In your photo_navigation() method, you do this...

trace("my_xml = " + my_xml);

... immediately after this...

var my_xml = load_xml(xml_file);

When you call the trace() your xml won't have loaded yet and therefore will
not have been returned. I'm guessing that's where you're getting
'undefined'.

Another potential issue you may end up with, again in your
photo_navigation() method, is that you declare your 'my_xml' var within the
method. I think I'm correct in saying that this means the variable is scoped
only to that method - i.e. you won't be able to access it from anywhere
else. To fix it use something like this...

// Contents of photo_navigation.as
class photo_navigation extends xml_loader {
 public var my_xml:XML;

   // constructor
   public function photo_navigation(xml_file:String) {
        // take the xml_file string and pass it to the superclass
"xml_loader"
       my_xml = load_xml(xml_file);

       // trace out the contents of "my_xml"
       trace("my_xml = " + my_xml);
   }
}

Note that the variable is declared (but with no value) in the body of the
'photo_navigation' class and is initialised in the constructor *without* the
var decleration. This way you will be able to access the variable from
anywhere in the class and, since it is declared as public, from anywhere
outside the class too.

Hope this helps.
Adrian P.


On 3/1/06, Peter Burke <[EMAIL PROTECTED]> wrote:
>
> Howdy folks,
>
> Just trying to get my head wrapped around this issue.  In
> photo_navigation.as, I'm trying to get back a return type of XML from
> xml_loader.  But when I attempt this:  "trace("my_xml = " + my_xml);", I
> end
> up getting: "my_xml = undefined".  Somewhere along the line I'm losing the
> my_xml value in xml_loader.as because the value returned is empty.
>
> I've been banging my head against this problem awhile now and need a
> second
> or third opinion...
>
>
>
> // Contents of xml_loader.as:
> class xml_loader extends MovieClip {
>
>     // constructor
>     public function xml_loader() {
>     }
>
>     // public method to load the xml file
>     public function load_xml(xml_file:String) {
>         var myclass = this
>         // Create a local variable that points back to the current object
>         var thisObj:xml_loader = this;
>
>         // Create a local variable, which is used to load the XML file.
>         var my_xml:XML = new XML();
>
>         // Ignore whitespace
>         my_xml.ignoreWhite = true;
>
>         // Upon successful load of the xml file
>         my_xml.onLoad = function(success:Boolean) {
>             if (success) {
>                 thisObj.init(my_xml);
>
>                 // return the my_xml variable value
>                 return my_xml;
>             } else {
>                 trace("error loading XML");
>                 return null;
>             }
>         };
>
>         // Begin loading the XML document.
>         my_xml.load(xml_file);
>     }
>
>     public function init(my_xml):Void {
>         // uncommenting the following line results in the xml being
> printed
> correctly
>         // trace(my_xml);
>     }
> }
>
>
>
> // Contents of photo_navigation.as
> class photo_navigation extends xml_loader {
>
>     // constructor
>     public function photo_navigation(xml_file:String) {
>         // take the xml_file string and pass it to the superclass
> "xml_loader"
>         var my_xml = load_xml(xml_file);
>
>         // trace out the contents of "my_xml"
>         trace("my_xml = " + my_xml);
>     }
> }
>
>
>
> // Contents of photos.xml
> <albums>
>     <album url="album_001/" label="Album 001" index="0">
>         <photo url="photo_001.jpg" label="Photo 001" index="0" />
>     </album>
> </albums>
>
>
> Thanks for any help you can give me!
> _______________________________________________
> Flashcoders@chattyfig.figleaf.com
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com
> http://training.figleaf.com
>
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to