flash on 2013-1-25

by hemingway
♥0 | Line 82 | Modified 2013-01-26 01:26:53 | MIT License
play

ActionScript3 source code

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

package
{
    import starling.display.DisplayObject;
    import starling.display.Sprite;
    import starling.events.*;
    
    import flash.display.Stage;
    
    import nape.constraint.*;
    import nape.space.*;
    import nape.geom.*;
    import nape.phys.*;
    import nape.util.*;
    
    [SWF(frameRate = 60, width = 465, height = 465)]
    public class Instance extends Sprite
    {
        private var canvas :BitmapDebug;
        
        public function Instance()
        {

            addEventListener(Event.ADDED_TO_STAGE, addedToStage);
        }
        
        public function _init() :void
        {
            //graphics.clear();
            //graphics.lineStyle(1, 0, 0.75);
            //graphics.drawRect(0, 0, 464, 464);
        }
    
        public function addedToStage($e:Event) :void
        {
            removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
            
            _init();
        }
    }
}

import starling.display.*;
import starling.events.*;

import flash.display.*;
import flash.system.*;
import flash.events.*;
import flash.geom.*;
import flash.text.*;
import flash.net.*;

import nape.constraint.*;
import nape.space.*;
import nape.geom.*;
import nape.phys.*;
import nape.util.*;

class Output extends TextField
{
    private var textFormat :TextFormat;
    
    protected var _x :Number;
    protected var _y :Number;
    protected var _font :String;
    protected var _content :String;
        
    public function Output($content:String, $x:Number = 1, $y:Number = 0, $font:String = "Helvetica")
    {
        addEventListener(Event.ADDED_TO_STAGE, addedToStage);
        
        _x = $x;
        _y = $y;
        _font = $font;
        _content = $content;
        
        selectable = mouseEnabled = false;
        autoSize = TextFieldAutoSize.CENTER;
        antiAliasType = AntiAliasType.ADVANCED;
    }
    
    public function _init() :void
    {
        x = _x;
        y = _y;
        text = _content;
        textFormat = new TextFormat(_font);
        setTextFormat(textFormat);
    }
    
    public function addedToStage($e:Event) :void
    {
       removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
       
       _init(); 
    }
    
    public function get font() :String
    { return _font }
    public function get nWidth() :Number
    { return width }
    
    public function set font($:String) :void
    { _font = $; _init() }
    public function set content($:String) :void
    { _content = $; _init() }
}