A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: How to get AS3.0 to work AS2.0

  1. #1
    Member
    Join Date
    Jan 2001
    Location
    Tampa, FL
    Posts
    62

    How to get AS3.0 to work AS2.0

    I got this twitter script from Blue_chi.
    it works in Actionscript 3. How do i get this code to work in Actionscript 2?

    var myXMLLoader:URLLoader = new URLLoader();
    myXMLLoader.load(new URLRequest("twitter.php"));
    myXMLLoader.addEventListener(Event.COMPLETE, processXML);

    function processXML(e:Event):void{
    var myXML:XML = new XML(e.target.data);

    tweet_1.text = myXML.status[0].text;
    tweet_2.text = myXML.status[1].text;
    tweet_3.text = myXML.status[2].text;
    1100101010100101

  2. #2
    Member
    Join Date
    Jul 2011
    Posts
    51
    Actionscript Code:
    var xml:XML=new XML();
    xml.ignoreWhite=true;
    xml.onLoad=function(success){
        if(success){
            trace(xml);
        }
    }
    xml.load("twitter.php");



    FFA

  3. #3
    Member
    Join Date
    Jan 2001
    Location
    Tampa, FL
    Posts
    62
    do you still use this line:

    tweet_1.text = myXML.status[0].text;
    1100101010100101

  4. #4
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Dunno, not good with AS3 - however, if you could post a small portion of your XML file?
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  5. #5
    Member
    Join Date
    Jul 2011
    Posts
    51
    Actionscript Code:
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    xml.onLoad = function(success) {
        if (success) {
            var nodes = this.firstChild.childNodes;
            trace(nodes[0].childNodes[0].firstChild);
            trace(nodes[1].childNodes[0].firstChild);
            trace(nodes[2].childNodes[0].firstChild);
        }
    };
    xml.load("twitter.php");

    Code:
    <root>
      <status>
        <text>A</text>
      </status>
      <status>
        <text>B</text>
      </status>
      <status>
        <text>C</text>
      </status>
    </root>
    
    //Output expected:
    A
    B
    C


    FFA

  6. #6
    Member
    Join Date
    Jan 2001
    Location
    Tampa, FL
    Posts
    62
    Thanks for the help. I just don't understand nodes or childnodes.

    Do i label the dynamic text box as something?
    1100101010100101

  7. #7
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    Yes, you have to give it an instance name from the Properties Panel, and then change its text by using this code:

    Code:
    dynamic_txt_instance_name.text = "Text Changed";
    where dynamic_txt_instance_name is the instance name you gave it, and "Text Changed" the text you want to change it to, which can also be:

    Actionscript Code:
    var nodes = this.firstChild.childNodes;
    dynamic_txt_instance_name.text = nodes[0].childNodes[0].firstChild;
    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  8. #8
    Member
    Join Date
    Jan 2001
    Location
    Tampa, FL
    Posts
    62
    NICE!! Thank you. I think i need to dive into some books on code..Im more on the animation side
    1100101010100101

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