In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

read facebook like by graph API

Get Adobe Flash player
by pc1697 12 Oct 2012
    Embed
/**
 * Copyright pc1697 ( http://wonderfl.net/user/pc1697 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/6wsx
 */

package {

    import flash.display.*;
    import flash.events.*;
    import flash.net.*;
    import flash.text.*;
    import flash.xml.*;
    import flash.utils.*;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
           
            inittrace(stage);
    
            var timer:Timer = new Timer(1000 * 60 * 10, 0);
            timer.addEventListener(TimerEvent.TIMER, blah);
            timer.start();

            function blah(e:TimerEvent):void{

                 //trace("Times Fired: " + e.currentTarget.currentCount);
                 //trace("Time Delayed: " + e.currentTarget.delay);
                 
                    var myRequest:URLRequest = new URLRequest("https://graph.facebook.com/hktaobao");
                    var myLoader:URLLoader = new URLLoader();
                    myLoader.addEventListener(Event.COMPLETE, onload);
                    myLoader.load(myRequest);
        
                    function onload(evt:Event):void {
                        var myData:Object = JSON.parse(evt.target.data);  
                        trace(myData.likes);
        
                    }                 

            }
            
        }
    }
}

import com.adobe.serialization.json.JSON;
/////  WONDERFL TRACE /////

// forked from architectural.synthesis's flash on 2012-6-23





// Howto:

// 1. cut and paste everything bellow the "WONDERFL TRACE" line to the end of your script

// 2. insert inittrace(stage); to the constructor of your main class

// 3. done!

import flash.display.Sprite;

import flash.display.Stage;

import flash.text.TextField;

import flash.text.TextFormat;





function inittrace(s:Stage):void

{

    WTrace.initTrace(s);

}



//global trace function

var trace:Function;



//wtreace class

class WTrace

{

        private static var FONT:String = "Fixedsys";

        private static var SIZE:Number = 12;

        private static var TextFields:Array = [];

        private static var trace_stage:Stage;

        

        public static function initTrace(stg:Stage):void

        {

            trace_stage = stg;

            trace = wtrace;

        }

        

        private static function scrollup():void

        {

            // maximum number of lines: 100

            if (TextFields.length > 100) 

            {

                var removeme:TextField = TextFields.shift();

                trace_stage.removeChild(removeme);

                removeme = null;

            }

            for(var x:Number=0;x<TextFields.length;x++)

            {

                (TextFields[x] as TextField).y -= SIZE*1.2;

            }

        }

    

        public static function wtrace(... args):void

        {

        

            var s:String="";

            var tracefield:TextField;

            

            for (var i:int;i < args.length;i++)

            {

                // imitating flash:

                // putting a space between the parameters

                if (i != 0) s+=" ";

                s+=args[i].toString();

            }

            



            tracefield= new TextField();

            tracefield.autoSize = "left";

            tracefield.text = s;

            tracefield.y = trace_stage.stageHeight - 20;



            var tf:TextFormat = new TextFormat(FONT, SIZE);

            tracefield.setTextFormat(tf);

            trace_stage.addChild(tracefield);

            scrollup();                      

            TextFields.push(tracefield);

            

        }

}