dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: XPath in actinscript 2.0 class

Hybrid View

  1. #1

    XPath in actinscript 2.0 class

    I'm having trouble calling XPath from one of my as2.0 classes. I'm fairly new to as2.0, so I'm sure it's just a problem with my syntax as I'm still getting a handle on scope and such. When I try to use the method XPath, I get the error "There is no method with the name 'XPath'." I guess that means that I can't reference the XPath method from within a method of a class I created, right? What am I doing wrong?

    Here's a simplified example of what I'm trying to accomplish.

    Class code (actionscript)
    PHP Code:
    class AudioData {
        var 
    myXML:XML
        
    var xmlfile:String
        
        
    function AudioData(x:String){ // CONSTRUCTOR
            
    myXML = new XML();
            
    xmlfile x;
            
    loadXMLData(xmlfile// CALL THE METHOD THAT LOADS THE XML DATA
        
    }

        private function 
    loadXMLData():Void{
            
    myXML.load(xmlfile); // LOAD THE XML FILE
            
    myXML.onLoad = function(success){
                if (
    success){
                    
    // HERE'S THE PROBLEMATIC LINE OF CODE!
                    
    var recordset XPath.selectNodes(this,"/Path/To/XML/Node");
                    for (
    n=0n<recordset.lengthn++){    
                        
    trace (recordset[n]) // PRINT TO THE OUTPUT WINDOW
                    
    }
                }
            }
        }

    on frame 1 of my main timeline
    code:
    // Import the XPath classes
    import com.xfactorstudio.xml.xpath.*;
    allData = new AudioData("xmldata.xml");





    -Paul
    - DancingPaul
    www.dancingpaul.com

  2. #2
    I figured it out. I need to pay a little more attention to the output window. seem the problem wasn't that I couldn't refrence the XPath method, but the problem was that I wasn't declaring the variable "n" in my loop.

    XPath is an excellent tool for anybody using flash and XML. if you don't use it already. check it out at http://www.xfactorstudio.com/ActionScript/AS2/XPath/
    - DancingPaul
    www.dancingpaul.com

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