いいね!数

by undo
♥0 | Line 46 | Modified 2011-09-15 17:29:27 | MIT License
play

ActionScript3 source code

/**
 * Copyright undo ( http://wonderfl.net/user/undo )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7igP
 */

package
{
    
    import com.adobe.serialization.json.JSON;
    
    import flash.display.*;
    import flash.events.Event;
    import flash.events.IOErrorEvent;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.text.TextField;
    import flash.text.TextFormat;
    
    [SWF(frameRate=60)]
    public class ASTest extends Sprite
    {
        
        private var _output:TextField;
        
        public function ASTest()
        {
            addEventListener(Event.ADDED_TO_STAGE, init);
        }
        private function init(evt:Event = null):void
        {
            removeEventListener(Event.ADDED_TO_STAGE, init);
            
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            
            _output = new TextField();
            var tf:TextFormat = new TextFormat('_sans', 20);
            _output.defaultTextFormat = tf;
            _output.width = stage.stageWidth;
            _output.height = stage.stageHeight;
            addChild(_output);
            
            var l:URLLoader = new URLLoader();
            var r:URLRequest = new URLRequest('http://graph.facebook.com/http://wonderfl.net/c/7igP/fullscreen'+'?nocache='+new Date().getTime());
            l.addEventListener(Event.COMPLETE, onComp);
            l.addEventListener(IOErrorEvent.IO_ERROR, onError);
            l.load(r);
        }
        private function onComp(evt:Event):void
        {
            var json:Object = JSON.decode(evt.target.data);
            var count:String = (json.shares)?json.shares:'0';
            _output.text = '\n↑のいいね!ボタンを押してリロードしてみ?\n\nこのページのいいね!数\n'+count;
        }
        private function onError(evt:IOErrorEvent):void
        {
            
        }
    }
}