mingle_alpha

by hemingway
wip
♥0 | Line 105 | Modified 2012-12-31 12:58:12 | 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/lxfi
 */

package
{
    import flash.display.*;
    import flash.system.*;
    import flash.events.*;
    import flash.utils.*;
    import flash.geom.*;
    import flash.text.*;
    
    [SWF(frameRate = 60, width = 640, height = 1136)]
    public class Main extends Sprite
    {
        public function Main()
        {
            stage.scaleMode = StageScaleMode.SHOW_ALL;
            
            addEventListener(Event.ADDED_TO_STAGE, addedToStage);    
        }
        
        public function _init() :void
        {
            graphics.clear();
            graphics.lineStyle(1, 0, 0.9);
            
            graphics.beginFill(0, 0.125);
            graphics.drawRect(0, 0, 640, 1135);
        }
        
        public function addedToStage($e:Event) :void
        {
            removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
            
            _init();
            
            Buffer.addResource(new Output("Hello World!"));
            Buffer.addResource(new Output("Hello World! #2", 1, 10));
            
            Buffer.buildContext(this);
        }
    }
}

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

class Buffer
{
    public static var resourceContext :Object = null;
    public static var resourceArr :Array = [];
    
    public static function buildContext($context:Object) :void
    {
        resourceContext = $context;
        
        for (var $:Number = 0; $ < resourceArr.length; $++)
            {resourceContext.addChild(resourceArr[$])}
    
        resourceContext.addEventListener(MouseEvent.MOUSE_DOWN, onInteractInit);
    }
    
    public static function addResource($item:Object) :void
    { 
        resourceArr.push($item);
    }
    
    private function onInteractInit($e:MouseEvent) :void
    {
        
    }

    private function onInteractMove($e:MouseEvent) :void
    {
        
    }

    private function onInteractEnd($e:MouseEvent) :void
    {
        
    }
}

class Output extends TextField
{
    private var textFormat :TextFormat;
    
    protected var _content :String;
    protected var _x :Number;
    protected var _y :Number;
    protected var _font :String;
    
    public function Output($content:String, $x:Number = 1, $y:Number = 0, $font:String = "Helvetica")
    {
        addEventListener(Event.ADDED_TO_STAGE, addedToStage);
        
        _content = $content;
        _x = $x;
        _y = $y;
        _font = $font;
        
        multiline = true;
        autoSize = "left";
        selectable = mouseEnabled = false;
        antiAliasType = AntiAliasType.ADVANCED;
    }
    
    public function _init() :void
    {
        text = _content;
        x = _x;
        y = _y;
        
        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(); }
}