A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: AS3 to AS2 Translation ???

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    8

    AS3 to AS2 Translation ???

    Hello All

    I'm adding a twitter feed to an older flash site that use's AS2, the code below works fine in AS3 but I need it translated into AS2 for obvious reasons...

    Can anybody help me with this! I need this translated into AS2 ?? :-/

    Thank you in advance


    Code:
     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;
    }
    Last edited by ***musica***; 01-22-2010 at 09:15 AM.

  2. #2
    I know nothing.
    Join Date
    Feb 2008
    Posts
    315
    Quote Originally Posted by ***musica*** View Post
    Hello All

    I'm adding a twitter feed to an older flash site that use's AS2, the code below works fine in AS3 but I need it translated into AS2 for obvious reasons...

    Can anybody help me with this! I need this translated into AS2 ?? :-/

    Thank you in advance


    Code:
     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;
    }
    PHP Code:
    package
    {
        
    /**********************************************
         * 
         *  This fun Twitter widget is brough to you
         *  by Untold Entertainment Inc, and 
         *  peanut butter!  Peanut butter: a gooey,
         *  yummy snack that might kill you.
         * 
         *  http://www.untoldentertainment.com
         * 
         **********************************************/
     
        // Here are all the goodies you're going to need 
        
    import flash.display.MovieClip;
        
    import flash.events.Event;
        
    import flash.net.URLLoader;
        
    import flash.text.TextField;
        
    import flash.text.TextFieldAutoSize;
        
    import flash.net.URLLoader;
        
    import flash.net.URLRequest;
        
    import flash.events.Event;
     
        public class 
    Main extends MovieClip
        
    {
            private var 
    twitterXML:XML// This holds the xml data
     
            
    public function Main()
            {
                
    // Put your Twitter username here.  For example, ours is "untoldEnt" :
                
    var myTwitterID:String "myTwitterID"
                
    // Put the path to your php script here:
                
    var twitterPHPScriptPath:String "http://www.yourdomain.com/thePathToYourPHPScript";
                
    // Fire the loadTwitterXML method, passing it the url to your Twitter info:
                
    loadTwitterXML(twitterPHPScriptPath "?twitterId=" myTwitterID);
            }
     
            private function 
    loadTwitterXML(URL:String):void
            
    {
                var 
    urlLoader:URLLoader = new URLLoader();
                
    // When all the junk has been pulled in from the url, we'll fire finishedLoadingXML:
                
    urlLoader.addEventListener(Event.COMPLETEfinishLoadingXML);
                
    urlLoader.load(new URLRequest(URL));            
            }
     
            private function 
    finishLoadingXML(e:Event null):void
            
    {
                
    // All the junk has been pulled in from the xml!  Hooray!
                // Remove the eventListener as a bit of housecleaning:
                
    e.target.removeEventListener(Event.COMPLETEfinishLoadingXML);
     
                
    // Populate the xml object with the xml data:
                
    twitterXML = new XML(e.target.data);
                
    showTwitterStatus();
            }
     
            private function 
    showTwitterStatus():void
            
    {
                
    // Uncomment this line if you want to see all the fun stuff Twitter sends you:
                //trace(twitterXML);
     
                // Prep the text field to hold our latest Twitter update:
                
    twitter_txt.wordWrap true;
                
    twitter_txt.autoSize TextFieldAutoSize.LEFT;
     
                
    // Populate the text field with the first element in the status.text nodes:
                
    twitter_txt.htmlText twitterXML.status.text[0];
            }
        }

    And PHP File:

    PHP Code:
    <?php
     
    $twitterId 
    = isset($_REQUEST["twitterId"]) ? $_REQUEST["twitterId"] : '';
    if( 
    $twitterId == "" ){
                    exit;
    }
    $file file_get_contents("http://twitter.com/statuses/user_timeline/" $twitterId  ".xml" );
    echo 
    $file;
     
    ?>

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