flash on 2012-8-6

by hemingway
♥0 | Line 82 | Modified 2012-08-09 08:39:17 | 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/ai7w
 */

package {
    import flash . net     . *;
    import flash . text    . *; 
    import flash . geom    . *;
    import flash . system  . *;
    import flash . events  . *;  
    import flash . display . *;
    import flash . filters . *;
    
    [SWF(width = 640, height = 960, widthPercent = 100, heightPercent = 100, frameRate = 60)]
    public class appMain extends Sprite {
        private var _appStyle : appStyle;
        
        public const DROPSHADOW :uint = 0x000000;
        public const DEVICE_RES :Point = new Point(0, 0); //TODO
        
        public function appMain() {
            stage.scaleMode = StageScaleMode.SHOW_ALL;
            stage.align = StageAlign.TOP;
            
            var _stageData:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight, false, 0xffffffff);
                
                //stage
                
                //////////////////////////////////////////// 
                //    
                //    iOS res :: (640 x 960)
                //   (work on compatibility later: get device res as const)
                //
                //    titleDock     =  640 x (960 * 0.15) 
                //    navDock       =  640 x (960 * 0.85) 
                //    navDock.itemX = (640 / numItems) x (960 * 0.85)
                //
                /////////////////////////////////////////// 
                
                for (var i:int = 4; i < 637; i++)
                {
                    _stageData.setPixel(i, 4, 0x000000);
                }
                
                for (var j:int = 4; j < 957; j++)
                {
                    _stageData.setPixel(4, j, 0x000000);
                }
                
                for (var o:int = 4; o < 637; o++)
                {
                    _stageData.setPixel(o, 956, 0x000000);
                }
                
                for (var k:int = 4; k < 957; k++)
                {
                    _stageData.setPixel(636, k, 0x000000);
                }
                
                //titleDock
                for (var n:int = 4; n < 637; n++)
                {
                    _stageData.setPixel(n, (stage.stageHeight*0.15), 0x000000);
                }

                //navDock[
                //divider
                for (var p:int = 4; p < 637; p++)
                {
                    _stageData.setPixel(p, (stage.stageHeight*0.85), 0x000000);
                }
                
                //items
                for (var l:int = 162; l < (637); l+=(158))
                {
                    for (var _l:int = (stage.stageHeight*0.85); _l < 956; _l++)
                    {
                        _stageData.setPixel(l, _l, 0x000000);
                    }
                }


            var _stage:Bitmap = new Bitmap(_stageData);
            var _lbl01: TextField = new TextField();
            var _lbl02: TextField = new TextField();
            
            _defineLabel(_lbl01, "<titleDock> ... 640 x (960 * 0.15)", 200, (stage.stageHeight*0.07), 18);
            _defineLabel(_lbl02, "<navDock_itemX> ... (640 / 4) x (960 * 0.85)", 200, (stage.stageHeight *0.92), 12);
                   
            addChild(_stage);
            addChild(_lbl01);
            addChild(_lbl02);
        }    
        
        
        public function _defineLabel (objRef :Object , txtVar :String , objX :int , objY :int, fontSize :int = 12,
                                  fontCol :uint = 0x666666 , shadDepth :int = 1, dropShadow :Boolean = true):void
        {
            _appStyle = new appStyle;
        
            objRef.autoSize = TextFieldAutoSize.LEFT;
            objRef.mouseEnabled = false;
            objRef.selectable = false;
            objRef.text = txtVar;
            objRef.x = objX;
            objRef.y = objY;
        
            objRef.setTextFormat(new TextFormat("Arial", fontSize, fontCol));
        
            if (dropShadow == true)
            {
                objRef.filters = [_appStyle._addShadow(shadDepth)];
            }
        }
    }
}


class appStyle {
    import flash . filters . *;
    
    public function _addShadow(sDepth:Number, KO:Boolean = false):DropShadowFilter
    {
        return new DropShadowFilter(sDepth, 45, 0x000000, 1, sDepth, sDepth, .3, 1, KO);
    }

}