Skip to main content
Known Participant
August 22, 2010
Answered

please help me

  • August 22, 2010
  • 28 replies
  • 3233 views

I have below code

application.onAppStart = function(){

this.clientStream = Stream.get("clientPlayStream");

var my_xml = new XML("<login><username>qeyd</username><password>nisan</password></login>");

if (my_xml.firstChild.hasChildNodes()) {

    // Use firstChild to iterate through the child nodes of rootNode.

    for (var aNode = my_xml.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {

        if (aNode.nodeType == 1) {

            trace(aNode.nodeName+":\t"+aNode.firstChild.nodeValue);

            this.clientStream.play(aNode.firstChild.nodeValue, 0 , 5 , false);

        }

    }

}

}

I need this application read from exteral xml file not in it. Please help me

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer

    yes with xml everything ok just one problem with line 22

    this.clientStream.play(aNode.firstChild.nodeValue, 0 , 20 , false);


    Oh I got it. You may be calling play inside XML.onLoad = function()

    so in this case this starts pointing to your XML object and not your Application object.

    So define clientStream globallly

    clientStream = Stream.get("clientstream");

    Then when you issue

    clientStream.play("streamname",0,15);

    It should play fine.

    Hope this works.

    Thanks,

    Abhishek

    28 replies

    August 23, 2010

    Hi,

    It will go something like this

    var my_xml  =  new XML();

    my_xml.load("<path to xml file">);

    my_xml.onLoad = function(resObj) {

         if(resObj) {  //xml loaded successfully

                 //your logic here

         }

         else {

                  ///error message

         }

    }

    Hope this answer helps you.

    Thanks,

    Abhishek

    samyahyaAuthor
    Known Participant
    August 23, 2010

    I have tested but nothing. Why it is happening? Can you give me comple code?

    August 23, 2010

    Hi,

    What is the issue that you ran into. Did it give a error.

    To do a simple check

    Place a sample xml file in your application folder, say sample.xml

    In your main.asc

    application.onAppStart = function () {

          

    var my_xml  =  new XML();

    my_xml.load("sample.xml");

    my_xml.onLoad = function(resObj) {

         if(resObj) {  //xml loaded successfully

                 //your logic here

                 trace("xml loaded successfully");

         }

         else {

                  ///error message

                   trace("Sample xml failed to load");

         }

    }

    }

    Unload the app and load it again. Check what is treaced in application.00.log.