├── AIR ├── src │ ├── com │ │ ├── luaye │ │ │ ├── utils │ │ │ │ ├── thread │ │ │ │ │ ├── link.txt │ │ │ │ │ └── Thread.as │ │ │ │ └── bitmapMovieClip │ │ │ │ │ ├── sample │ │ │ │ │ ├── example.fla │ │ │ │ │ └── example.swf │ │ │ │ │ ├── BitmapMovieClipData.as │ │ │ │ │ └── BitmapMovieClip.as │ │ │ └── console │ │ │ │ ├── core │ │ │ │ ├── Log.as │ │ │ │ ├── Logs.as │ │ │ │ ├── MemoryMonitor.as │ │ │ │ ├── Remoting.as │ │ │ │ └── CommandTools.as │ │ │ │ ├── utils │ │ │ │ ├── WeakRef.as │ │ │ │ ├── WeakObject.as │ │ │ │ └── Utils.as │ │ │ │ ├── Ch.as │ │ │ │ └── view │ │ │ │ ├── MemoryPanel.as │ │ │ │ ├── ChannelsPanel.as │ │ │ │ ├── FPSPanel.as │ │ │ │ ├── RollerPanel.as │ │ │ │ ├── Style.as │ │ │ │ ├── Ruler.as │ │ │ │ ├── PanelsManager.as │ │ │ │ ├── GraphingPanel.as │ │ │ │ └── AbstractPanel.as │ │ └── doitflash │ │ │ ├── consts │ │ │ ├── CartUpdateType.as │ │ │ ├── LangDirection.as │ │ │ ├── Orientation.as │ │ │ ├── ScrollConst.as │ │ │ ├── FontStyle.as │ │ │ ├── Direction.as │ │ │ ├── Position.as │ │ │ ├── Youtube.as │ │ │ ├── Ease.as │ │ │ └── Easing.as │ │ │ ├── events │ │ │ └── ListEvent.as │ │ │ ├── tools │ │ │ └── DynamicFunc.as │ │ │ ├── mobileProject │ │ │ └── commonCpuSrc │ │ │ │ └── DeviceInfo.as │ │ │ └── text │ │ │ └── modules │ │ │ ├── MyMovieClip.as │ │ │ ├── MySprite.as │ │ │ └── TextModule.as │ └── Main.as ├── icons │ ├── Assets.car │ ├── icons │ │ ├── icon_144.png │ │ ├── icon_192.png │ │ ├── icon_36.png │ │ ├── icon_48.png │ │ ├── icon_512.png │ │ ├── icon_72.png │ │ ├── icon_96.png │ │ └── icon_1024.png │ └── LaunchScreen.storyboardc │ │ ├── Info.plist │ │ ├── 01J-lp-oVM-view-Ze5-6b-2t3.nib │ │ └── UIViewController-01J-lp-oVM.nib ├── lib │ └── README.md ├── AIR.iml └── Main-app.xml ├── ChangeLog.md └── README.md /AIR/src/com/luaye/utils/thread/link.txt: -------------------------------------------------------------------------------- 1 | http://www.luaye.com/blog/index.php?action=read&id=58 -------------------------------------------------------------------------------- /AIR/icons/Assets.car: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/Assets.car -------------------------------------------------------------------------------- /AIR/icons/icons/icon_144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_144.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_192.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_36.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_36.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_48.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_512.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_72.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_96.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_96.png -------------------------------------------------------------------------------- /AIR/icons/icons/icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/icons/icon_1024.png -------------------------------------------------------------------------------- /AIR/icons/LaunchScreen.storyboardc/Info.plist: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/LaunchScreen.storyboardc/Info.plist -------------------------------------------------------------------------------- /AIR/src/com/luaye/utils/bitmapMovieClip/sample/example.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/src/com/luaye/utils/bitmapMovieClip/sample/example.fla -------------------------------------------------------------------------------- /AIR/src/com/luaye/utils/bitmapMovieClip/sample/example.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/src/com/luaye/utils/bitmapMovieClip/sample/example.swf -------------------------------------------------------------------------------- /AIR/icons/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib -------------------------------------------------------------------------------- /AIR/icons/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/myflashlab/PermissionCheck-ANE/HEAD/AIR/icons/LaunchScreen.storyboardc/UIViewController-01J-lp-oVM.nib -------------------------------------------------------------------------------- /AIR/lib/README.md: -------------------------------------------------------------------------------- 1 | Copy the purchased [permissionCheck.ane](https://www.myflashlabs.com/product/native-access-permission-check-settings-menu-air-native-extension/) here along with the following dependency ANEs: 2 | 3 | 1. androidx_core.ane 4 | 2. overrideAir.ane 5 | 6 | Download dependency ANEs from here: https://github.com/myflashlab/common-dependencies-ANE 7 | -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/CartUpdateType.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | 4 | /** 5 | * ... 6 | * @author Hadi Tavakoli - 8/22/2010 7:08 AM 7 | */ 8 | public class CartUpdateType 9 | { 10 | 11 | public static const QUANTITY_CHANGE:String = "quantityChange"; 12 | public static const ADDED:String = "itemAdded"; 13 | public static const REMOVED:String = "itemRemoved"; 14 | } 15 | 16 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/LangDirection.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | 4 | /** 5 | * LangDirection class indicates the direction of diffrent languages. wether left to right or right to left language script. 6 | * @author Hadi Tavakoli 7 | */ 8 | public class LangDirection 9 | { 10 | /** 11 | * Left to right language script 12 | */ 13 | public static const LTR:String = "ltr"; 14 | 15 | /** 16 | * Right to left language script 17 | */ 18 | public static const RTL:String = "rtl"; 19 | } 20 | 21 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/Orientation.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | /** 4 | * Orientation class indicates different kind of orientation. 5 | * @author Ali Tavakoli 6 | */ 7 | public class Orientation 8 | { 9 | /** 10 | * vertical orientation 11 | */ 12 | public static const VERTICAL:String = "myVertical"; 13 | /** 14 | * horizontal orientation 15 | */ 16 | public static const HORIZONTAL:String = "myHorizontal"; 17 | /** 18 | * indicates whether we need vertical, horizontal or both 19 | */ 20 | public static const AUTO:String = "myAuto"; 21 | } 22 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/ScrollConst.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | /** 4 | * ScrollConst class indicates the scroll consts. 5 | * @author Ali Tavakoli 6 | */ 7 | public class ScrollConst 8 | { 9 | public static const STRONG:String = "strong"; 10 | public static const NORMAL:String = "normal"; 11 | public static const WEAK:String = "weak"; 12 | 13 | /** 14 | * indicates the minimum value(20) that you can set as the mask width 15 | */ 16 | public static const MASK_MIN_WIDTH:Number = 20; 17 | /** 18 | * indicates the minimum value(20) that you can set as the mask height 19 | */ 20 | public static const MASK_MIN_HEIGHT:Number = 20; 21 | } 22 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/utils/bitmapMovieClip/BitmapMovieClipData.as: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Lu Aye Oo | www.luaye.com 3 | * 4 | * BitmapMovieClipData 5 | * 6 | * This is an info class for use with BitmapMovieClip. 7 | * See BitmapMovieClip for details. 8 | * 9 | */ 10 | 11 | package com.luaye.utils.bitmapMovieClip { 12 | 13 | public class BitmapMovieClipData{ 14 | 15 | public var frames:Array; 16 | public var labels:Object; 17 | 18 | public function BitmapMovieClipData(frames:Array,labels:Object = null){ 19 | this.frames = frames; 20 | if(labels){ 21 | this.labels = labels; 22 | }else{ 23 | this.labels = new Object(); 24 | } 25 | } 26 | 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/FontStyle.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | 4 | /** 5 | * FontStyle class includes different font styles. which are either regular, bold, italic or bold-italic 6 | * @author Hadi Tavakoli 7 | */ 8 | public class FontStyle 9 | { 10 | /** 11 | * Regular font type. 12 | */ 13 | public static const REGULAR:String = "regular"; 14 | 15 | /** 16 | * Bold font type. 17 | */ 18 | public static const BOLD:String = "bold"; 19 | 20 | /** 21 | * Italic font type. 22 | */ 23 | public static const ITALIC:String = "italic"; 24 | 25 | /** 26 | * Bold-Italic font type. 27 | */ 28 | public static const BOLD_ITALIC:String = "boldItalic"; 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/Direction.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | 4 | /** 5 | * Direction class indicates the direction of items. 6 | * @author Ali Tavakoli - 3/1/2010 12:27 PM 7 | */ 8 | public class Direction 9 | { 10 | /** 11 | * Left to right direction 12 | */ 13 | public static const LEFT_TO_RIGHT:String = "myLeftToRight"; 14 | 15 | /** 16 | * Right to left direction 17 | */ 18 | public static const RIGHT_TO_LEFT:String = "myRightToLeft"; 19 | 20 | /** 21 | * Top to bottom direction 22 | */ 23 | public static const TOP_TO_BOTTOM:String = "myTopToBottom"; 24 | 25 | /** 26 | * bottom to top direction 27 | */ 28 | public static const BOTTOM_TO_TOP:String = "myBottomToTop"; 29 | } 30 | 31 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/events/ListEvent.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.events 2 | { 3 | import flash.events.Event; 4 | 5 | /** 6 | * 7 | * @author Hadi Tavakoli - 3/18/2010 5:39 PM 8 | */ 9 | public class ListEvent extends Event 10 | { 11 | /** 12 | * @private 13 | */ 14 | public static const RESIZE:String = "onListResize"; 15 | public static const ITEM_ADDED:String = "onItemAdded"; 16 | 17 | private var _param:*; 18 | 19 | /** 20 | * 21 | */ 22 | public function ListEvent(type:String, data:*=null, bubbles:Boolean=false, cancelable:Boolean=false):void 23 | { 24 | _param = data; 25 | super(type, bubbles, cancelable); 26 | } 27 | 28 | /** 29 | * @private 30 | */ 31 | public function get param():* 32 | { 33 | return _param; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/Position.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | 4 | /** 5 | * Indicates the position of items. 6 | * @author Hadi Tavakoli - 8/5/2010 9:06 PM 7 | */ 8 | public class Position 9 | { 10 | /** 11 | * Left position 12 | */ 13 | public static const LEFT:String = "Left"; 14 | 15 | /** 16 | * Right position 17 | */ 18 | public static const RIGHT:String = "Right"; 19 | 20 | /** 21 | * Left position 22 | */ 23 | public static const CENTER:String = "Center"; 24 | 25 | 26 | 27 | 28 | /** 29 | * Top position 30 | */ 31 | public static const TOP:String = "Top"; 32 | 33 | /** 34 | * bottom position 35 | */ 36 | public static const BOTTOM:String = "Bottom"; 37 | 38 | /** 39 | * middle position 40 | */ 41 | public static const MIDDLE:String = "Middle"; 42 | } 43 | 44 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/Youtube.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | 4 | /** 5 | * Direction class indicates the direction of items. 6 | * @author Ali Tavakoli - 3/1/2010 12:27 PM 7 | */ 8 | public class Youtube 9 | { 10 | /** 11 | * playback small quality 12 | */ 13 | public static const QUALITY_SMALL:String = "small"; 14 | 15 | /** 16 | * playback medium quality 17 | */ 18 | public static const QUALITY_MEDIUM:String = "medium"; 19 | 20 | /** 21 | * playback large quality 22 | */ 23 | public static const QUALITY_LARGE:String = "large"; 24 | 25 | /** 26 | * playback hd720 quality 27 | */ 28 | public static const QUALITY_HD720:String = "hd720"; 29 | 30 | /** 31 | * playback hd1080 quality 32 | */ 33 | public static const QUALITY_HD1080:String = "hd1080"; 34 | 35 | /** 36 | * playback highres quality 37 | */ 38 | public static const QUALITY_HIGHRES:String = "highres"; 39 | 40 | /** 41 | * playback default quality 42 | */ 43 | public static const QUALITY_DEFAULT:String = "default"; 44 | 45 | /** 46 | * wrapper height 47 | */ 48 | public static const WRAPPER_HEIGHT:Number = 40; 49 | } 50 | 51 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/core/Log.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.core { 26 | 27 | public class Log{ 28 | public var text:String; 29 | public var c:String; 30 | public var p:int; 31 | public var r:Boolean; 32 | public var s:Boolean; 33 | // 34 | public var next:Log; 35 | public var prev:Log; 36 | // 37 | public function Log(t:String, ch:String, pr:int, repeating:Boolean = false, skipSafe:Boolean = false){ 38 | text = t; 39 | c = ch; 40 | p = pr; 41 | r = repeating; 42 | s = skipSafe; 43 | } 44 | public function toObject():Object{ 45 | return {text:text, c:c, p:p, r:r, s:s}; 46 | } 47 | public function toString():String{ 48 | return "["+c+"] " + text; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/Ease.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | /** 4 | * Ease class indicates different kinds of easing functions. 5 | * @author Ali Tavakoli 6 | */ 7 | public class Ease 8 | { 9 | public static const Regular_easeOut:String = "Regular_easeOut"; 10 | 11 | public static const Back_easeOut:String = "Back_easeOut"; 12 | 13 | public static const Bounce_easeOut:String = "Bounce_easeOut"; 14 | public static const Bounce_easeIn:String = "Bounce_easeIn"; 15 | public static const Bounce_easeInOut:String = "Bounce_easeInOut"; 16 | 17 | public static const Circ_easeOut:String = "Circ_easeOut"; 18 | public static const Circ_easeIn:String = "Circ_easeIn"; 19 | public static const Circ_easeInOut:String = "Circ_easeInOut"; 20 | 21 | public static const Cubic_easeOut:String = "Cubic_easeOut"; 22 | public static const Cubic_easeIn:String = "Cubic_easeIn"; 23 | public static const Cubic_easeInOut:String = "Cubic_easeInOut"; 24 | 25 | public static const Elastic_easeOut:String = "Elastic_easeOut"; 26 | public static const Elastic_easeIn:String = "Elastic_easeIn"; 27 | public static const Elastic_easeInOut:String = "Elastic_easeInOut"; 28 | 29 | public static const Expo_easeOut:String = "Expo_easeOut"; 30 | public static const Expo_easeIn:String = "Expo_easeIn"; 31 | public static const Expo_easeInOut:String = "Expo_easeInOut"; 32 | 33 | public static const Linear_easeNone:String = "Linear_easeNone"; 34 | 35 | public static const Quad_easeOut:String = "Quad_easeOut"; 36 | public static const Quad_easeIn:String = "Quad_easeIn"; 37 | public static const Quad_easeInOut:String = "Quad_easeInOut"; 38 | 39 | public static const Quart_easeOut:String = "Quart_easeOut"; 40 | public static const Quart_easeIn:String = "Quart_easeIn"; 41 | public static const Quart_easeInOut:String = "Quart_easeInOut"; 42 | 43 | public static const Quint_easeOut:String = "Quint_easeOut"; 44 | public static const Quint_easeIn:String = "Quint_easeIn"; 45 | public static const Quint_easeInOut:String = "Quint_easeInOut"; 46 | 47 | public static const Sine_easeOut:String = "Sine_easeOut"; 48 | public static const Sine_easeIn:String = "Sine_easeIn"; 49 | public static const Sine_easeInOut:String = "Sine_easeInOut"; 50 | } 51 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/core/Logs.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.core { 26 | public class Logs{ 27 | 28 | public var first:Log; 29 | public var last:Log; 30 | 31 | private var _length:uint; 32 | 33 | public function clear():void{ 34 | first = null; 35 | last = null; 36 | _length = 0; 37 | } 38 | 39 | public function get length():uint{ 40 | return _length; 41 | } 42 | // add to the last of chain 43 | public function push(v:Log):void{ 44 | if(last==null) { 45 | first = v; 46 | }else{ 47 | last.next = v; 48 | v.prev = last; 49 | } 50 | last = v; 51 | _length++; 52 | } 53 | // remove last item of chain 54 | public function pop():void{ 55 | if(last) { 56 | last = last.prev; 57 | _length--; 58 | } 59 | } 60 | // remove first item of chain 61 | public function shift(count:uint = 1):void{ 62 | while(first != null && count>0){ 63 | first = first.next; 64 | count--; 65 | _length--; 66 | } 67 | } 68 | public function remove(log:Log):void{ 69 | if(first == log) first = log.next; 70 | if(last == log) last = log.prev; 71 | if(log.next != null) log.next.prev = log.prev; 72 | if(log.prev != null) log.prev.next = log.next; 73 | _length--; 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/utils/WeakRef.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.utils { 26 | import flash.utils.Dictionary; 27 | 28 | public class WeakRef{ 29 | 30 | private var _val:*; 31 | private var _strong:Boolean; 32 | 33 | // 34 | // There is abilty to use strong reference incase you need to mix - 35 | // weak and strong references together somewhere 36 | public function WeakRef(ref:*, strong:Boolean = false) { 37 | if(ref is Function) strong = true; // Function must be strong ref, for now :/ 38 | _strong = strong; 39 | reference = ref; 40 | } 41 | // 42 | // 43 | // 44 | public function get reference():*{ 45 | if(_strong){ 46 | return _val; 47 | }else{ 48 | //there should be only 1 key in it anyway 49 | for(var X:* in _val){ 50 | return X; 51 | } 52 | } 53 | return null; 54 | } 55 | public function set reference(ref:*):void{ 56 | if(_strong){ 57 | _val = ref; 58 | }else{ 59 | _val = new Dictionary(true); 60 | _val[ref] = null; 61 | } 62 | } 63 | // 64 | // 65 | // 66 | public function get strong():Boolean{ 67 | return _strong; 68 | } 69 | public function set strong(b:Boolean):void{ 70 | if(_strong != b){ 71 | var ref:* = reference; 72 | _strong = b; 73 | reference = ref; 74 | } 75 | } 76 | } 77 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/consts/Easing.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.consts 2 | { 3 | /** 4 | * Easing class indicates different kinds of easing functions. 5 | * @author Ali Tavakoli - 6/27/2010 3:49 PM 6 | */ 7 | public class Easing 8 | { 9 | public static const Regular_easeOut:String = "Regular.easeOut"; 10 | 11 | public static const Back_easeOut:String = "Back.easeOut"; 12 | 13 | public static const Bounce_easeOut:String = "Bounce.easeOut"; 14 | public static const Bounce_easeIn:String = "Bounce.easeIn"; 15 | public static const Bounce_easeInOut:String = "Bounce.easeInOut"; 16 | 17 | public static const Circ_easeOut:String = "Circ.easeOut"; 18 | public static const Circ_easeIn:String = "Circ.easeIn"; 19 | public static const Circ_easeInOut:String = "Circ.easeInOut"; 20 | 21 | public static const Cubic_easeOut:String = "Cubic.easeOut"; 22 | public static const Cubic_easeIn:String = "Cubic.easeIn"; 23 | public static const Cubic_easeInOut:String = "Cubic.easeInOut"; 24 | 25 | public static const Elastic_easeOut:String = "Elastic.easeOut"; 26 | public static const Elastic_easeIn:String = "Elastic.easeIn"; 27 | public static const Elastic_easeInOut:String = "Elastic.easeInOut"; 28 | 29 | public static const Expo_easeOut:String = "Expo.easeOut"; 30 | public static const Expo_easeIn:String = "Expo.easeIn"; 31 | public static const Expo_easeInOut:String = "Expo.easeInOut"; 32 | 33 | public static const Linear_easeNone:String = "Linear.easeNone"; 34 | 35 | public static const Quad_easeOut:String = "Quad.easeOut"; 36 | public static const Quad_easeIn:String = "Quad.easeIn"; 37 | public static const Quad_easeInOut:String = "Quad.easeInOut"; 38 | 39 | public static const Quart_easeOut:String = "Quart.easeOut"; 40 | public static const Quart_easeIn:String = "Quart.easeIn"; 41 | public static const Quart_easeInOut:String = "Quart.easeInOut"; 42 | 43 | public static const Quint_easeOut:String = "Quint.easeOut"; 44 | public static const Quint_easeIn:String = "Quint.easeIn"; 45 | public static const Quint_easeInOut:String = "Quint.easeInOut"; 46 | 47 | public static const Sine_easeOut:String = "Sine.easeOut"; 48 | public static const Sine_easeIn:String = "Sine.easeIn"; 49 | public static const Sine_easeInOut:String = "Sine.easeInOut"; 50 | 51 | public static const Strong_easeOut:String = "Strong.easeOut"; 52 | public static const Strong_easeIn:String = "Strong.easeIn"; 53 | public static const Strong_easeInOut:String = "Strong.easeInOut"; 54 | } 55 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/utils/WeakObject.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.utils { 26 | import flash.utils.Proxy; 27 | import flash.utils.flash_proxy; 28 | 29 | public class WeakObject extends Proxy{ 30 | 31 | private var _item:Array; // array of object's properties 32 | private var _dir:Object; 33 | 34 | public function WeakObject() { 35 | _dir = new Object(); 36 | } 37 | 38 | 39 | public function set(n:String,obj:Object, strong:Boolean = false):void{ 40 | if(obj == null){ 41 | return; 42 | } 43 | _dir[n] = new WeakRef(obj, strong); 44 | } 45 | public function get(n:String):Object{ 46 | if(_dir[n]){ 47 | return _dir[n].reference; 48 | } 49 | return null; 50 | } 51 | // 52 | // PROXY 53 | // 54 | override flash_proxy function getProperty(n:*):* { 55 | return get(n); 56 | } 57 | override flash_proxy function callProperty(n:*, ... rest):* { 58 | var o:Object = get(n); 59 | if(o is Function){ 60 | return (o as Function).apply(this, rest); 61 | } 62 | return null; 63 | } 64 | override flash_proxy function setProperty(n:*, v:*):void { 65 | set(n,v); 66 | } 67 | override flash_proxy function nextNameIndex (index:int):int { 68 | // initial call 69 | if (index == 0) { 70 | _item = new Array(); 71 | for (var x:* in _dir) { 72 | _item.push(x); 73 | } 74 | } 75 | if (index < _item.length) { 76 | return index + 1; 77 | } else { 78 | return 0; 79 | } 80 | } 81 | override flash_proxy function nextName(index:int):String { 82 | return _item[index - 1]; 83 | } 84 | public function toString():String{ 85 | return "[WeakObject]"; 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/Ch.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | 26 | package com.luaye.console { 27 | /** 28 | * @author Lu 29 | */ 30 | public class Ch { 31 | 32 | private var _c:*; // because it could be Console or C 33 | public var name:String; 34 | 35 | public function Ch(n:String = null, c:Console = null){ 36 | name = n; 37 | // allowed to pass in Console here incase you want to use a different console instance from whats used in C 38 | _c = c?c:C; 39 | } 40 | public function add(str:*, priority:Number = 2, isRepeating:Boolean = false):void{ 41 | _c.ch(name, str, priority, isRepeating); 42 | } 43 | public function log(...args):void{ 44 | _c.logch.apply(null, [name].concat(args)); 45 | } 46 | public function info(...args):void{ 47 | _c.infoch.apply(null, [name].concat(args)); 48 | } 49 | public function debug(...args):void{ 50 | _c.debugch.apply(null, [name].concat(args)); 51 | } 52 | public function warn(...args):void{ 53 | _c.warnch.apply(null, [name].concat(args)); 54 | } 55 | public function error(...args):void{ 56 | _c.errorch.apply(null, [name].concat(args)); 57 | } 58 | public function fatal(...args):void{ 59 | _c.fatalch.apply(null, [name].concat(args)); 60 | } 61 | /* 62 | not worth using... 63 | public function set tracing(v:Boolean):void{ 64 | var chs:Array = _c.tracingChannels; 65 | var i:int = chs.indexOf(name); 66 | if(v){ 67 | _c.tracing = true; 68 | if(i<0){ 69 | chs.push(name); 70 | } 71 | }else if(i>=0){ 72 | chs.splice(i,1); 73 | } 74 | } 75 | public function get tracing():Boolean{ 76 | if(!_c.tracing) return false; 77 | var chs:Array = _c.tracingChannels; 78 | if(chs.length==0) return true; 79 | // 80 | var i:int = chs.indexOf(name); 81 | if(i<0) return false; 82 | return true; 83 | }*/ 84 | 85 | /** 86 | * Clear channel 87 | */ 88 | public function clear():void{ 89 | _c.clear(name); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/MemoryPanel.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | 26 | package com.luaye.console.view { 27 | import com.luaye.console.Console; 28 | 29 | import flash.events.Event; 30 | import flash.events.TextEvent; 31 | 32 | public class MemoryPanel extends GraphingPanel { 33 | 34 | // 35 | public function MemoryPanel(m:Console) { 36 | super(m, 80,40); 37 | name = Console.PANEL_MEMORY; 38 | updateEvery = 5; 39 | drawEvery = 5; 40 | minimumWidth = 32; 41 | //master.mm.addEventListener(MemoryMonitor.GARBAGE_COLLECTED, onGC, false, 0, true); 42 | //master.mm.notifyGC = !m.isRemote; 43 | add(this, "current", 0x5060FF, "Memory"); 44 | } 45 | public override function close():void { 46 | super.close(); 47 | master.panels.updateMenu(); // should be black boxed :/ 48 | } 49 | public function get current():Number{ 50 | // in MB, up to 2 decimal 51 | return Math.round(master.currentMemory/10485.76)/100; 52 | } 53 | protected override function onFrame(e:Event):Boolean{ 54 | if(super.onFrame(e)){ 55 | updateKeyText(); 56 | return true; 57 | } 58 | return false; 59 | } 60 | public override function updateKeyText():void{ 61 | var mem:Number = getCurrentOf(0); 62 | if(mem>0){ 63 | keyTxt.htmlText = ""+mem.toFixed(2)+"mb G R X"; 64 | }else{ 65 | keyTxt.htmlText = "no mem input X"; 66 | } 67 | } 68 | protected override function linkHandler(e:TextEvent):void{ 69 | if(e.text == "gc"){ 70 | master.gc(); 71 | } 72 | super.linkHandler(e); 73 | } 74 | // 75 | 76 | protected override function onMenuRollOver(e:TextEvent):void{ 77 | var txt:String = e.text?e.text.replace("event:",""):null; 78 | if(txt == "gc"){ 79 | txt = "Garbage collect::Requires debugger version of flash player"; 80 | } 81 | master.panels.tooltip(txt, this); 82 | } 83 | /*private function onGC(e:Event):void{ 84 | mark(0xFF000000); 85 | }*/ 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /AIR/AIR.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/ChannelsPanel.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import com.luaye.console.Console; 27 | 28 | import flash.events.TextEvent; 29 | import flash.text.TextField; 30 | import flash.text.TextFieldAutoSize; 31 | 32 | public class ChannelsPanel extends AbstractPanel{ 33 | 34 | private var _txtField:TextField; 35 | 36 | private var _channels:Array; 37 | 38 | public function ChannelsPanel(m:Console) { 39 | super(m); 40 | name = Console.PANEL_CHANNELS; 41 | init(10,10,false); 42 | _txtField = new TextField(); 43 | _txtField.name = "channelsField"; 44 | _txtField.wordWrap = true; 45 | _txtField.width = 160; 46 | _txtField.multiline = true; 47 | _txtField.autoSize = TextFieldAutoSize.LEFT; 48 | _txtField.styleSheet = style.css; 49 | _txtField.addEventListener(TextEvent.LINK, linkHandler, false, 0, true); 50 | registerRollOverTextField(_txtField); 51 | _txtField.addEventListener(AbstractPanel.TEXT_LINK, onMenuRollOver, false, 0, true); 52 | registerDragger(_txtField); 53 | addChild(_txtField); 54 | } 55 | public function start(channels:Array):void{ 56 | _channels = channels; 57 | update(); 58 | } 59 | public function update():void{ 60 | _txtField.wordWrap = false; 61 | _txtField.width = 80; 62 | var str:String = " X "+ master.panels.mainPanel.getChannelsLink(); 63 | _txtField.htmlText = str+""; 64 | if(_txtField.width>160){ 65 | _txtField.wordWrap = true; 66 | _txtField.width = 160; 67 | } 68 | width = _txtField.width+4; 69 | height = _txtField.height; 70 | } 71 | private function onMenuRollOver(e:TextEvent):void{ 72 | master.panels.mainPanel.onMenuRollOver(e, this); 73 | } 74 | protected function linkHandler(e:TextEvent):void{ 75 | _txtField.setSelection(0, 0); 76 | if(e.text == "close"){ 77 | master.channelsPanel = false; 78 | }else if(e.text.substring(0,8) == "channel_"){ 79 | master.panels.mainPanel.onChannelPressed(e.text.substring(8)); 80 | } 81 | _txtField.setSelection(0, 0); 82 | e.stopPropagation(); 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/FPSPanel.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import com.luaye.console.Console; 27 | import com.luaye.console.view.GraphingPanel; 28 | 29 | import flash.events.Event; 30 | 31 | public class FPSPanel extends GraphingPanel { 32 | // 33 | private var _cachedCurrent:Number; 34 | // 35 | public function FPSPanel(m:Console) { 36 | super(m, 80,40); 37 | name = Console.PANEL_FPS; 38 | lowest = 0; 39 | minimumWidth = 32; 40 | add(this, "current", 0xFF3333, "FPS"); 41 | } 42 | public override function close():void { 43 | super.close(); 44 | master.panels.updateMenu(); // should be black boxed :/ 45 | } 46 | //public override function reset():void { 47 | // //lowest = NaN; 48 | // super.reset(); 49 | //} 50 | public override function stop():void { 51 | super.stop(); 52 | reset(); 53 | } 54 | public override function updateKeyText():void{ 55 | if(_history.length>0){ 56 | keyTxt.htmlText = ""+master.fps.toFixed(1)+" | "+getAverageOf(0).toFixed(1)+" R X"; 57 | }else{ 58 | keyTxt.htmlText = "no fps input X"; 59 | } 60 | } 61 | public function get current():Number{ 62 | if(isNaN(_cachedCurrent)) 63 | return master.fps; 64 | var mspf:Number = _cachedCurrent; 65 | _cachedCurrent = NaN; 66 | return mspf; 67 | } 68 | public function addCurrent(n:Number):void{ 69 | _cachedCurrent = n; 70 | updateData(); 71 | } 72 | protected override function onFrame(e:Event):Boolean{ 73 | if(master.remote) return false; 74 | var mspf:Number = master.mspf; 75 | if (!isNaN(mspf)) { 76 | if(super.onFrame(e)){ 77 | updateKeyText(); 78 | if(stage){ 79 | fixed = true; 80 | averaging = stage.frameRate; 81 | highest = averaging; 82 | var frames:int = Math.floor(mspf/(1000/highest)); 83 | // this is to try add the frames that have been lagged 84 | if(frames>Console.FPS_MAX_LAG_FRAMES) frames = Console.FPS_MAX_LAG_FRAMES; // Don't add too many 85 | while(frames>1){ 86 | updateData(); 87 | frames--; 88 | } 89 | } 90 | return true; 91 | } 92 | } 93 | return false; 94 | } 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/utils/Utils.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.utils { 26 | import flash.utils.getQualifiedClassName; 27 | import flash.display.Graphics; 28 | import flash.geom.Point; 29 | 30 | public class Utils { 31 | 32 | public static function round(n:Number, d:uint):Number{ 33 | return Math.round(n*d)/d; 34 | } 35 | public static function angle(srcP:Point, point:Point):Number { 36 | var X: Number = point.x - srcP.x; 37 | var Y: Number = point.y - srcP.y; 38 | var a:Number = Math.atan2(Y , X)/Math.PI * 180; 39 | a +=90; 40 | if(a>180){ 41 | a -= 360; 42 | } 43 | return a; 44 | } 45 | public static function drawCircleSegment(g:Graphics, radius:Number,pos:Point = null, deg:Number = 180, startDeg:Number = 0):Point 46 | { 47 | if(!pos) pos = new Point(); 48 | var reversed:Boolean = false; 49 | if(deg<0){ 50 | reversed = true; 51 | deg = Math.abs(deg); 52 | } 53 | var rad:Number = (deg*Math.PI)/180; 54 | var rad2:Number = (startDeg*Math.PI)/180; 55 | var p:Point = getPointOnCircle(radius, rad2); 56 | p.offset(pos.x,pos.y); 57 | g.moveTo(p.x,p.y); 58 | var pra:Number = 0; 59 | for (var i:int = 1; i<=(rad+1); i++) { 60 | var ra:Number = i<=rad?i:rad; 61 | var diffr:Number = ra-pra; 62 | var offr:Number = 1+(0.12*diffr*diffr); 63 | var ap:Point = getPointOnCircle(radius*offr, ((ra-(diffr/2))*(reversed?-1:1))+rad2); 64 | ap.offset(pos.x,pos.y); 65 | p = getPointOnCircle(radius, (ra*(reversed?-1:1))+rad2); 66 | p.offset(pos.x,pos.y); 67 | g.curveTo(ap.x,ap.y, p.x,p.y); 68 | pra = ra; 69 | } 70 | return p; 71 | } 72 | public static function getPointOnCircle(radius:Number, rad:Number):Point { 73 | return new Point(radius * Math.cos(rad),radius * Math.sin(rad)); 74 | } 75 | // 76 | 77 | public static function averageOut(current:Number, addition:Number, over:Number):Number { 78 | // this does not output an absolute average - you would need a history of values for this 79 | // This way is more light weight but not as accurate. 80 | return current+((addition-current)/over); 81 | } 82 | public static function replaceByIndexes(str:String, replace:String, start:int, end:int):String { 83 | return str.substring(0,start)+replace+str.substring(end); 84 | } 85 | 86 | public static function shortClassName(cls:Object):String{ 87 | var str:String = getQualifiedClassName(cls); 88 | var ind:int = str.lastIndexOf("::"); 89 | return str.substring(ind>=0?(ind+2):0); 90 | } 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/core/MemoryMonitor.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.core { 26 | import flash.events.EventDispatcher; 27 | import flash.system.System; 28 | import flash.utils.Dictionary; 29 | import flash.utils.getTimer; 30 | 31 | public class MemoryMonitor extends EventDispatcher{ 32 | 33 | //public static const GARBAGE_COLLECTED:String = "garbageCollected"; 34 | //private static const DUMMY_GARBAGE:String = "_memoryMonitor_dummy_garbage"; 35 | 36 | private var _namesList:Object; 37 | private var _objectsList:Dictionary; 38 | //private var _notifyGC:Boolean; 39 | // 40 | // 41 | public function MemoryMonitor() { 42 | _namesList = new Object(); 43 | _objectsList = new Dictionary(true); 44 | } 45 | public function watch(obj:Object, n:String):String{ 46 | if(_objectsList[obj]){ 47 | if(_namesList[_objectsList[obj]]){ 48 | unwatch(_objectsList[obj]); 49 | } 50 | } 51 | if(_namesList[n] && _objectsList[obj] != n){ 52 | var nn:String = n+"@"+getTimer()+"_"+Math.floor(Math.random()*100); 53 | n = nn; 54 | } 55 | _namesList[n] = true; 56 | _objectsList[obj] = n; 57 | return n; 58 | } 59 | public function unwatch(n:String):void{ 60 | for (var X:Object in _objectsList) { 61 | if(_objectsList[X] == n){ 62 | delete _objectsList[X]; 63 | } 64 | } 65 | delete _namesList[n]; 66 | } 67 | // 68 | // 69 | // 70 | public function update():Array { 71 | var arr:Array = new Array(); 72 | var o:Object = new Object(); 73 | for (var X:Object in _objectsList) { 74 | o[_objectsList[X]] = true; 75 | } 76 | for(var Y:String in _namesList){ 77 | if(!o[Y]){ 78 | arr.push(Y); 79 | delete _namesList[Y]; 80 | } 81 | } 82 | return arr; 83 | } 84 | /*private function seedGCDummy():void{ 85 | if(!_namesList[DUMMY_GARBAGE]){ 86 | // using MovieClip as dummy garbate as it doenst get collected straight away like others 87 | watch(new MovieClip(), DUMMY_GARBAGE); 88 | } 89 | } 90 | public function set notifyGC(b:Boolean):void{ 91 | if(_notifyGC != b){ 92 | _notifyGC = b; 93 | if(b){ 94 | seedGCDummy(); 95 | }else if(!b){ 96 | unwatch(DUMMY_GARBAGE); 97 | } 98 | } 99 | } 100 | public function get notifyGC():Boolean{ 101 | return _notifyGC; 102 | }*/ 103 | // 104 | // only works in debugger player version 105 | // 106 | public function gc():Boolean { 107 | if(System["gc"] != null){ 108 | System["gc"](); 109 | return true; 110 | } 111 | return false; 112 | } 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /ChangeLog.md: -------------------------------------------------------------------------------- 1 | # Permission Check Air Native Extension 2 | 3 | *Jul 30, 2020 - v5.0.0* 4 | - Upgrade dependencies to the latest versions. 5 | - Fixed some minor issues and refactor native codes. 6 | 7 | *Apr 05, 2020 - V4.0.1* 8 | - Add androidx dependencies instead of android support libraries 9 | 10 | *Aug 2, 2019 - V3.1.1* 11 | - Added Android 64-bit support 12 | - Supports iOS 10+ 13 | - Removed **PermissionCheck.os** property, use ```OverrideAir.os``` instead. 14 | 15 | *Feb 21, 2019 - V3.1.0* 16 | - Added method ```PermissionCheck.shouldShowRequest("permissionSource")```. This method works on Android side only. 17 | 18 | *Nov 18, 2018 - V3.0.1* 19 | - Works with OverrideAir ANE V5.6.1 or higher 20 | - Works with ANELAB V1.1.26 or higher 21 | 22 | *Sep 10, 2018 - V3.0.0* 23 | - remove *androidSupport* and instead add the following dependencies: 24 | - `com.myflashlab.air.extensions.dependency.androidSupport.v4` 25 | - `com.myflashlab.air.extensions.dependency.androidSupport.core` 26 | - Set `android:targetSdkVersion` to at least `26` in your AIR manifest file 27 | - When asking for iOS SOURCE_LOCATION_ALWAYS permission, you must add a new `key` to your manifest in adition to the old one: 28 | ```xml 29 | 30 | NSLocationAlwaysUsageDescription 31 | My description about why I need location access always 32 | 33 | NSLocationAlwaysAndWhenInUseUsageDescription 34 | My description about why I need location access always 35 | ``` 36 | * On Android side, we have now a new static method, ```PermissionCheck.requestMulti``` which you can pass in multiple permissions in one call if you are asking for multiple permissions one after the other. This feature is NOT supported on iOS though. avoid that on the iOS side or it will throw an error. 37 | ```actionscript 38 | PermissionCheck.requestMulti( 39 | [ 40 | PermissionCheck.SOURCE_CAMERA, 41 | PermissionCheck.SOURCE_MIC 42 | ], 43 | onRequestMultiResult 44 | ); 45 | 46 | function onRequestMultiResult($arr:Array):void 47 | { 48 | for(var i:int=0; i < $arr.length; i++) 49 | { 50 | trace("permission for " + $arr[i].source + ": " + $arr[i].state); 51 | } 52 | } 53 | ``` 54 | 55 | * Working with this ANE from now on is static rather than instance initialization. Refer to the sample codes to know how you should update your code to use the static methods rathen than instances. 56 | * The permission request callback function returns an *Object* rather than the old *int* parameter. 57 | ```actionscript 58 | // asking for the camera permission 59 | PermissionCheck.request(PermissionCheck.SOURCE_CAMERA, onRequestResult); 60 | 61 | function onRequestResult($obj:Object):void 62 | { 63 | // $obj.source > will be SOURCE_CAMERA in this example 64 | // $obj.state > will be either PERMISSION_DENIED, PERMISSION_GRANTED or PERMISSION_OS_ERR 65 | trace("permission for " + $obj.source + ": " + $obj.state); 66 | } 67 | ``` 68 | 69 | *Dec 15, 2017 - V2.2.2* 70 | - Optimized for [ANE-LAB software](https://github.com/myflashlab/ANE-LAB). 71 | 72 | *Aug 14, 2017 - V2.2.0* 73 | - `SOURCE_LOCATION_WHEN_IN_USE` and `SOURCE_LOCATION_ALWAYS` for iOS are now also supported by the ANE. Do not confuse them with `SOURCE_LOCATION` which works on Android only. 74 | - Sample intelliJ project added to GitHub. 75 | 76 | *Mar 27, 2016 - V2.1.0* 77 | - Updated the ANE with the latest OverrideAir ANE. This dependency is required on iOS builds also. 78 | 79 | *Nov 03, 2016 - V2.0.2* 80 | - Fixed a bug on Android when requesting permissions quickly one after the other 81 | - Fixed a bug on Android when requesting for permission groups. In this fix, you can call any of the permissions in a group and a correct dialog will open 82 | 83 | *Nov 02, 2016 - V2.0.1* 84 | - Fixed a bug on Android when requesting for a permission in the project constructor function was returning a wrong value. 85 | 86 | *Oct 29, 2016 - V2.0.0* 87 | - Added Android support 88 | - AIR 24+ is required to compile the ANE 89 | - Set -swf-version=35 in compiler options 90 | - Set ```android:targetSdkVersion``` to at least ``23``` in your AIR manifest file 91 | 92 | *Sep 18, 2016 - V1.0.1* 93 | - Fixed iOS 7 hard crash 94 | 95 | *Jun 08, 2016 - V1.0.0* 96 | - beginning of the journey! 97 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/RollerPanel.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import com.luaye.console.Console; 27 | import com.luaye.console.utils.Utils; 28 | 29 | import flash.display.DisplayObject; 30 | import flash.display.DisplayObjectContainer; 31 | import flash.display.Stage; 32 | import flash.events.Event; 33 | import flash.events.TextEvent; 34 | import flash.geom.Point; 35 | import flash.text.TextField; 36 | import flash.text.TextFieldAutoSize; 37 | import flash.utils.Dictionary; 38 | 39 | public class RollerPanel extends AbstractPanel{ 40 | 41 | private var _txtField:TextField; 42 | private var _base:DisplayObjectContainer; 43 | 44 | public function RollerPanel(m:Console) { 45 | super(m); 46 | name = Console.PANEL_ROLLER; 47 | init(60,100,false); 48 | _txtField = new TextField(); 49 | _txtField.name = "rollerprints"; 50 | _txtField.multiline = true; 51 | _txtField.autoSize = TextFieldAutoSize.LEFT; 52 | _txtField.styleSheet = style.css; 53 | _txtField.addEventListener(TextEvent.LINK, linkHandler, false, 0, true); 54 | registerRollOverTextField(_txtField); 55 | _txtField.addEventListener(AbstractPanel.TEXT_LINK, onMenuRollOver, false, 0, true); 56 | registerDragger(_txtField); 57 | addChild(_txtField); 58 | } 59 | public function start(base:DisplayObjectContainer):void{ 60 | _base = base; 61 | addEventListener(Event.ENTER_FRAME, _onFrame, false, 0, true); 62 | } 63 | public function capture():String{ 64 | return getMapString(true); 65 | } 66 | private function onMenuRollOver(e:TextEvent):void{ 67 | master.panels.tooltip(e.text?"Close":null, this); 68 | } 69 | private function _onFrame(e:Event):void{ 70 | if(!_base.stage){ 71 | close(); 72 | return; 73 | } 74 | _txtField.htmlText = ""+getMapString()+""; 75 | _txtField.autoSize = TextFieldAutoSize.LEFT; 76 | _txtField.setSelection(0, 0); 77 | width = _txtField.width+4; 78 | height = _txtField.height; 79 | } 80 | private function getMapString(dolink:Boolean = false):String{ 81 | var stg:Stage = _base.stage; 82 | var str:String = ""; 83 | var objs:Array = stg.getObjectsUnderPoint(new Point(stg.mouseX, stg.mouseY)); 84 | var stepMap:Dictionary = new Dictionary(true); 85 | if(objs.length == 0){ 86 | objs.push(stg);// if nothing at least have stage. 87 | } 88 | for each(var child:DisplayObject in objs){ 89 | var chain:Array = new Array(child); 90 | var par:DisplayObjectContainer = child.parent; 91 | while(par){ 92 | chain.unshift(par); 93 | par = par.parent; 94 | } 95 | var len:uint = chain.length; 96 | for (var i:uint=0; i0;j--){ 102 | str += j==1?" ∟":" -"; 103 | } 104 | if(dolink){ 105 | if(obj == stg){ 106 | str += "Stage ["+stg.mouseX+","+stg.mouseY+"]"; 107 | }else if(i == len-1){ 108 | str += ""+obj.name+"("+Utils.shortClassName(obj)+")"; 109 | }else { 110 | str += ""+obj.name+"("+Utils.shortClassName(obj)+")"; 111 | } 112 | }else{ 113 | if(obj == stg){ 114 | str += " X Stage ["+stg.mouseX+","+stg.mouseY+"]
"; 115 | }else if(i == len-1){ 116 | str += ""+obj.name+"("+Utils.shortClassName(obj)+")"; 117 | }else { 118 | str += ""+obj.name+"("+Utils.shortClassName(obj)+")
"; 119 | } 120 | } 121 | } 122 | } 123 | } 124 | return str; 125 | } 126 | private function mapUpward(mc:DisplayObject):String{ 127 | var arr:Array = [mc.name]; 128 | mc = mc.parent; 129 | while(mc && mc!=mc.stage){ 130 | arr.push(mc.name); 131 | mc = mc.parent; 132 | } 133 | return arr.reverse().join(Console.MAPPING_SPLITTER); 134 | } 135 | public override function close():void { 136 | removeEventListener(Event.ENTER_FRAME, _onFrame); 137 | _base = null; 138 | super.close(); 139 | master.panels.updateMenu(); // should be black boxed :/ 140 | } 141 | protected function linkHandler(e:TextEvent):void{ 142 | TextField(e.currentTarget).setSelection(0, 0); 143 | if(e.text == "close"){ 144 | close(); 145 | } 146 | e.stopPropagation(); 147 | } 148 | } 149 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/Style.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import flash.text.TextFormat; 27 | import flash.text.StyleSheet; 28 | 29 | public class Style { 30 | 31 | private var _preset:int = 0; 32 | 33 | public var css:StyleSheet; 34 | public var panelBackgroundColor:int; 35 | public var panelBackgroundAlpha:Number; 36 | public var panelScalerColor:Number; 37 | public var commandLineColor:Number; 38 | public var bottomLineColor:Number; 39 | public var textFormat:TextFormat; 40 | 41 | public function Style(uiset:int = 1) { 42 | css = new StyleSheet(); 43 | preset = uiset; 44 | if(_preset<=0){ 45 | preset = 1; 46 | } 47 | } 48 | 49 | public function set preset(num:int):void{ 50 | if(hasOwnProperty(["preset"+num])){ 51 | this["preset"+num](); 52 | _preset = num; 53 | } 54 | } 55 | public function get preset():int{ 56 | return _preset; 57 | } 58 | public function preset1():void{ 59 | panelBackgroundColor = 0; 60 | panelScalerColor = 0x880000; 61 | commandLineColor = 0x10AA00; 62 | bottomLineColor = 0xFF0000; 63 | panelBackgroundAlpha = 0.8; 64 | textFormat = new TextFormat('Arial', 12, 0xFFFFFF); 65 | // 66 | css.setStyle("r",{textAlign:'right', display:'inline'}); 67 | css.setStyle("w",{color:'#FFFFFF', fontFamily:'Arial', fontSize:'12', display:'inline'}); 68 | css.setStyle("s",{color:'#CCCCCC', fontFamily:'Arial', fontSize:'10', display:'inline'}); 69 | css.setStyle("y",{color:'#DD5500', display:'inline'}); 70 | css.setStyle("ro",{color:'#DD5500', fontFamily:'Arial', fontSize:'11', display:'inline'}); 71 | css.setStyle("roBold",{color:'#EE6611', fontWeight:'bold'}); 72 | css.setStyle("menu",{color:'#FF8800', display:'inline'}); 73 | css.setStyle("chs",{color:'#FFFFFF', fontSize:'11', leading:'2', display:'inline'}); 74 | css.setStyle("ch",{color:'#0099CC', display:'inline'}); 75 | css.setStyle("tooltip",{color:'#DD5500',fontFamily:'Arial', textAlign:'center'}); 76 | // 77 | css.setStyle("p",{fontFamily:'Verdana', fontSize:'11'}); 78 | css.setStyle("l1",{color:'#0099CC'}); 79 | css.setStyle("l2",{color:'#FF8800'}); 80 | css.setStyle("p0",{color:'#336633', display:'inline'}); 81 | css.setStyle("p1",{color:'#33AA33', display:'inline'}); 82 | css.setStyle("p2",{color:'#77D077', display:'inline'}); 83 | css.setStyle("p3",{color:'#AAEEAA', display:'inline'}); 84 | css.setStyle("p4",{color:'#D6FFD6', display:'inline'}); 85 | css.setStyle("p5",{color:'#E6E6E6', display:'inline'}); 86 | css.setStyle("p6",{color:'#FFD6D6', display:'inline'}); 87 | css.setStyle("p7",{color:'#FFAAAA', display:'inline'}); 88 | css.setStyle("p8",{color:'#FF7777', display:'inline'}); 89 | css.setStyle("p9",{color:'#FF2222', display:'inline'}); 90 | css.setStyle("p10",{color:'#FF2222', display:'inline'}); 91 | css.setStyle("p100",{color:'#FF0000', fontWeight:'bold', display:'inline'}); 92 | css.setStyle("p-1",{color:'#0099CC', display:'inline'}); 93 | css.setStyle("p-2",{color:'#FF8800', display:'inline'}); 94 | } 95 | 96 | public function preset2():void{ 97 | panelBackgroundColor = 0xFFFFFF; 98 | panelScalerColor = 0xFF0000; 99 | commandLineColor = 0x66CC00; 100 | bottomLineColor = 0xFF0000; 101 | panelBackgroundAlpha = 0.8; 102 | textFormat = new TextFormat('Arial', 12, 0); 103 | // 104 | css.setStyle("r",{textAlign:'right', display:'inline'}); 105 | css.setStyle("w",{color:'#000000', fontFamily:'Arial', fontSize:'12', display:'inline'}); 106 | css.setStyle("s",{color:'#333333', fontFamily:'Arial', fontSize:'10', display:'inline'}); 107 | css.setStyle("y",{color:'#881100', display:'inline'}); 108 | css.setStyle("ro",{color:'#661100', fontFamily:'Arial', fontSize:'11', display:'inline'}); 109 | css.setStyle("roBold",{color:'#AA4400', fontWeight:'bold'}); 110 | css.setStyle("menu",{color:'#CC1100', display:'inline'}); 111 | css.setStyle("chs",{color:'#000000', fontSize:'11', leading:'2', display:'inline'}); 112 | css.setStyle("ch",{color:'#0066AA', display:'inline'}); 113 | css.setStyle("tooltip",{color:'#AA3300',fontFamily:'Arial', textAlign:'center'}); 114 | // 115 | css.setStyle("p",{fontFamily:'Verdana', fontSize:'11'}); 116 | css.setStyle("l1",{color:'#0099CC'}); 117 | css.setStyle("l2",{color:'#FF8800'}); 118 | css.setStyle("p0",{color:'#666666', display:'inline'}); 119 | css.setStyle("p1",{color:'#339033', display:'inline'}); 120 | css.setStyle("p2",{color:'#227722', display:'inline'}); 121 | css.setStyle("p3",{color:'#115511', display:'inline'}); 122 | css.setStyle("p4",{color:'#003300', display:'inline'}); 123 | css.setStyle("p5",{color:'#000000', display:'inline'}); 124 | css.setStyle("p6",{color:'#660000', display:'inline'}); 125 | css.setStyle("p7",{color:'#990000', display:'inline'}); 126 | css.setStyle("p8",{color:'#BB0000', display:'inline'}); 127 | css.setStyle("p9",{color:'#DD0000', display:'inline'}); 128 | css.setStyle("p10",{color:'#FF0000', display:'inline'}); 129 | css.setStyle("p100",{color:'#FF0000', fontWeight:'bold', display:'inline'}); 130 | css.setStyle("p-1",{color:'#0099CC', display:'inline'}); 131 | css.setStyle("p-2",{color:'#FF6600', display:'inline'}); 132 | } 133 | public function preset3():void{ 134 | preset1(); 135 | panelBackgroundAlpha = 1; 136 | } 137 | public function preset4():void{ 138 | preset2(); 139 | panelBackgroundAlpha = 1; 140 | } 141 | public function preset951():void{ 142 | // USED BY AIR Remote 143 | preset1(); 144 | panelBackgroundAlpha = 0.55; 145 | } 146 | } 147 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/tools/DynamicFunc.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.tools 2 | { 3 | //import com.luaye.console.C; 4 | /** 5 | * With the help of this class you can convert strings into function calls. 6 | * your string must be in the following format, as you can see, we have the function name as myFunc 7 | * and you may optionally send different styles of arguments to that function, it supports arguments in form of 8 | * simple strings, arrays or objects. 9 | * myFunc(val1,val2,[arr1,arr2,arr3],{var1:value1,var2:value2,var3:value3}) 10 | * 11 | * 12 | * function myFunc($str1:String, $str2:String, $arr:Array, $obj:Object):void 13 | * { 14 | * trace($str1); 15 | * trace($str2); 16 | * trace($arr); 17 | * trace($obj); 18 | * } 19 | * 20 | * 21 | * @author Hadi Tavakoli - 9/11/2010 1:32 PM 22 | * @author Hadi Tavakoli - Modified - 5/14/2011 5:34 PM 23 | * @author Hadi Tavakoli - Modified - 8/30/2011 6:56 PM 24 | * @example The following example shows how a string is converted to an actuall function call. 25 | * 26 | * 27 | * var myString:String = "myFunc(value,value2,[arr1,arr2,arr3],{var1:value1,var2:value2,var3:value3})"; 28 | * var df:DynamicFunc = new DynamicFunc(myString); 29 | * this[df.funcName].apply(null, df.inputs); 30 | * 31 | * function myFunc($str1:String, $str2:String, $arr:Array, $obj:Object):void 32 | * { 33 | * trace($str1); 34 | * trace($str2); 35 | * trace($arr); 36 | * trace($obj); 37 | * } 38 | * 39 | */ 40 | public class DynamicFunc 41 | { 42 | private var _funcName:String; 43 | private var _inputs:Array = []; 44 | 45 | public static const OBJECT_PATTERN:RegExp = /[\w_!.@\$\?%]+:[\w_!.@\$\?%\s\/\[\]]+/g; 46 | public static const STRING_PATTERN_FOR_OBJECT:RegExp = /[\w_!.@\$\?%\s\/\[\]]+/g; 47 | public static const STRING_PATTERN:RegExp = /[\w_!:.@\$\?%\s\/\(\)'-]+/g; 48 | 49 | /** 50 | * initialize the class and send your string to be converted to a function call. 51 | * @param $str 52 | * 53 | * @see #funcName 54 | * @see #inputs 55 | */ 56 | public function DynamicFunc($str:String):void 57 | { 58 | //required patterns for analyzing the string 59 | var funcPattern:RegExp = /[\w_]+/; 60 | var valuePattern:RegExp = /\[?\{?((([\w_!.@\$\?%]+):?([\w_!.@\$\?%\s\/]+)?),?\s?)+\}?\]?/g; 61 | //var stringPattern:RegExp = /[\w_!:.@\$\?%\s\/]+/g; 62 | //var stringPatternForObject:RegExp = /[\w_!.@\$\?%\s\/]+/g; 63 | //var objectPattern:RegExp = /[\w_!.@\$\?%]+:[\w_!.@\$\?%\s\/]+/g; 64 | 65 | // save the function name in string 66 | _funcName = $str.match(funcPattern)[0]; 67 | 68 | // overwrite the raw string and remove the function name from the beggining 69 | $str = $str.replace(_funcName, ""); 70 | 71 | // identify different kinds of inputs and save them in an array 72 | var rawValues:Array = $str.match(valuePattern); 73 | 74 | for (var i:int = 0; i < rawValues.length; i++ ) 75 | { 76 | var curr:String = rawValues[i]; 77 | 78 | if (curr.charAt(0) == "[") 79 | { 80 | // save the input as an array 81 | _inputs.push(curr.match(DynamicFunc.STRING_PATTERN)); 82 | } 83 | else if (curr.charAt(0) == "{") 84 | { 85 | // save the input as an object 86 | var finalObject:Object = {}; 87 | var objMatchArray:Array = curr.match(DynamicFunc.OBJECT_PATTERN); 88 | for (var k:int = 0; k < objMatchArray.length; k++ ) 89 | { 90 | var eachPair:Array = objMatchArray[k].match(DynamicFunc.STRING_PATTERN_FOR_OBJECT); 91 | finalObject[eachPair[0]] = eachPair[1]; 92 | } 93 | _inputs.push(finalObject); 94 | } 95 | else 96 | { 97 | // save the input as a string 98 | var curStringArr:Array = curr.match(DynamicFunc.STRING_PATTERN); 99 | for (var j:int = 0; j < curStringArr.length; j++ ) 100 | { 101 | _inputs.push(curStringArr[j]); 102 | } 103 | } 104 | } 105 | } 106 | 107 | /** 108 | * returns the function name in string type 109 | */ 110 | public function get funcName():String 111 | { 112 | return _funcName; 113 | } 114 | 115 | /** 116 | * returns all arguments, if any, for the function. 117 | */ 118 | public function get inputs():Array 119 | { 120 | return _inputs; 121 | } 122 | 123 | public static function getObject($str:String):Object 124 | { 125 | var finalObject:Object = {}; 126 | var objMatchArray:Array = $str.match(DynamicFunc.OBJECT_PATTERN); 127 | for (var k:int = 0; k < objMatchArray.length; k++ ) 128 | { 129 | var eachPair:Array = objMatchArray[k].match(DynamicFunc.STRING_PATTERN_FOR_OBJECT); 130 | finalObject[eachPair[0]] = eachPair[1]; 131 | } 132 | 133 | return finalObject; 134 | } 135 | 136 | public static function getArray($str:String):Array 137 | { 138 | return $str.match(DynamicFunc.STRING_PATTERN); 139 | } 140 | 141 | public static function run($delegate:*, $stringFunc:String):void 142 | { 143 | var inputs:Array = []; 144 | 145 | var funcPattern:RegExp = /[\w_]+/; 146 | var valuePattern:RegExp = /\[?\{?((([\w_!.@\$\?%]+):?([\w_!.@\$\?%\s\/'-]+)?),?\s?)+\}?\]?/g; 147 | 148 | // save the function name in string 149 | var funcName:String = $stringFunc.match(funcPattern)[0]; 150 | 151 | // overwrite the raw string and remove the function name from the beggining 152 | $stringFunc = $stringFunc.replace(funcName, ""); 153 | 154 | // identify different kinds of inputs and save them in an array 155 | var rawValues:Array = $stringFunc.match(valuePattern); 156 | 157 | var curr:String; 158 | for (var i:int = 0; i < rawValues.length; i++ ) 159 | { 160 | curr = rawValues[i]; 161 | 162 | if (curr.charAt(0) == "[") 163 | { 164 | // save the input as an array 165 | inputs.push(curr.match(DynamicFunc.STRING_PATTERN)); 166 | } 167 | else if (curr.charAt(0) == "{") 168 | { 169 | // save the input as an object 170 | var finalObject:Object = {}; 171 | var objMatchArray:Array = curr.match(DynamicFunc.OBJECT_PATTERN); 172 | 173 | for (var k:int = 0; k < objMatchArray.length; k++ ) 174 | { 175 | var eachPair:Array = objMatchArray[k].match(DynamicFunc.STRING_PATTERN_FOR_OBJECT); 176 | finalObject[eachPair[0]] = eachPair[1]; 177 | } 178 | 179 | inputs.push(finalObject); 180 | } 181 | else 182 | { 183 | // save the input as a string 184 | var curStringArr:Array = curr.match(DynamicFunc.STRING_PATTERN); 185 | for (var j:int = 0; j < curStringArr.length; j++ ) 186 | { 187 | if (curStringArr[j] == "true") 188 | { 189 | inputs.push(true); 190 | } 191 | else if (curStringArr[j] == "false") 192 | { 193 | inputs.push(false); 194 | } 195 | else 196 | { 197 | inputs.push(curStringArr[j]); 198 | } 199 | } 200 | } 201 | } 202 | 203 | $delegate[funcName].apply(null, inputs); 204 | } 205 | } 206 | 207 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/mobileProject/commonCpuSrc/DeviceInfo.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.mobileProject.commonCpuSrc 2 | { 3 | import flash.system.Capabilities; 4 | import flash.system.TouchscreenType; 5 | import flash.ui.Multitouch; 6 | import flash.ui.KeyboardType; 7 | import flash.ui.Keyboard; 8 | import flash.ui.Mouse; 9 | import flash.ui.MultitouchInputMode; 10 | 11 | import flash.sensors.Accelerometer; 12 | import flash.sensors.Geolocation; 13 | 14 | import flash.media.CameraUI; 15 | import flash.media.Camera; 16 | import flash.media.Microphone; 17 | import flash.media.StageWebView; 18 | 19 | 20 | /** 21 | * ... 22 | * @author Hadi Tavakoli - 3/3/2012 6:38 PM 23 | */ 24 | public class DeviceInfo 25 | { 26 | public static const LDPI:String = "ldpi"; 27 | public static const MDPI:String = "mdpi"; 28 | public static const HDPI:String = "hdpi"; 29 | public static const XHDPI:String = "xhdpi"; 30 | 31 | public function DeviceInfo():void 32 | { 33 | 34 | } 35 | 36 | // ----------------------------------------------------------------------------------------------------------------------- Privates 37 | 38 | 39 | 40 | // ----------------------------------------------------------------------------------------------------------------------- Methods 41 | 42 | 43 | 44 | // ----------------------------------------------------------------------------------------------------------------------- Properties 45 | 46 | public static function get info():String 47 | { 48 | var info:String; 49 | 50 | info = "touchscreenType = " + DeviceInfo.touchscreenType + "\n"; 51 | info += "supportsCursor = " + DeviceInfo.supportsCursor + "\n"; 52 | info += "physicalKeyboardType = " + DeviceInfo.physicalKeyboardType + "\n"; 53 | info += "hasVirtualKeyboard = " + DeviceInfo.hasVirtualKeyboard + "\n"; 54 | info += "supportsGestureEvents = " + DeviceInfo.supportsGestureEvents + "\n"; 55 | info += "supportsTouchEvents = " + DeviceInfo.supportsTouchEvents + "\n"; 56 | info += "supportsGestures = " + DeviceInfo.supportsGestures + "\n"; 57 | info += "supportedGestures = " + DeviceInfo.supportedGestures + "\n"; 58 | info += "supportsAccelerometer = " + DeviceInfo.supportsAccelerometer + "\n"; 59 | info += "supportsGeolocation = " + DeviceInfo.supportsGeolocation + "\n"; 60 | info += "supportsCameraUI = " + DeviceInfo.supportsCameraUI + "\n"; 61 | info += "supportsCamera = " + DeviceInfo.supportsCamera + "\n"; 62 | info += "supportsMicrophone = " + DeviceInfo.supportsMicrophone + "\n"; 63 | info += "pixelAspectRatio = " + DeviceInfo.pixelAspectRatio + "\n"; 64 | info += "dpi = " + DeviceInfo.dpi + "\n"; 65 | info += "dpiCategory = " + DeviceInfo.dpiCategory + "\n"; 66 | info += "dpiScaleMultiplier = " + DeviceInfo.dpiScaleMultiplier + "\n"; 67 | info += "screenResolutionX = " + DeviceInfo.screenResolutionX + "\n"; 68 | info += "screenResolutionY = " + DeviceInfo.screenResolutionY + "\n"; 69 | info += "cpuArchitecture = " + DeviceInfo.cpuArchitecture + "\n"; 70 | info += "supportsStageWebView = " + DeviceInfo.supportsStageWebView + "\n"; 71 | 72 | return info; 73 | } 74 | 75 | 76 | 77 | public static function get touchscreenType():String 78 | { 79 | return Capabilities.touchscreenType; 80 | } 81 | 82 | public static function get supportsCursor():Boolean 83 | { 84 | return Mouse.supportsCursor; 85 | } 86 | 87 | public static function get physicalKeyboardType():String 88 | { 89 | return Keyboard.physicalKeyboardType; 90 | } 91 | 92 | public static function get hasVirtualKeyboard():Boolean 93 | { 94 | return Keyboard.hasVirtualKeyboard; 95 | } 96 | 97 | public static function get supportsGestureEvents():Boolean 98 | { 99 | return Multitouch.supportsGestureEvents; 100 | } 101 | 102 | public static function get supportsTouchEvents():Boolean 103 | { 104 | return Multitouch.supportsTouchEvents; 105 | } 106 | 107 | public static function get supportsGestures():Boolean 108 | { 109 | Multitouch.inputMode = MultitouchInputMode.GESTURE; 110 | if (Multitouch.supportedGestures) return true; 111 | 112 | return false; 113 | } 114 | 115 | public static function get supportedGestures():Vector. 116 | { 117 | Multitouch.inputMode = MultitouchInputMode.GESTURE; 118 | if (Multitouch.supportedGestures) return Multitouch.supportedGestures; 119 | 120 | return null; 121 | } 122 | 123 | public static function get supportsAccelerometer():Boolean 124 | { 125 | return Accelerometer.isSupported; 126 | } 127 | 128 | public static function get supportsGeolocation():Boolean 129 | { 130 | return Geolocation.isSupported; 131 | } 132 | 133 | public static function get supportsCameraUI():Boolean 134 | { 135 | return CameraUI.isSupported; 136 | } 137 | 138 | public static function get supportsCamera():Boolean 139 | { 140 | return Camera.isSupported; 141 | } 142 | 143 | public static function get supportsMicrophone():Boolean 144 | { 145 | return Microphone.isSupported; 146 | } 147 | 148 | public static function get pixelAspectRatio():Number 149 | { 150 | return Capabilities.pixelAspectRatio; 151 | } 152 | 153 | public static function get dpi():Number 154 | { 155 | return Capabilities.screenDPI; 156 | } 157 | 158 | public static function get dpiCategory():String 159 | { 160 | var currDpi:Number = Capabilities.screenDPI; 161 | var currDpiCat:String = DeviceInfo.MDPI; 162 | 163 | if (currDpi <= 140) 164 | { 165 | currDpiCat = DeviceInfo.LDPI; 166 | } 167 | else if (currDpi > 140 && currDpi <= 200) 168 | { 169 | currDpiCat = DeviceInfo.MDPI; 170 | } 171 | else if (currDpi > 200 && currDpi <= 280) 172 | { 173 | currDpiCat = DeviceInfo.HDPI; 174 | } 175 | else if (currDpi > 280) 176 | { 177 | currDpiCat = DeviceInfo.XHDPI; 178 | } 179 | 180 | return currDpiCat; 181 | } 182 | 183 | public static function get dpiScaleMultiplier():Number 184 | { 185 | var currDpi:Number = Capabilities.screenDPI; 186 | var multiplier:Number = 1; 187 | 188 | if (currDpi <= 140) 189 | { 190 | multiplier = 0.75; 191 | } 192 | else if (currDpi > 140 && currDpi <= 200) 193 | { 194 | multiplier = 1; 195 | } 196 | else if (currDpi > 200 && currDpi <= 280) 197 | { 198 | multiplier = 1.5; 199 | } 200 | else if (currDpi > 280) 201 | { 202 | multiplier = 2; 203 | } 204 | 205 | return multiplier; 206 | } 207 | 208 | public static function get screenResolutionX():Number 209 | { 210 | return Capabilities.screenResolutionX; 211 | } 212 | 213 | public static function get screenResolutionY():Number 214 | { 215 | return Capabilities.screenResolutionY; 216 | } 217 | 218 | public static function get cpuArchitecture():String 219 | { 220 | return Capabilities.cpuArchitecture; 221 | } 222 | 223 | public static function get supportsStageWebView():Boolean 224 | { 225 | return StageWebView.isSupported; 226 | } 227 | 228 | public static function get stageWebView():Class 229 | { 230 | return StageWebView; 231 | } 232 | } 233 | 234 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/utils/thread/Thread.as: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * @author Lu Aye Oo 4 | * 5 | * Thread. 6 | * 7 | * *What is it?*: 8 | * 9 | * Flash runs in a single thread. Which means if you execute an intensive script, 10 | * flash would lag/un-respond until your script finishes. 11 | * You would want to spread the process over a number of frames to avoid this lag. 12 | * 13 | * This class allows you to call a function over and over again while keeping the frameRate 14 | * and interface response fairly stable and also avoid falling into script timeout. 15 | * 16 | * 17 | * *Example use*: 18 | * 19 | * I used this for 'path finding' which can take between 10ms to 1000ms (depending on map size). 20 | * I don't want user to lag out everytime they choose a path. 21 | * instead I trade it off by taking 1-10 frames for path to be found. 22 | * 23 | * In an arcade style game, I needed to pre render the background + static objects into tiled bitmaps 24 | * Some long levels takes quite a long time to render so using Thread lets me spread the process and 25 | * have a smoother 'building' screen animation (rather than a stucked/lagged screen). 26 | * 27 | * 28 | * *When you shouldn't use*: 29 | * - If you want the outcome of the process straight away, this will not always delivery - 30 | * because it will spread your function calls over a number of frames if needed. 31 | * 32 | * 33 | * *To be careful*: 34 | * - This class DOES NOT stop the function from excuting half way through. 35 | * It only spreads the time between each function call (when needed). 36 | * - If your process is not only a 'loop' you could make a function that manage the sequence 37 | * in which it should excute by looking at 'steps' to know which step of thread you are on. 38 | * - You can call multiple Threads to execute at the same time - However each thread does not share 39 | * 'givenTime' with others so you will need to manage it for better processing spread. 40 | * 41 | * 42 | * *Example Code*: 43 | * 44 | * Example below is using Thread to increament an integer 'n' up to 500,000 45 | * giving 20 ms per frame to excute (it let go a frame when 20ms is passed). 46 | * Change countUpTo var if you are getting 1-2 frames/threadStep - your machine must be fast then! 47 | * 48 | 49 | import com.luaye.utils.thread.Thread; 50 | 51 | var countUpTo:int = 500000; 52 | var traceEvery:int = 20000; 53 | 54 | new Thread(stepFun, {n:0}, false, 20); 55 | 56 | function stepFun(thread:Thread):void{ 57 | var vars:Object = thread.vars; 58 | vars.n++; 59 | if(vars.n%traceEvery == 0){ 60 | trace("n = ", vars.n, ", threadStep = ", thread.threadSteps); 61 | } 62 | if(vars.n >= countUpTo){ 63 | // need to call end() to stop executing. 64 | thread.end(); 65 | trace("Ended process after "+thread.threadSteps+" frames/threadSteps"); 66 | } 67 | } 68 | 69 | * 70 | */ 71 | 72 | package com.luaye.utils.thread { 73 | import flash.display.Shape; 74 | import flash.events.Event; 75 | import flash.utils.getTimer; 76 | 77 | 78 | public class Thread { 79 | 80 | private static var _Threads:Array = []; 81 | // this is used to store the refernce to all threads (unless it was chosen to be 'weak') 82 | // Because threads without any reference elsewhere can get garbage collected before finishing. 83 | 84 | 85 | private var _maxTime:uint = 10; 86 | private var _steps:uint; 87 | private var _threadSteps:uint; 88 | private var _step:Function; 89 | private var _excuting:Boolean; 90 | private var _weak:Boolean; 91 | // uses Shape's enterFrame event to know the ticks... don't know other way - Timer doesnt work as good as this way... 92 | // Shape is more lightweight than Sprite, etc, I THINK 93 | private var _ticker:Shape; 94 | // 95 | 96 | public var vars:Object; 97 | 98 | 99 | /* 100 | * stepFun: Step function. example: function threadStep(thread:Thread):void {...} 101 | * vars: variables to keep with thread (optional) 102 | * m: manual control? if true, you need to call step() to execute each frame/step 103 | * maxt: maximum time given per step 104 | * weak: if true it can get garbage collected before function end unless you keep the Thread's reference. 105 | * (it is better practice to make it weak and keep the thread's reference in your code to prevent from 106 | * being garbage collected. This way, if the code that keeps the thread is garbage collected, the thread 107 | * will also go with it - rather than it keep holding on till it end for nothing. 108 | */ 109 | public function Thread(stepFun:Function, vrs:Object = null, m:Boolean = false, maxt:uint = 20, weak:Boolean = false){ 110 | if(stepFun == null){ 111 | throw new Error("Thread: step Function can not be null"); 112 | } 113 | _step = stepFun; 114 | vars = vrs; 115 | maxTime = maxt; 116 | manual = m; 117 | // 118 | _weak = weak; 119 | if(!weak){ 120 | _Threads.push(this); 121 | } 122 | } 123 | 124 | /* 125 | * Excute thread step 126 | * You can manually call this to force run the excutition. 127 | * You can not exactly control how many times you want to call your step function 128 | * It will keep calling till it run out of your 'givenTime' OR 'maxTime' OR when 'thread.end()' 129 | * leave param blank (or 0) to use default time. 130 | * 131 | */ 132 | public function step(givenTime:uint = 0):int{ 133 | if(_excuting || _step == null) return -1; 134 | if(givenTime == 0) givenTime = _maxTime; 135 | _excuting = true; 136 | _threadSteps++; 137 | var st:uint = getTimer(); 138 | var tt:uint = 0; 139 | do{ 140 | _steps++; 141 | try{ 142 | _step(this); 143 | } catch(e:Error){ 144 | throw new Error("Thread: There was a problem running the step function at step "+_step); 145 | } 146 | tt = getTimer()-st; 147 | }while(_step != null && tt < givenTime); 148 | _excuting = false; 149 | return tt; 150 | } 151 | /* 152 | * End excution 153 | * You need to call this when you no longer want to run the thread 154 | * This also cleans up it self so calling '.vars' OR '.step()' after ending will fail. 155 | */ 156 | public function end():void{ 157 | manual = true; 158 | vars = null; 159 | if(_step != null){ 160 | _step = null; 161 | if(!_weak){ 162 | var ind:int = _Threads.indexOf(this); 163 | if(ind>=0){ 164 | _Threads.splice(ind,1); 165 | } 166 | } 167 | } 168 | } 169 | public function get excuting():Boolean{ 170 | return _excuting; 171 | } 172 | // how many times it has called step() function 173 | public function get steps():uint{ 174 | return _steps; 175 | } 176 | // how many thread frames/steps it has passed 177 | public function get threadSteps():uint{ 178 | return _threadSteps; 179 | } 180 | public function get ended():Boolean{ 181 | return _step == null; 182 | } 183 | public function get weak():Boolean{ 184 | return _weak; 185 | } 186 | public function get maxTime():uint{ 187 | return _maxTime; 188 | } 189 | public function set maxTime(n:uint):void{ 190 | _maxTime = n<1?1:n; 191 | } 192 | // 193 | // Once set to manual, you have to call step() to excute manually 194 | public function set manual(b:Boolean):void{ 195 | if(b && _ticker){ 196 | _ticker.removeEventListener(Event.ENTER_FRAME, onTick); 197 | _ticker = null; 198 | }else if(!b && !_ticker){ 199 | _ticker = new Shape(); 200 | _ticker.addEventListener(Event.ENTER_FRAME, onTick, false, 0, true); 201 | } 202 | } 203 | public function get manual():Boolean{ 204 | return (_ticker==null); 205 | } 206 | 207 | 208 | private function onTick(e:Event):void{ 209 | step(); 210 | } 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/utils/bitmapMovieClip/BitmapMovieClip.as: -------------------------------------------------------------------------------- 1 | /** 2 | * @author Lu Aye Oo | www.luaye.com 3 | * 4 | * BitmapMovieClip. 5 | * 6 | * What is it?: 7 | * This class is essencially a Bitmap class that can hold sequence of BitmapData; 8 | * 9 | * Imagine you have a lot (say 100s) of non-interactive movieclip that have the same animation 10 | * (but not necerrially all show the same frame at the same time). 11 | * If you make new movieClips to accompany all clips it will be very slow to render the vectors 12 | * every frame... 13 | * with BitmapMovieClip, it caches all the frames in the movieclip in an array of BitmapData and 14 | * use the same bitmapData across all instances. Therefore it only need to store a sequence of 15 | * BitmapData for an animation and get reused. 16 | * 17 | * Advantages: 18 | * - Doesnt have to duplicate bitmaps for the number of movieclips you need. 19 | * - Very fast as it doesn't need to render vectors. 20 | * - It got most functionality (and more) of MovieClip, such as play()/stop()/gotoAndPlay() 21 | * - support labels 22 | * 23 | * When you shouldn't use: 24 | * - If your movieclip have simple vectors. There is no point to turn them into bitmapsData. 25 | * - If there is only 1 frame in movieclip, just use Bitmap class. 26 | * - Highly nested movieClips may not work as intended. 27 | * - Scaling will pixelate, you can pre scale before generating the clip tho. 28 | * 29 | * To be careful: 30 | * If you make changes to the bitmapData of a frame in the sequence, it will update in all clips. 31 | * 32 | * Example: 33 | import com.luaye.utils.bitmapMovieClip.*; 34 | 35 | var srcMC:MovieClip = new myClipFromLibrary(); 36 | 37 | var clipData:BitmapMovieClipData = BitmapMovieClip.generate(srcMC, 150, 150); 38 | 39 | var mc:BitmapMovieClip = new BitmapMovieClip(clipData); 40 | addChild(mc); 41 | 42 | mc = new BitmapMovieClip(clipData); 43 | mc.x = 150; 44 | mc.loop = true; 45 | addChild(mc); 46 | 47 | mc = new BitmapMovieClip(clipData); 48 | mc.x = 300; 49 | mc.play(3,10); 50 | addChild(mc); 51 | * 52 | */ 53 | 54 | package com.luaye.utils.bitmapMovieClip { 55 | import flash.geom.Rectangle; 56 | import flash.geom.Matrix; 57 | import flash.display.*; 58 | import flash.events.Event; 59 | 60 | public class BitmapMovieClip extends Bitmap { 61 | 62 | // If you want to know when movieclip reached end 63 | public static const ENDED:String = "reachedEnd"; 64 | 65 | private var _data:BitmapMovieClipData; 66 | private var _lastFrame:int = -1; 67 | private var _currentFrame:int = 0; 68 | private var _playing:Boolean = true; 69 | private var _manualUpdate:Boolean; 70 | 71 | // 72 | // 73 | // 74 | public var playingTo:int = 0; // playhead will stop on hitting this number, 0 = no stopping. 75 | public var useClone:Boolean; // if turned on, it will clone the BitmapData from original before updating 76 | public var loop:Boolean; // loop OR play once. 77 | 78 | 79 | // 80 | // This generates the BitmapMovieClipData required to run BitmapMovieClip 81 | // It captures all frames from the movieClip you pass in. 82 | // You may need to pass in matrix with x and y if your source clip's origin is not at the top left. 83 | // Similar to params from BitmapData.draw(); 84 | // 85 | public static function generate(mc:MovieClip, w:int = 0, h:int = 0, matrix:Matrix = null, clipRect:Rectangle = null):BitmapMovieClipData { 86 | if (w<=0) { 87 | w = mc.width; 88 | } 89 | if (h<=0) { 90 | h = mc.height; 91 | } 92 | var frames:Array = new Array(); 93 | var len:int = mc.totalFrames; 94 | for (var i:int = 0; i < len; i++) { 95 | var bmd:BitmapData = new BitmapData(w, h, true, 0); 96 | bmd.draw(mc, matrix, null, null, clipRect, true); 97 | frames.push(bmd); 98 | mc.nextFrame(); 99 | } 100 | var labels:Object = new Object(); 101 | var currentLabels:Array = mc.currentLabels; 102 | for each(var label:FrameLabel in currentLabels){ 103 | labels[label.name] = label.frame; 104 | } 105 | var data:BitmapMovieClipData = new BitmapMovieClipData(frames, labels); 106 | return data; 107 | } 108 | public function BitmapMovieClip(data:BitmapMovieClipData = null,clone:Boolean = false) { 109 | if (data) { 110 | setSource(data, clone); 111 | } else { 112 | _data = new BitmapMovieClipData([]); 113 | } 114 | } 115 | // 116 | // 117 | // Incase you want to change source BitmapMovieClipData on the fly. 118 | // 119 | public function setSource(data:BitmapMovieClipData,clone:Boolean = true):void { 120 | 121 | var frames:Array = data.frames; 122 | if (!frames || frames.length==0) { 123 | throw new Error("Requires an array of bitmaps to start BitmapMovieClip. Use BitmapMovieClip.generate(MovieClip) for ease of use."); 124 | } 125 | useClone = clone; 126 | _data = data; 127 | _lastFrame = -1; 128 | _currentFrame = _playing?-1:0; 129 | update(); 130 | if(_playing){ 131 | startUpdating(); 132 | } 133 | } 134 | public function getSource():BitmapMovieClipData { 135 | return _data; 136 | } 137 | public function get manualUpdate():Boolean{ 138 | return _manualUpdate; 139 | } 140 | // 141 | // If turned on, you need to call update() manually. 142 | // Which is useful for games and such where you need to sync frame rate. 143 | // 144 | public function set manualUpdate(b:Boolean):void{ 145 | if(_manualUpdate == b) return; 146 | _manualUpdate = b; 147 | if(b){ 148 | stopUpdating(); 149 | }else if(_playing){ 150 | startUpdating(); 151 | } 152 | } 153 | public function update(e:Event = null):void { 154 | if (_playing) { 155 | _currentFrame++; 156 | if (_currentFrame>=_data.frames.length) { 157 | if(loop){ 158 | _currentFrame = 0; 159 | }else{ 160 | _currentFrame--; 161 | dispatchEvent(new Event(ENDED)); 162 | stop(); 163 | return; 164 | } 165 | } 166 | } 167 | if (_currentFrame == (playingTo-1)) { 168 | _playing = false; 169 | playingTo = 0; 170 | stopUpdating(); 171 | } 172 | if (_lastFrame != _currentFrame) { 173 | if (useClone) { 174 | bitmapData = _data.frames[_currentFrame].clone(); 175 | } else { 176 | bitmapData = _data.frames[_currentFrame]; 177 | } 178 | _lastFrame = _currentFrame; 179 | } 180 | } 181 | private function startUpdating():void{ 182 | stopUpdating(); 183 | if(!_manualUpdate){ 184 | addEventListener(Event.ENTER_FRAME, update, false, 0 , true); 185 | } 186 | } 187 | private function stopUpdating():void{ 188 | removeEventListener(Event.ENTER_FRAME, update); 189 | } 190 | // label name or frame number 191 | public function play(frame:Object = 0, to:Object = 0):void { 192 | _playing = true; 193 | playingTo = getFrameFromLabel(to); 194 | var from:int = getFrameFromLabel(frame)-1; 195 | goto(from); 196 | startUpdating(); 197 | } 198 | // label name or frame number 199 | public function stop(frame:Object = 0):void { 200 | _playing = false; 201 | playingTo = 0; 202 | goto(getFrameFromLabel(frame)-1); 203 | stopUpdating(); 204 | update(); 205 | } 206 | public function get currentFrame():int { 207 | return _currentFrame - 1; 208 | } 209 | public function get totalFrames():int { 210 | return (_data&&_data.frames)?_data.frames.length:0; 211 | } 212 | public function get playing():Boolean { 213 | return _playing; 214 | } 215 | 216 | 217 | 218 | // 219 | private function goto(frame:int):void{ 220 | if (frame>=0) { 221 | var max:int = _data.frames.length-1; 222 | _currentFrame = frame>max?max:(frame<0?0:frame); 223 | } 224 | } 225 | // 226 | private function getFrameFromLabel(frame:Object = "0"):int{ 227 | var frameno:int = 0; 228 | if(isNaN(Number(frame))){ 229 | if(_data.labels[frame] != undefined){ 230 | frameno = _data.labels[frame]; 231 | } 232 | }else{ 233 | frameno = int(frame); 234 | } 235 | return frameno; 236 | } 237 | } 238 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/Ruler.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import com.luaye.console.Console; 27 | import com.luaye.console.utils.Utils; 28 | 29 | import flash.display.BlendMode; 30 | import flash.display.Shape; 31 | import flash.display.Sprite; 32 | import flash.events.Event; 33 | import flash.events.MouseEvent; 34 | import flash.geom.Point; 35 | import flash.geom.Rectangle; 36 | import flash.text.TextField; 37 | import flash.text.TextFieldAutoSize; 38 | import flash.text.TextFormat; 39 | import flash.text.TextFormatAlign; 40 | import flash.ui.Mouse; 41 | 42 | public class Ruler extends Sprite{ 43 | public static const EXIT:String = "exit"; 44 | private static const POINTER_DISTANCE:int = 12; 45 | 46 | private var _master:Console; 47 | private var _area:Rectangle; 48 | private var _pointer:Shape; 49 | 50 | private var _posTxt:TextField; 51 | 52 | private var _points:Array; 53 | 54 | public function Ruler() { 55 | 56 | } 57 | public function start(console:Console):void{ 58 | _master = console; 59 | buttonMode = true; 60 | _points = new Array(); 61 | _pointer = new Shape(); 62 | addChild(_pointer); 63 | var p:Point = new Point(); 64 | p = globalToLocal(p); 65 | _area = new Rectangle(-stage.stageWidth*1.5+p.x, -stage.stageHeight*1.5+p.y, stage.stageWidth*3, stage.stageHeight*3); 66 | graphics.beginFill(0x000000, 0.1); 67 | graphics.drawRect(_area.x, _area.y, _area.width, _area.height); 68 | graphics.endFill(); 69 | // 70 | _posTxt = new TextField(); 71 | _posTxt.name = "positionText"; 72 | _posTxt.autoSize = TextFieldAutoSize.LEFT; 73 | _posTxt.background = true; 74 | _posTxt.backgroundColor = _master.style.panelBackgroundColor; 75 | _posTxt.styleSheet = console.style.css; 76 | _posTxt.mouseEnabled = false; 77 | addChild(_posTxt); 78 | // 79 | addEventListener(MouseEvent.CLICK, onMouseClick, false, 0, true); 80 | addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove, false, 0, true); 81 | onMouseMove(); 82 | if(_master.rulerHidesMouse) Mouse.hide(); 83 | _master.report("Ruler started. Click on two locations to measure.", -1); 84 | } 85 | private function onMouseMove(e:MouseEvent = null):void{ 86 | _pointer.graphics.clear(); 87 | _pointer.graphics.lineStyle(1, 0xAACC00, 1); 88 | _pointer.graphics.moveTo(_area.x, mouseY); 89 | _pointer.graphics.lineTo(_area.x+_area.width, mouseY); 90 | _pointer.graphics.moveTo(mouseX, _area.y); 91 | _pointer.graphics.lineTo(mouseX, _area.y+_area.height); 92 | _pointer.blendMode = BlendMode.INVERT; 93 | _posTxt.text = ""+mouseX+","+mouseY+""; 94 | // 95 | _posTxt.x = mouseX-_posTxt.width-POINTER_DISTANCE; 96 | _posTxt.y = mouseY-_posTxt.height-POINTER_DISTANCE; 97 | if(_posTxt.x < 0){ 98 | _posTxt.x = mouseX+POINTER_DISTANCE; 99 | } 100 | if(_posTxt.y < 0){ 101 | _posTxt.y = mouseY+POINTER_DISTANCE; 102 | } 103 | } 104 | private function onMouseClick(e:MouseEvent):void{ 105 | e.stopPropagation(); 106 | var p:Point; 107 | if(_points.length==0){ 108 | p = new Point(e.localX, e.localY); 109 | graphics.lineStyle(1, 0xFF0000); 110 | graphics.drawCircle(p.x, p.y, 3); 111 | _points.push(p); 112 | }else if(_points.length==1){ 113 | if(_master.rulerHidesMouse) Mouse.show(); 114 | removeChild(_pointer); 115 | removeChild(_posTxt); 116 | removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); 117 | p = _points[0]; 118 | var p2:Point = new Point(e.localX, e.localY); 119 | _points.push(p2); 120 | graphics.clear(); 121 | graphics.beginFill(0x000000, 0.4); 122 | graphics.drawRect(_area.x, _area.y, _area.width, _area.height); 123 | graphics.endFill(); 124 | graphics.lineStyle(1.5, 0xFF0000); 125 | graphics.drawCircle(p.x, p.y, 4); 126 | graphics.lineStyle(1.5, 0xFF9900); 127 | graphics.drawCircle(p2.x, p2.y, 4); 128 | var mp:Point = Point.interpolate(p, p2, 0.5); 129 | graphics.lineStyle(1, 0xAAAAAA); 130 | graphics.drawCircle(mp.x, mp.y, 4); 131 | // 132 | var xmin:Point = p; 133 | var xmax:Point = p2; 134 | if(p.x>p2.x){ 135 | xmin = p2; 136 | xmax = p; 137 | } 138 | var ymin:Point = p; 139 | var ymax:Point = p2; 140 | if(p.y>p2.y){ 141 | ymin = p2; 142 | ymax = p; 143 | } 144 | // 145 | var w:Number = xmax.x-xmin.x; 146 | var h:Number = ymax.y-ymin.y; 147 | var d:Number = Point.distance(p, p2); 148 | // 149 | var txt:TextField = makeTxtField(); 150 | txt.text = Utils.round(p.x,10)+","+ Utils.round(p.y,10); 151 | txt.x = p.x; 152 | txt.y = p.y-(ymin==p?14:0); 153 | addChild(txt); 154 | // 155 | txt = makeTxtField(); 156 | txt.text = Utils.round(p2.x,10)+","+ Utils.round(p2.y,10); 157 | txt.x = p2.x; 158 | txt.y = p2.y-(ymin==p2?14:0);; 159 | addChild(txt); 160 | // 161 | if(w>40 || h>25){ 162 | txt = makeTxtField(0x00AA00); 163 | txt.text = Utils.round(mp.x,10)+","+ Utils.round(mp.y,10); 164 | txt.x = mp.x; 165 | txt.y = mp.y; 166 | addChild(txt); 167 | /* 168 | txt = makeTxtField(0x00AA00, false); 169 | txt.text = xmin.x+","+ ymin.y; 170 | txt.x = xmin.x; 171 | txt.y = (xmin.y==ymin.y)?ymax.y:(ymin.y-14); 172 | addChild(txt); 173 | // 174 | txt = makeTxtField(0x00AA00, false); 175 | txt.text = xmax.x+","+ ymax.y; 176 | txt.x = xmax.x; 177 | txt.y = (xmax.y==ymax.y)?(ymin.y-14):ymax.y; 178 | addChild(txt); 179 | */ 180 | } 181 | // 182 | graphics.lineStyle(1, 0xAACC00, 0.5); 183 | graphics.moveTo(_area.x, ymin.y); 184 | graphics.lineTo(_area.x+_area.width, ymin.y); 185 | graphics.moveTo(_area.x, ymax.y); 186 | graphics.lineTo(_area.x+_area.width, ymax.y); 187 | graphics.moveTo(xmin.x, _area.y); 188 | graphics.lineTo(xmin.x, _area.y+_area.height); 189 | graphics.moveTo(xmax.x, _area.y); 190 | graphics.lineTo(xmax.x, _area.y+_area.height); 191 | // 192 | var a1:Number = Utils.round(Utils.angle(p,p2),100); 193 | var a2:Number = Utils.round(Utils.angle(p2,p),100); 194 | graphics.lineStyle(1, 0xAA0000, 0.8); 195 | Utils.drawCircleSegment(graphics, 10,p, a1, -90); 196 | graphics.lineStyle(1, 0xCC8800, 0.8); 197 | Utils.drawCircleSegment(graphics, 10,p2, a2, -90); 198 | // 199 | graphics.lineStyle(2, 0x00FF00, 0.7); 200 | graphics.moveTo(p.x, p.y); 201 | graphics.lineTo(p2.x, p2.y); 202 | // 203 | _master.report("Ruler results: (red) ["+p.x+","+p.y+"] to (orange) ["+p2.x+","+p2.y+"]", -2); 204 | _master.report("Distance: "+Utils.round(d,100) +"", -2); 205 | _master.report("Mid point: ["+mp.x+","+mp.y+"]", -2); 206 | _master.report("Width:"+w+", Height: "+h+"", -2); 207 | _master.report("Angle from first point (red): "+a1+"°", -2); 208 | _master.report("Angle from second point (orange): "+a2+"°", -2); 209 | }else{ 210 | exit(); 211 | } 212 | } 213 | public function exit():void{ 214 | _points = null; 215 | _master = null; 216 | dispatchEvent(new Event(EXIT)); 217 | } 218 | private function makeTxtField(col:Number = 0x00FF00, b:Boolean = true):TextField{ 219 | var format:TextFormat = new TextFormat("Arial", 11, col, b, true, null, null, TextFormatAlign.RIGHT); 220 | var txt:TextField = new TextField(); 221 | txt.autoSize = TextFieldAutoSize.RIGHT; 222 | txt.selectable = false; 223 | txt.defaultTextFormat = format; 224 | return txt; 225 | } 226 | } 227 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/text/modules/MyMovieClip.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.text.modules 2 | { 3 | import flash.display.Shape; 4 | import flash.display.MovieClip; 5 | 6 | /** 7 | * ... 8 | * 9 | * @author Hadi Tavakoli - 3/28/2011 3:21 PM 10 | */ 11 | public class MyMovieClip extends MovieClip 12 | { 13 | protected var _width:Number = 0; 14 | protected var _height:Number = 0; 15 | protected var _margin:Number = 0; 16 | protected var _marginX:Number = 0; 17 | protected var _marginY:Number = 0; 18 | 19 | protected var _embedFonts:Boolean; 20 | protected var _configXml:XML; 21 | protected var _xml:XML; 22 | protected var _data:Object = {}; 23 | protected var _id:int; 24 | 25 | protected var _base:Object; 26 | protected var _canvas:*; 27 | protected var _holder:Object; 28 | 29 | protected var _bg:Shape; 30 | protected var _bgColor:uint = 0x000000; 31 | protected var _bgAlpha:Number = 0; 32 | protected var _bgStrokeColor:uint = 0x990000; 33 | protected var _bgStrokeThickness:Number = 0; 34 | protected var _bgStrokeAlpha:Number = 0; 35 | protected var _bgTopLeftRadius:Number = 0; 36 | protected var _bgTopRightRadius:Number = 0; 37 | protected var _bgBottomLeftRadius:Number = 0; 38 | protected var _bgBottomRightRadius:Number = 0; 39 | 40 | protected var _serverPath:String = ""; 41 | protected var _flashVars:Object; 42 | 43 | private var _listenersArr:Array = []; 44 | 45 | public function MyMovieClip():void 46 | { 47 | 48 | } 49 | 50 | protected function onResize(e:*=null):void 51 | { 52 | if (_bg) drawBg(); 53 | } 54 | 55 | public function drawBg():void 56 | { 57 | if (!_bg) 58 | { 59 | _bg = new Shape(); 60 | this.addChildAt(_bg, 0); 61 | } 62 | 63 | _bg.graphics.clear(); 64 | _bg.graphics.beginFill(_bgColor, _bgAlpha); 65 | _bg.graphics.lineStyle(_bgStrokeThickness, _bgStrokeColor, _bgStrokeAlpha); 66 | _bg.graphics.drawRoundRectComplex(0, 0, _width, _height, _bgTopLeftRadius, _bgTopRightRadius, _bgBottomLeftRadius, _bgBottomRightRadius); 67 | _bg.graphics.endFill(); 68 | } 69 | 70 | protected function toBoolean(a:String):Boolean 71 | { 72 | if (a == "true") return true; 73 | 74 | return false; 75 | } 76 | 77 | protected function cleanUp($target:*, $freeMemory:Boolean = false):void 78 | { 79 | $target.graphics.clear(); 80 | 81 | for (var i:int = $target.numChildren-1; i >= 0; i--) 82 | { 83 | var child:* = $target.getChildAt(i); 84 | 85 | $target.removeChild(child); 86 | if ($freeMemory) child = null; 87 | } 88 | } 89 | 90 | public function clearEvents():void 91 | { 92 | if (!_listenersArr) return; 93 | 94 | for (var i:int = 0; i < _listenersArr.length; i++) 95 | { 96 | if (this.hasEventListener(_listenersArr[i].type)) 97 | { 98 | this.removeEventListener(_listenersArr[i].type, _listenersArr[i].listener); 99 | } 100 | } 101 | 102 | _listenersArr = null 103 | } 104 | 105 | override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void 106 | { 107 | super.addEventListener(type, listener, useCapture, priority, useWeakReference); 108 | _listenersArr.push({type:type, listener:listener}); 109 | } 110 | 111 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 112 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Getter - Setter 113 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 114 | 115 | public function get base():Object 116 | { 117 | return _base; 118 | } 119 | 120 | public function set base(a:Object):void 121 | { 122 | _base = a; 123 | } 124 | 125 | public function get canvas():Object 126 | { 127 | return _canvas; 128 | } 129 | 130 | public function set canvas(a:Object):void 131 | { 132 | _canvas = a; 133 | } 134 | 135 | public function get holder():Object 136 | { 137 | return _holder; 138 | } 139 | 140 | public function set holder(a:Object):void 141 | { 142 | _holder = a; 143 | } 144 | 145 | override public function get width():Number 146 | { 147 | return _width; 148 | } 149 | 150 | override public function set width(a:Number):void 151 | { 152 | if (_width != a) 153 | { 154 | _width = a; 155 | onResize(); 156 | } 157 | } 158 | 159 | override public function get height():Number 160 | { 161 | return _height; 162 | } 163 | 164 | override public function set height(a:Number):void 165 | { 166 | if (_height != a) 167 | { 168 | _height = a; 169 | onResize(); 170 | } 171 | } 172 | 173 | public function get margin():Number 174 | { 175 | return _margin; 176 | } 177 | 178 | public function set margin(a:Number):void 179 | { 180 | _margin = a; 181 | } 182 | 183 | public function get marginX():Number 184 | { 185 | return _marginX; 186 | } 187 | 188 | public function set marginX(a:Number):void 189 | { 190 | _marginX = a; 191 | } 192 | 193 | public function get marginY():Number 194 | { 195 | return _marginY; 196 | } 197 | 198 | public function set marginY(a:Number):void 199 | { 200 | _marginY = a; 201 | } 202 | 203 | public function get embedFonts():Boolean 204 | { 205 | return _embedFonts; 206 | } 207 | 208 | public function set embedFonts(a:Boolean):void 209 | { 210 | _embedFonts = a; 211 | } 212 | 213 | public function get configXml():XML 214 | { 215 | return _configXml; 216 | } 217 | 218 | public function set configXml(a:XML):void 219 | { 220 | _configXml = a; 221 | } 222 | 223 | public function get xml():XML 224 | { 225 | return _xml; 226 | } 227 | 228 | public function set xml(a:XML):void 229 | { 230 | _xml = a; 231 | } 232 | 233 | public function get data():Object 234 | { 235 | return _data; 236 | } 237 | 238 | public function set data(a:Object):void 239 | { 240 | _data = a; 241 | } 242 | 243 | public function get id():int 244 | { 245 | return _id; 246 | } 247 | 248 | public function set id(a:int):void 249 | { 250 | _id = a; 251 | } 252 | 253 | public function get bgAlpha():Number 254 | { 255 | return _bgAlpha; 256 | } 257 | 258 | public function set bgAlpha(a:Number):void 259 | { 260 | _bgAlpha = a; 261 | } 262 | 263 | public function get bgStrokeAlpha():Number 264 | { 265 | return _bgStrokeAlpha; 266 | } 267 | 268 | public function set bgStrokeAlpha(a:Number):void 269 | { 270 | _bgStrokeAlpha = a; 271 | } 272 | 273 | public function get bgStrokeThickness():Number 274 | { 275 | return _bgStrokeThickness; 276 | } 277 | 278 | public function set bgStrokeThickness(a:Number):void 279 | { 280 | _bgStrokeThickness = a; 281 | } 282 | 283 | public function get bgColor():uint 284 | { 285 | return _bgColor; 286 | } 287 | 288 | public function set bgColor(a:uint):void 289 | { 290 | _bgColor = a; 291 | } 292 | 293 | public function get bgStrokeColor():uint 294 | { 295 | return _bgStrokeColor; 296 | } 297 | 298 | public function set bgStrokeColor(a:uint):void 299 | { 300 | _bgStrokeColor = a; 301 | } 302 | 303 | public function get bgTopLeftRadius():Number 304 | { 305 | return _bgTopLeftRadius; 306 | } 307 | 308 | public function set bgTopLeftRadius(a:Number):void 309 | { 310 | _bgTopLeftRadius = a; 311 | } 312 | 313 | public function get bgTopRightRadius():Number 314 | { 315 | return _bgTopRightRadius; 316 | } 317 | 318 | public function set bgTopRightRadius(a:Number):void 319 | { 320 | _bgTopRightRadius = a; 321 | } 322 | 323 | public function get bgBottomLeftRadius():Number 324 | { 325 | return _bgBottomLeftRadius; 326 | } 327 | 328 | public function set bgBottomLeftRadius(a:Number):void 329 | { 330 | _bgBottomLeftRadius = a; 331 | } 332 | 333 | public function get bgBottomRightRadius():Number 334 | { 335 | return _bgBottomRightRadius; 336 | } 337 | 338 | public function set bgBottomRightRadius(a:Number):void 339 | { 340 | _bgBottomRightRadius = a; 341 | } 342 | 343 | public function get serverPath():String 344 | { 345 | return _serverPath; 346 | } 347 | 348 | public function set serverPath(a:String):void 349 | { 350 | _serverPath = a; 351 | } 352 | 353 | public function get flashVars():Object 354 | { 355 | return _flashVars; 356 | } 357 | 358 | public function set flashVars(a:Object):void 359 | { 360 | _flashVars = a; 361 | } 362 | } 363 | 364 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/text/modules/MySprite.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.text.modules 2 | { 3 | import flash.display.Shape; 4 | import flash.display.Sprite; 5 | 6 | /** 7 | * ... 8 | * 9 | * @author Hadi Tavakoli - 3/28/2011 3:21 PM 10 | */ 11 | public class MySprite extends Sprite 12 | { 13 | protected var _width:Number = 0; 14 | protected var _height:Number = 0; 15 | protected var _margin:Number = 0; 16 | protected var _marginX:Number = 0; 17 | protected var _marginY:Number = 0; 18 | 19 | protected var _embedFonts:Boolean; 20 | protected var _configXml:XML; 21 | protected var _xml:XML; 22 | protected var _data:Object = {}; 23 | protected var _id:int; 24 | 25 | protected var _base:Object; 26 | protected var _canvas:*; 27 | protected var _holder:Object; 28 | 29 | protected var _bg:Shape; 30 | protected var _bgColor:uint = 0x000000; 31 | protected var _bgAlpha:Number = 0; 32 | protected var _bgStrokeColor:uint = 0x990000; 33 | protected var _bgStrokeThickness:Number = 0; 34 | protected var _bgStrokeAlpha:Number = 0; 35 | protected var _bgTopLeftRadius:Number = 0; 36 | protected var _bgTopRightRadius:Number = 0; 37 | protected var _bgBottomLeftRadius:Number = 0; 38 | protected var _bgBottomRightRadius:Number = 0; 39 | 40 | protected var _serverPath:String = ""; 41 | protected var _flashVars:Object; 42 | 43 | private var _listenersArr:Array = []; 44 | 45 | public function MySprite():void 46 | { 47 | 48 | } 49 | 50 | protected function onResize(e:*=null):void 51 | { 52 | if (_bg) drawBg(); 53 | } 54 | 55 | public function drawBg():void 56 | { 57 | if (!_bg) 58 | { 59 | _bg = new Shape(); 60 | this.addChildAt(_bg, 0); 61 | } 62 | 63 | _bg.graphics.clear(); 64 | _bg.graphics.beginFill(_bgColor, _bgAlpha); 65 | _bg.graphics.lineStyle(_bgStrokeThickness, _bgStrokeColor, _bgStrokeAlpha, true); 66 | _bg.graphics.drawRoundRectComplex(0, 0, _width, _height, _bgTopLeftRadius, _bgTopRightRadius, _bgBottomLeftRadius, _bgBottomRightRadius); 67 | _bg.graphics.endFill(); 68 | } 69 | 70 | protected function toBoolean(a:String):Boolean 71 | { 72 | if (a == "true") return true; 73 | 74 | return false; 75 | } 76 | 77 | protected function cleanUp($target:*, $freeMemory:Boolean = false):void 78 | { 79 | $target.graphics.clear(); 80 | 81 | for (var i:int = $target.numChildren-1; i >= 0; i--) 82 | { 83 | var child:* = $target.getChildAt(i); 84 | 85 | $target.removeChild(child); 86 | if ($freeMemory) child = null; 87 | } 88 | } 89 | 90 | public function clearEvents():void 91 | { 92 | if (!_listenersArr) return; 93 | 94 | for (var i:int = 0; i < _listenersArr.length; i++) 95 | { 96 | if (this.hasEventListener(_listenersArr[i].type)) 97 | { 98 | this.removeEventListener(_listenersArr[i].type, _listenersArr[i].listener); 99 | } 100 | } 101 | 102 | _listenersArr = null 103 | } 104 | 105 | override public function addEventListener(type:String, listener:Function, useCapture:Boolean=false, priority:int=0, useWeakReference:Boolean=false):void 106 | { 107 | super.addEventListener(type, listener, useCapture, priority, useWeakReference); 108 | _listenersArr.push({type:type, listener:listener}); 109 | } 110 | 111 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 112 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Getter - Setter 113 | /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 114 | 115 | public function get base():Object 116 | { 117 | return _base; 118 | } 119 | 120 | public function set base(a:Object):void 121 | { 122 | _base = a; 123 | } 124 | 125 | public function get canvas():Object 126 | { 127 | return _canvas; 128 | } 129 | 130 | public function set canvas(a:Object):void 131 | { 132 | _canvas = a; 133 | } 134 | 135 | public function get holder():Object 136 | { 137 | return _holder; 138 | } 139 | 140 | public function set holder(a:Object):void 141 | { 142 | _holder = a; 143 | } 144 | 145 | override public function get width():Number 146 | { 147 | return _width; 148 | } 149 | 150 | override public function set width(a:Number):void 151 | { 152 | if (_width != a) 153 | { 154 | _width = a; 155 | onResize(); 156 | } 157 | } 158 | 159 | override public function get height():Number 160 | { 161 | return _height; 162 | } 163 | 164 | override public function set height(a:Number):void 165 | { 166 | if (_height != a) 167 | { 168 | _height = a; 169 | onResize(); 170 | } 171 | } 172 | 173 | public function get margin():Number 174 | { 175 | return _margin; 176 | } 177 | 178 | public function set margin(a:Number):void 179 | { 180 | _margin = a; 181 | } 182 | 183 | public function get marginX():Number 184 | { 185 | return _marginX; 186 | } 187 | 188 | public function set marginX(a:Number):void 189 | { 190 | _marginX = a; 191 | } 192 | 193 | public function get marginY():Number 194 | { 195 | return _marginY; 196 | } 197 | 198 | public function set marginY(a:Number):void 199 | { 200 | _marginY = a; 201 | } 202 | 203 | public function get embedFonts():Boolean 204 | { 205 | return _embedFonts; 206 | } 207 | 208 | public function set embedFonts(a:Boolean):void 209 | { 210 | _embedFonts = a; 211 | } 212 | 213 | public function get configXml():XML 214 | { 215 | return _configXml; 216 | } 217 | 218 | public function set configXml(a:XML):void 219 | { 220 | _configXml = a; 221 | } 222 | 223 | public function get xml():XML 224 | { 225 | return _xml; 226 | } 227 | 228 | public function set xml(a:XML):void 229 | { 230 | _xml = a; 231 | } 232 | 233 | public function get data():Object 234 | { 235 | return _data; 236 | } 237 | 238 | public function set data(a:Object):void 239 | { 240 | _data = a; 241 | } 242 | 243 | public function get id():int 244 | { 245 | return _id; 246 | } 247 | 248 | public function set id(a:int):void 249 | { 250 | _id = a; 251 | } 252 | 253 | public function get bgAlpha():Number 254 | { 255 | return _bgAlpha; 256 | } 257 | 258 | public function set bgAlpha(a:Number):void 259 | { 260 | _bgAlpha = a; 261 | } 262 | 263 | public function get bgStrokeAlpha():Number 264 | { 265 | return _bgStrokeAlpha; 266 | } 267 | 268 | public function set bgStrokeAlpha(a:Number):void 269 | { 270 | _bgStrokeAlpha = a; 271 | } 272 | 273 | public function get bgStrokeThickness():Number 274 | { 275 | return _bgStrokeThickness; 276 | } 277 | 278 | public function set bgStrokeThickness(a:Number):void 279 | { 280 | _bgStrokeThickness = a; 281 | } 282 | 283 | public function get bgColor():uint 284 | { 285 | return _bgColor; 286 | } 287 | 288 | public function set bgColor(a:uint):void 289 | { 290 | _bgColor = a; 291 | } 292 | 293 | public function get bgStrokeColor():uint 294 | { 295 | return _bgStrokeColor; 296 | } 297 | 298 | public function set bgStrokeColor(a:uint):void 299 | { 300 | _bgStrokeColor = a; 301 | } 302 | 303 | public function get bgTopLeftRadius():Number 304 | { 305 | return _bgTopLeftRadius; 306 | } 307 | 308 | public function set bgTopLeftRadius(a:Number):void 309 | { 310 | _bgTopLeftRadius = a; 311 | } 312 | 313 | public function get bgTopRightRadius():Number 314 | { 315 | return _bgTopRightRadius; 316 | } 317 | 318 | public function set bgTopRightRadius(a:Number):void 319 | { 320 | _bgTopRightRadius = a; 321 | } 322 | 323 | public function get bgBottomLeftRadius():Number 324 | { 325 | return _bgBottomLeftRadius; 326 | } 327 | 328 | public function set bgBottomLeftRadius(a:Number):void 329 | { 330 | _bgBottomLeftRadius = a; 331 | } 332 | 333 | public function get bgBottomRightRadius():Number 334 | { 335 | return _bgBottomRightRadius; 336 | } 337 | 338 | public function set bgBottomRightRadius(a:Number):void 339 | { 340 | _bgBottomRightRadius = a; 341 | } 342 | 343 | public function get serverPath():String 344 | { 345 | return _serverPath; 346 | } 347 | 348 | public function set serverPath(a:String):void 349 | { 350 | _serverPath = a; 351 | } 352 | 353 | public function get flashVars():Object 354 | { 355 | return _flashVars; 356 | } 357 | 358 | public function set flashVars(a:Object):void 359 | { 360 | _flashVars = a; 361 | } 362 | } 363 | 364 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/core/Remoting.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.core { 26 | import com.luaye.console.Console; 27 | 28 | import flash.events.EventDispatcher; 29 | import flash.events.SecurityErrorEvent; 30 | import flash.events.StatusEvent; 31 | import flash.net.LocalConnection; 32 | import flash.system.Security; 33 | 34 | public class Remoting extends EventDispatcher{ 35 | 36 | public static const REMOTE_PREFIX:String = "R"; 37 | public static const CLIENT_PREFIX:String = "C"; 38 | 39 | private var _master:Console; 40 | private var _logsend:Function; 41 | private var _isRemoting:Boolean; 42 | private var _isRemote:Boolean; 43 | private var _sharedConnection:LocalConnection; 44 | private var _remoteLinesQueue:Array; 45 | private var _mspfsForRemote:Array; 46 | private var _remoteDelayed:int; 47 | 48 | private var _lastLogin:String = ""; 49 | private var _loggedIn:Boolean; 50 | 51 | public var remoteMem:int; 52 | 53 | public function Remoting(m:Console, logsend:Function) { 54 | _master = m; 55 | _logsend = logsend; 56 | } 57 | public function addLineQueue(line:Log):void{ 58 | if(!_loggedIn) return; 59 | _remoteLinesQueue.push(line.toObject()); 60 | var maxlines:int = _master.maxLines; 61 | if(_remoteLinesQueue.length > maxlines && maxlines > 0 ){ 62 | _remoteLinesQueue.splice(0,1); 63 | } 64 | } 65 | public function update(mspf:Number, sFR:Number = NaN):void{ 66 | _remoteDelayed++; 67 | if(!_loggedIn) return; 68 | _mspfsForRemote.push(mspf); 69 | if(sFR){ 70 | // this is to try add the frames that have been lagged 71 | var frames:int = Math.floor(mspf/(1000/sFR)); 72 | if(frames>Console.FPS_MAX_LAG_FRAMES) frames = Console.FPS_MAX_LAG_FRAMES; 73 | while(frames>1){ 74 | _mspfsForRemote.push(mspf); 75 | frames--; 76 | } 77 | } 78 | if(_remoteDelayed >= _master.remoteDelay){ 79 | _remoteDelayed = 0; 80 | var newQueue:Array = new Array(); 81 | // don't send too many lines at once cause there is 50kb limit with LocalConnection.send 82 | // Buffer it... 83 | if(_remoteLinesQueue.length > 20){ 84 | newQueue = _remoteLinesQueue.splice(20); 85 | // to force update next farme 86 | _remoteDelayed = _master.remoteDelay; 87 | } 88 | send("logSend", [_remoteLinesQueue, _mspfsForRemote, _master.currentMemory, _master.cl.scopeString]); 89 | _remoteLinesQueue = newQueue; 90 | _mspfsForRemote = [sFR?sFR:30]; 91 | } 92 | } 93 | public function send(command:String, ...args):void{ 94 | var target:String = Console.REMOTING_CONN_NAME+(_isRemote?CLIENT_PREFIX:REMOTE_PREFIX); 95 | args = [target, command].concat(args); 96 | try{ 97 | _sharedConnection.send.apply(this, args); 98 | }catch(e:Error){ 99 | // don't care 100 | } 101 | } 102 | public function get remoting():Boolean{ 103 | return _isRemoting; 104 | } 105 | public function set remoting(newV:Boolean):void{ 106 | _remoteLinesQueue = null; 107 | _mspfsForRemote = null; 108 | if(newV){ 109 | _isRemote = false; 110 | _remoteDelayed = 0; 111 | _mspfsForRemote = [30]; 112 | _remoteLinesQueue = new Array(); 113 | startSharedConnection(); 114 | _sharedConnection.addEventListener(StatusEvent.STATUS, onRemotingStatus); 115 | _sharedConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR , onRemotingSecurityError); 116 | try{ 117 | _sharedConnection.connect(Console.REMOTING_CONN_NAME+CLIENT_PREFIX); 118 | _master.report("Remoting started. "+getInfo(),-1); 119 | _isRemoting = true; 120 | _loggedIn = _master.checkLogin(""); 121 | if(_loggedIn){ 122 | _remoteLinesQueue = _master.getLogsAsObjects(); 123 | send("loginSuccess"); 124 | }else{ 125 | send("requestLogin"); 126 | } 127 | }catch (error:Error){ 128 | _master.report("Could not create client service. You will not be able to control this console with remote.", 10); 129 | } 130 | }else{ 131 | _isRemoting = false; 132 | close(); 133 | } 134 | } 135 | private function onRemotingStatus(e:StatusEvent):void{ 136 | // this will get called quite often... 137 | } 138 | private function onRemotingSecurityError(e:SecurityErrorEvent):void{ 139 | _master.report("Sandbox security error.", 10); 140 | printHowToGlobalSetting(); 141 | } 142 | public function get isRemote():Boolean{ 143 | return _isRemote; 144 | } 145 | public function set isRemote(newV:Boolean):void{ 146 | _isRemote = newV ; 147 | if(newV){ 148 | _isRemoting = false; 149 | startSharedConnection(); 150 | _sharedConnection.addEventListener(StatusEvent.STATUS, onRemoteStatus); 151 | _sharedConnection.addEventListener(SecurityErrorEvent.SECURITY_ERROR , onRemotingSecurityError); 152 | try{ 153 | _sharedConnection.connect(Console.REMOTING_CONN_NAME+REMOTE_PREFIX); 154 | _master.report("Remote started. "+getInfo(),-1); 155 | var sdt:String = Security.sandboxType; 156 | if(sdt == Security.LOCAL_WITH_FILE || sdt == Security.LOCAL_WITH_NETWORK){ 157 | _master.report("Untrusted local sandbox. You may not be able to listen for logs properly.", 10); 158 | printHowToGlobalSetting(); 159 | } 160 | login(_lastLogin); 161 | }catch (error:Error){ 162 | _isRemoting = false; 163 | _master.report("Could not create remote service. You might have a console remote already running.", 10); 164 | } 165 | }else{ 166 | close(); 167 | } 168 | } 169 | private function onRemoteStatus(e:StatusEvent):void{ 170 | if(_isRemote && e.level=="error"){ 171 | _master.report("Problem communicating to client.", 10); 172 | } 173 | } 174 | private function getInfo():String{ 175 | return "channel:"+Console.REMOTING_CONN_NAME+" ("+Security.sandboxType+")"; 176 | } 177 | private function printHowToGlobalSetting():void{ 178 | _master.report("Make sure your flash file is 'trusted' in Global Security Settings.", -2); 179 | _master.report("Go to Settings Manager [click here] > 'Global Security Settings Panel' (on left) > add the location of the local flash (swf) file.", -2); 180 | } 181 | private function startSharedConnection():void{ 182 | close(); 183 | _sharedConnection = new LocalConnection(); 184 | _sharedConnection.allowDomain("*"); 185 | _sharedConnection.allowInsecureDomain("*"); 186 | // just for sort of security 187 | _sharedConnection.client = { 188 | login:login, requestLogin:requestLogin, loginFail:loginFail, loginSuccess:loginSuccess, 189 | logSend:_logsend, gc:_master.gc, runCommand:_master.runCommand 190 | }; 191 | } 192 | public function loginFail():void{ 193 | _master.report("Login Failed", 10); 194 | _master.panels.mainPanel.requestLogin(); 195 | } 196 | public function loginSuccess():void{ 197 | _master.report("Login Successful", -1); 198 | } 199 | public function requestLogin():void{ 200 | if(_lastLogin){ 201 | login(_lastLogin); 202 | }else{ 203 | _master.panels.mainPanel.requestLogin(); 204 | } 205 | } 206 | public function login(pass:String = null):void{ 207 | if(_isRemote){ 208 | _lastLogin = pass; 209 | _master.report("Attempting to login...", -1); 210 | send("login", pass); 211 | }else{ 212 | // once logged in, next login attempts will always be success 213 | if(_loggedIn || _master.checkLogin(pass)){ 214 | _loggedIn = true; 215 | _remoteLinesQueue = _master.getLogsAsObjects(); 216 | send("loginSuccess"); 217 | }else{ 218 | send("loginFail"); 219 | } 220 | } 221 | } 222 | public function close():void{ 223 | if(_sharedConnection){ 224 | try{ 225 | _sharedConnection.close(); 226 | }catch(error:Error){ 227 | _master.report("Remote.close: "+error, 10); 228 | } 229 | } 230 | _sharedConnection = null; 231 | } 232 | } 233 | } -------------------------------------------------------------------------------- /AIR/src/com/doitflash/text/modules/TextModule.as: -------------------------------------------------------------------------------- 1 | package com.doitflash.text.modules 2 | { 3 | import flash.geom.Point; 4 | import flash.display.Loader; 5 | import flash.display.LoaderInfo; 6 | import flash.display.Sprite; 7 | import flash.events.Event; 8 | import flash.utils.Timer; 9 | import flash.utils.setTimeout; 10 | import flash.events.TimerEvent; 11 | import flash.system.LoaderContext; 12 | import flash.system.Security; 13 | import flash.system.SecurityDomain; 14 | 15 | import com.doitflash.text.modules.MySprite; 16 | 17 | //import com.luaye.console.C; 18 | 19 | /** 20 | * ... 21 | * 22 | * Copyright 2011, DoItFlash. All rights reserved. This work is subject to the terms and software agreements in http://www.doitflash.com/. 23 | * 24 | * @author Hadi Tavakoli - 9/12/2010 2:38 PM 25 | */ 26 | public class TextModule extends MySprite 27 | { 28 | protected var _paramList:Object; // holds flashVars 29 | protected var _moduleId:String = ""; 30 | protected var _tagName:String = ""; 31 | protected var _assetsPath:String; 32 | protected var _swfPath:String; 33 | 34 | protected var _tooltip:Object; 35 | 36 | protected var _textArea:*; // a reference to the TextArea which has loaded this module 37 | protected var _loader:Loader; // a reference to the Loader which has loaded this module (adobe is scaling this Loader automatically!) 38 | 39 | private var _contentTimer:Timer; 40 | 41 | public function TextModule():void 42 | { 43 | _width = 100; 44 | _height = 100; 45 | 46 | this.addEventListener(Event.ADDED_TO_STAGE, stageAdded); 47 | 48 | // save flashVars 49 | _paramList = this.root.loaderInfo.parameters; 50 | 51 | this._xml = new XML(restorCDATA(unescape(decodeURIComponent(_paramList.config)))); 52 | this._serverPath = _paramList.serverPath; 53 | 54 | _assetsPath = _paramList.assetsPath; 55 | _swfPath = _paramList.swfPath; 56 | _moduleId = this._xml.@id; 57 | _tagName = this._xml.name(); 58 | } 59 | 60 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 61 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Private Functions 62 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 63 | 64 | private function stageAdded(e:Event = null):void 65 | { 66 | this.removeEventListener(Event.ADDED_TO_STAGE, stageAdded); 67 | 68 | _loader = this.parent as Loader; 69 | 70 | /*var loaderInfo:LoaderInfo = _loader.contentLoaderInfo; 71 | setTimeout(tt, 500); 72 | 73 | function tt():void 74 | { 75 | 76 | for (var name:String in loaderInfo.parameters) 77 | { 78 | C.log(name + " = " + loaderInfo.parameters[name]) 79 | } 80 | }*/ 81 | 82 | /*_textArea = _loader.parent as Object; 83 | _embedFonts = _textArea.embedFonts; 84 | 85 | // connect to the tooltip 86 | //_tooltip = this.stage.getChildByName("myTooltip"); 87 | 88 | // save data from the TextArea 89 | if (_textArea.base) _base = _textArea.base; 90 | else _base = _textArea.holder; 91 | 92 | _holder = _textArea.holder; 93 | 94 | _contentTimer = new Timer(50); 95 | _contentTimer.addEventListener(TimerEvent.TIMER, checkContent); 96 | _contentTimer.start();*/ 97 | } 98 | 99 | public function construct($textArea:*):void 100 | { 101 | _textArea = $textArea; 102 | _embedFonts = _textArea.embedFonts; 103 | 104 | // connect to the tooltip 105 | //_tooltip = this.stage.getChildByName("myTooltip"); 106 | 107 | // save data from the TextArea 108 | if (_textArea.base) _base = _textArea.base; 109 | else _base = _textArea.holder; 110 | 111 | _holder = _textArea.holder; 112 | 113 | _contentTimer = new Timer(50); 114 | _contentTimer.addEventListener(TimerEvent.TIMER, checkContent); 115 | _contentTimer.start(); 116 | } 117 | 118 | private function checkContent(e:TimerEvent=null):void 119 | { 120 | if (_loader.width && _loader.height && _loader.width > 0, _loader.height > 0) 121 | { 122 | // stop the timer 123 | _contentTimer.stop(); 124 | _contentTimer.removeEventListener(TimerEvent.TIMER, checkContent); 125 | 126 | // save the width and height of the module based on the user input 127 | _width = this.root.loaderInfo.width * _loader.scaleX; 128 | _height = this.root.loaderInfo.height * _loader.scaleY; 129 | 130 | drawBg(); // draw the final background for the module 131 | 132 | // Adobe scales the module and we need to stop that! 133 | _loader.scaleX = 1; 134 | _loader.scaleY = 1; 135 | 136 | init(); 137 | 138 | // let TextArea know that this module is loaded and added to stage 139 | _textArea.onModuleLoaded(this); 140 | } 141 | } 142 | 143 | protected function init():void { } 144 | 145 | protected function restorCDATA($str:String):String 146 | { 147 | while ($str.indexOf("@![CDATA[") > -1) 148 | { 149 | $str = $str.replace("@![CDATA[", ""); 151 | } 152 | 153 | return $str; 154 | } 155 | 156 | protected function convertXmlToObject($config:XML):Object 157 | { 158 | var param:String; 159 | var value:String; 160 | var configVars:Object = { }; 161 | 162 | for (var i:int = 0; i < $config..@*.length(); i++) 163 | { 164 | param = $config..@ * [i].name(); 165 | value = $config..@ * [i]; 166 | 167 | configVars[param] = value; 168 | } 169 | 170 | for (var j:int = 0; j < $config.children().length(); j++) 171 | { 172 | var currNode:XML = new XML($config.children()[j]); 173 | 174 | for (var k:int = 0; k < currNode.children().length(); k++) 175 | { 176 | var currAttribute:XML = new XML(currNode.children()[k]); 177 | 178 | param = currAttribute.name(); 179 | value = currAttribute.text(); 180 | 181 | configVars[param] = value; 182 | } 183 | } 184 | 185 | return configVars; 186 | } 187 | 188 | protected function domainLock($Array:Array):Boolean 189 | { 190 | var domainLock:Boolean = true; 191 | 192 | var urlStart:int = root.loaderInfo.loaderURL.indexOf("://")+3; 193 | var urlEnd:int = root.loaderInfo.loaderURL.indexOf("/", urlStart); 194 | var domain:String = root.loaderInfo.loaderURL.substring(urlStart, urlEnd); 195 | var LastDot:int = domain.lastIndexOf(".")-1; 196 | var domEnd:int = domain.lastIndexOf(".", LastDot)+1; 197 | domain = domain.substring(domEnd, domain.length); 198 | 199 | for (var i:int = 0; i < $Array.length; i++) 200 | { 201 | if (domain == $Array[i]) 202 | { 203 | domainLock = false; 204 | break; 205 | } 206 | } 207 | 208 | if ($Array.length == 0) domainLock = false; // if the user didn't write any domain name, execute the movie freely 209 | if (domain == "") domainLock = false; // if the user is executing the movie from his/her computer offline 210 | if (domainLock) throw new Error("The movie can not be executed on this domain"); 211 | 212 | return domainLock; 213 | } 214 | 215 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 216 | //////////////////////////////////////////////////////////////////////////////////////////////////////////////// Helpful Private Functions 217 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 218 | 219 | 220 | 221 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 222 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Methods 223 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 224 | 225 | public function getLocation():Point 226 | { 227 | return new Point(_loader.x, _loader.y) 228 | } 229 | 230 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 231 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Getter - Setter 232 | ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// 233 | 234 | public function get moduleId():String 235 | { 236 | return _moduleId; 237 | } 238 | 239 | public function get tagName():String 240 | { 241 | return _tagName; 242 | } 243 | 244 | } 245 | 246 | } -------------------------------------------------------------------------------- /AIR/Main-app.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.doitflash.permissionCheck 4 | 4.0.1 5 | mobileDevice 6 | exPermissionCheck 7 | Permission Checker 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | ]]> 79 | 80 | 81 | 82 | 83 | 84 | 85 | 88 | MinimumOSVersion 89 | 10.0 90 | 91 | UILaunchStoryboardName 92 | LaunchScreen 93 | 94 | UIPrerenderedIcon 95 | 96 | 97 | UIStatusBarStyle 98 | UIStatusBarStyleBlackOpaque 99 | 100 | UIRequiresPersistentWiFi 101 | NO 102 | 103 | UIDeviceFamily 104 | 105 | 1 106 | 2 107 | 108 | 109 | 126 | 127 | 128 | NSCameraUsageDescription 129 | My description about why I need this feature in my app 130 | 131 | 132 | NSMicrophoneUsageDescription 133 | My description about why I need this feature in my app 134 | 135 | 136 | NSContactsUsageDescription 137 | My description about why I need this feature in my app 138 | 139 | 140 | NSCalendarsUsageDescription 141 | My description about why I need this feature in my app 142 | 143 | 144 | NSPhotoLibraryUsageDescription 145 | My description about why I need this feature in my app 146 | 147 | 148 | NSRemindersUsageDescription 149 | My description about why I need this feature in my app 150 | 151 | 152 | NSLocationWhenInUseUsageDescription 153 | My description about why I need location access when app is in use 154 | 155 | 156 | NSLocationAlwaysUsageDescription 157 | My description about why I need location access always 158 | NSLocationAlwaysAndWhenInUseUsageDescription 159 | My description about why I need location access always 160 | 161 | ]]> 162 | high 163 | 164 | 165 | 166 | 167 | 168 | 169 | exPermissionCheck 170 | ex.swf 171 | true 172 | false 173 | true 174 | 175 | gpu 176 | 177 | 178 | standard 179 | 180 | 181 | icons/icon_36.png 182 | icons/icon_48.png 183 | icons/icon_72.png 184 | icons/icon_96.png 185 | icons/icon_144.png 186 | icons/icon_192.png 187 | icons/icon_512.png 188 | icons/icon_1024.png 189 | 190 | 191 | 192 | com.myflashlab.air.extensions.permissionCheck 193 | 194 | 195 | com.myflashlab.air.extensions.dependency.overrideAir 196 | com.myflashlab.air.extensions.dependency.androidx.core 197 | 198 | 199 | 200 | -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/PanelsManager.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import com.luaye.console.Console; 27 | 28 | import flash.events.Event; 29 | import flash.geom.Rectangle; 30 | import flash.text.TextField; 31 | import flash.text.TextFieldAutoSize; 32 | 33 | public class PanelsManager{ 34 | 35 | 36 | private static const USER_GRAPH_PREFIX:String = "graph_"; 37 | 38 | private var _master:Console; 39 | private var _mainPanel:MainPanel; 40 | private var _ruler:Ruler; 41 | 42 | private var _tooltipField:TextField; 43 | 44 | public function PanelsManager(master:Console, mp:MainPanel) { 45 | _master = master; 46 | _tooltipField = new TextField(); 47 | _tooltipField.autoSize = TextFieldAutoSize.CENTER; 48 | _tooltipField.multiline = true; 49 | _tooltipField.background = true; 50 | _tooltipField.backgroundColor = _master.style.panelBackgroundColor; 51 | _tooltipField.styleSheet = _master.style.css; 52 | _tooltipField.mouseEnabled = false; 53 | _mainPanel = mp; 54 | addPanel(_mainPanel); 55 | } 56 | public function addPanel(panel:AbstractPanel):void{ 57 | if(_master.contains(_tooltipField)){ 58 | _master.addChildAt(panel, _master.getChildIndex(_tooltipField)); 59 | }else{ 60 | _master.addChild(panel); 61 | } 62 | panel.addEventListener(AbstractPanel.STARTED_DRAGGING, onPanelStartDragScale, false,0, true); 63 | panel.addEventListener(AbstractPanel.STARTED_SCALING, onPanelStartDragScale, false,0, true); 64 | } 65 | public function removePanel(n:String):void{ 66 | var panel:AbstractPanel = _master.getChildByName(n) as AbstractPanel; 67 | if(panel){ 68 | // this removes it self from parent. this way each individual panel can clean up before closing. 69 | panel.close(); 70 | } 71 | } 72 | public function getPanel(n:String):AbstractPanel{ 73 | return _master.getChildByName(n) as AbstractPanel; 74 | } 75 | public function get mainPanel():MainPanel{ 76 | return _mainPanel; 77 | } 78 | public function panelExists(n:String):Boolean{ 79 | return (_master.getChildByName(n) as AbstractPanel)?true:false; 80 | } 81 | public function setPanelArea(panelname:String, rect:Rectangle):void{ 82 | var panel:AbstractPanel = getPanel(panelname); 83 | if(panel){ 84 | if(rect.x) panel.x = rect.x; 85 | if(rect.y) panel.y = rect.y; 86 | if(rect.width) panel.width = rect.width; 87 | if(rect.height) panel.height = rect.height; 88 | } 89 | } 90 | // 91 | // 92 | // 93 | public function get channelsPanel():Boolean{ 94 | return (getPanel(Console.PANEL_CHANNELS) as ChannelsPanel)?true:false; 95 | } 96 | public function set channelsPanel(b:Boolean):void{ 97 | if(channelsPanel != b){ 98 | if(b){ 99 | var chpanel:ChannelsPanel = new ChannelsPanel(_master); 100 | chpanel.x = _mainPanel.x+_mainPanel.width-332; 101 | chpanel.y = _mainPanel.y-2; 102 | addPanel(chpanel); 103 | }else { 104 | removePanel(Console.PANEL_CHANNELS); 105 | updateMenu(); 106 | } 107 | } 108 | } 109 | public function updateMenu():void{ 110 | _mainPanel.updateMenu(); 111 | var chpanel:ChannelsPanel = getPanel(Console.PANEL_CHANNELS) as ChannelsPanel; 112 | if(chpanel){ 113 | chpanel.update(); 114 | } 115 | } 116 | // 117 | // 118 | // 119 | public function get displayRoller():Boolean{ 120 | return (getPanel(Console.PANEL_ROLLER) as RollerPanel)?true:false; 121 | } 122 | public function set displayRoller(n:Boolean):void{ 123 | if(displayRoller != n){ 124 | if(n){ 125 | var roller:RollerPanel = new RollerPanel(_master); 126 | roller.x = _mainPanel.x+_mainPanel.width-160; 127 | roller.y = _mainPanel.y+55; 128 | addPanel(roller); 129 | roller.start(_master); 130 | }else{ 131 | removePanel(Console.PANEL_ROLLER); 132 | } 133 | _mainPanel.updateMenu(); 134 | } 135 | } 136 | // 137 | // 138 | // 139 | public function get fpsMonitor():Boolean{ 140 | return (getPanel(Console.PANEL_FPS) as FPSPanel)!=null; 141 | } 142 | public function set fpsMonitor(b:Boolean):void{ 143 | if(fpsMonitor != b){ 144 | if(b){ 145 | var fps:FPSPanel = new FPSPanel(_master); 146 | fps.x = _mainPanel.x+_mainPanel.width-160; 147 | fps.y = _mainPanel.y+15; 148 | addPanel(fps); 149 | }else { 150 | removePanel(Console.PANEL_FPS); 151 | } 152 | _mainPanel.updateMenu(); 153 | } 154 | } 155 | // 156 | // 157 | // 158 | public function get memoryMonitor():Boolean{ 159 | return (getPanel(Console.PANEL_MEMORY) as MemoryPanel)!=null; 160 | } 161 | public function set memoryMonitor(b:Boolean):void{ 162 | if(memoryMonitor != b){ 163 | if(b){ 164 | var mp:MemoryPanel = new MemoryPanel(_master); 165 | mp.x = _mainPanel.x+_mainPanel.width-80; 166 | mp.y = _mainPanel.y+15; 167 | addPanel(mp); 168 | }else { 169 | removePanel(Console.PANEL_MEMORY); 170 | } 171 | _mainPanel.updateMenu(); 172 | } 173 | } 174 | // 175 | // 176 | // 177 | public function addGraph(n:String, obj:Object, prop:String, col:Number = -1, key:String = null, rect:Rectangle = null, inverse:Boolean = false):void{ 178 | n = USER_GRAPH_PREFIX+n; 179 | var graph:GraphingPanel = getPanel(n) as GraphingPanel; 180 | if(!graph){ 181 | graph = new GraphingPanel(_master, 100,100); 182 | graph.x = _mainPanel.x + 80; 183 | graph.y = _mainPanel.y + 20; 184 | graph.name = n; 185 | } 186 | if(rect){ 187 | graph.x = rect.x; 188 | graph.y = rect.y; 189 | if(rect.width>0) 190 | graph.width = rect.width; 191 | if(rect.height>0) 192 | graph.height = rect.height; 193 | } 194 | graph.inverse = inverse; 195 | graph.add(obj,prop,col, key); 196 | addPanel(graph); 197 | } 198 | public function fixGraphRange(n:String, min:Number = NaN, max:Number = NaN):void{ 199 | var graph:GraphingPanel = getPanel(USER_GRAPH_PREFIX+n) as GraphingPanel; 200 | if(graph){ 201 | graph.fixRange(min, max); 202 | } 203 | } 204 | public function removeGraph(n:String, obj:Object = null, prop:String = null):void{ 205 | var graph:GraphingPanel = getPanel(USER_GRAPH_PREFIX+n) as GraphingPanel; 206 | if(graph){ 207 | graph.remove(obj, prop); 208 | } 209 | } 210 | // 211 | // 212 | // 213 | public function tooltip(str:String = null, panel:AbstractPanel = null):void{ 214 | if(str && !rulerActive){ 215 | str = str.replace(/\:\:(.*)/, "
$1"); 216 | _master.addChild(_tooltipField); 217 | _tooltipField.wordWrap = false; 218 | _tooltipField.htmlText = ""+str+""; 219 | if(_tooltipField.width>120){ 220 | _tooltipField.width = 120; 221 | _tooltipField.wordWrap = true; 222 | } 223 | _tooltipField.x = _master.mouseX-(_tooltipField.width/2); 224 | _tooltipField.y = _master.mouseY+20; 225 | if(panel){ 226 | var txtRect:Rectangle = _tooltipField.getBounds(_master); 227 | var panRect:Rectangle = new Rectangle(panel.x,panel.y,panel.width,panel.height); 228 | var doff:Number = txtRect.bottom - panRect.bottom; 229 | if(doff>0){ 230 | if((_tooltipField.y - doff)>(_master.mouseY+15)){ 231 | _tooltipField.y -= doff; 232 | }else if(panRect.y<(_master.mouseY-24) && txtRect.y>panRect.bottom){ 233 | _tooltipField.y = _master.mouseY-_tooltipField.height-15; 234 | } 235 | } 236 | var loff:Number = txtRect.left - panRect.left; 237 | var roff:Number = txtRect.right - panRect.right; 238 | if(loff<0){ 239 | _tooltipField.x -= loff; 240 | }else if(roff>0){ 241 | _tooltipField.x -= roff; 242 | } 243 | } 244 | }else if(_master.contains(_tooltipField)){ 245 | _master.removeChild(_tooltipField); 246 | } 247 | } 248 | // 249 | // 250 | // 251 | public function startRuler():void{ 252 | if(rulerActive){ 253 | return; 254 | } 255 | _ruler = new Ruler(); 256 | _ruler.addEventListener(Ruler.EXIT, onRulerExit, false, 0, true); 257 | _master.addChild(_ruler); 258 | _ruler.start(_master); 259 | _mainPanel.updateMenu(); 260 | } 261 | public function get rulerActive():Boolean{ 262 | return (_ruler && _master.contains(_ruler))?true:false; 263 | } 264 | private function onRulerExit(e:Event):void{ 265 | if(_ruler && _master.contains(_ruler)){ 266 | _master.removeChild(_ruler); 267 | } 268 | _ruler = null; 269 | _mainPanel.updateMenu(); 270 | } 271 | // 272 | // 273 | // 274 | private function onPanelStartDragScale(e:Event):void{ 275 | var target:AbstractPanel = e.currentTarget as AbstractPanel; 276 | if(target.snapping){ 277 | var X:Array = [0]; 278 | var Y:Array = [0]; 279 | if(_master.stage){ 280 | // this will only work if stage size is not changed or top left aligned 281 | X.push(_master.stage.stageWidth); 282 | Y.push(_master.stage.stageHeight); 283 | } 284 | var numchildren:int = _master.numChildren; 285 | for(var i:int = 0;i0){ 230 | var avg:Number = interest.avg; 231 | if(isNaN(avg)) { 232 | interest.avg = v; 233 | }else{ 234 | interest.avg = Utils.averageOut(avg, v, averaging); 235 | } 236 | } 237 | if(!fixed){ 238 | if(v > highest) highest = v; 239 | if(v < lowest) lowest = v; 240 | } 241 | }else{ 242 | remove(obj, interest.prop); 243 | } 244 | } 245 | _history.push(values); 246 | // clean up off screen data 247 | var maxLen:int = Math.floor(width)+10; 248 | var len:uint = _history.length; 249 | if(len > maxLen){ 250 | _history.splice(0, (len-maxLen)); 251 | } 252 | } 253 | public function drawGraph():void{ 254 | _drawnFrame++; 255 | if(!_needRedraw && _drawnFrame < drawEvery) return; 256 | _needRedraw = false; 257 | _drawnFrame= 0; 258 | var W:Number = width; 259 | var H:Number = height-graph.y; 260 | graph.graphics.clear(); 261 | var diffGraph:Number = highest-lowest; 262 | var numInterests:int = _interests.length; 263 | var len:int = _history.length; 264 | for(var j:int = 0;jH)Y=H; 277 | graph.graphics[(first?"moveTo":"lineTo")]((W-i), Y); 278 | first = false; 279 | } 280 | if(averaging>0 && diffGraph){ 281 | Y = ((interest.avg-lowest)/diffGraph)*H; 282 | if(!inverse) Y = H-Y; 283 | if(Y<-1)Y=-1; 284 | if(Y>H)Y=H+1; 285 | graph.graphics.lineStyle(1,interest.col, 0.3); 286 | graph.graphics.moveTo(0, Y); 287 | graph.graphics.lineTo(W, Y); 288 | } 289 | } 290 | (inverse?highTxt:lowTxt).text = isNaN(lowest)?"":""+lowest+""; 291 | (inverse?lowTxt:highTxt).text = isNaN(highest)?"":""+highest+""; 292 | } 293 | public function updateKeyText():void{ 294 | var str:String = ""; 295 | for each(var interest:Interest in _interests){ 296 | str += " "+interest.key+""; 297 | } 298 | str += " | R X"; 299 | keyTxt.htmlText = str; 300 | } 301 | protected function linkHandler(e:TextEvent):void{ 302 | TextField(e.currentTarget).setSelection(0, 0); 303 | if(e.text == "reset"){ 304 | reset(); 305 | }else if(e.text == "close"){ 306 | close(); 307 | } 308 | e.stopPropagation(); 309 | } 310 | protected function onMenuRollOver(e:TextEvent):void{ 311 | master.panels.tooltip(e.text?e.text.replace("event:",""):null, this); 312 | } 313 | } 314 | } 315 | 316 | import com.luaye.console.utils.WeakRef; 317 | 318 | class Interest{ 319 | private var _ref:WeakRef; 320 | public var prop:String; 321 | public var col:Number; 322 | public var key:String; 323 | public var avg:Number; 324 | public function Interest(object:Object, property:String, color:Number, keystr:String):void{ 325 | _ref = new WeakRef(object); 326 | prop = property; 327 | col = color; 328 | key = keystr; 329 | } 330 | public function get obj():Object{ 331 | return _ref.reference; 332 | } 333 | } -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/view/AbstractPanel.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.view { 26 | import flash.events.TextEvent; 27 | 28 | import com.luaye.console.Console; 29 | 30 | import flash.display.DisplayObject; 31 | import flash.display.Sprite; 32 | import flash.events.Event; 33 | import flash.events.MouseEvent; 34 | import flash.geom.Point; 35 | import flash.geom.Rectangle; 36 | import flash.text.TextField; 37 | import flash.text.TextFieldAutoSize; 38 | 39 | public class AbstractPanel extends Sprite { 40 | 41 | public static const STARTED_DRAGGING:String = "startedDragging"; 42 | public static const STARTED_SCALING:String = "startedScaling"; 43 | 44 | //event might be clearer to have it independent... 45 | //[Event(name="textLinkEvent", type="flash.events.TextEvent")] 46 | public static const TEXT_LINK:String = "textLinkEvent"; 47 | 48 | private var _snaps:Array; 49 | private var _dragOffset:Point; 50 | private var _resizeTxt:TextField; 51 | 52 | protected var master:Console; 53 | protected var style:Style; 54 | protected var bg:Sprite; 55 | protected var scaler:Sprite; 56 | protected var minimumWidth:int = 18; 57 | protected var minimumHeight:int = 18; 58 | 59 | public var moveable:Boolean = true; 60 | public var snapping:uint = 3; 61 | 62 | public function AbstractPanel(m:Console) { 63 | master = m; 64 | style = master.style; 65 | bg = new Sprite(); 66 | bg.name = "background"; 67 | addChild(bg); 68 | } 69 | protected function drawBG(col:Number = 0, a:Number = 0.6, rounding:int = 10):void{ 70 | bg.graphics.clear(); 71 | bg.graphics.beginFill(col, a); 72 | var size:int = 100; 73 | var roundSize:int = 100-(rounding*2); 74 | bg.graphics.drawRoundRect(0, 0, size, size,rounding,rounding); 75 | var grid:Rectangle = new Rectangle(rounding, rounding, roundSize, roundSize); 76 | bg.scale9Grid = grid; 77 | } 78 | public function init(w:Number,h:Number,resizable:Boolean = false, col:Number = -1, a:Number = -1, rounding:int = 10):void{ 79 | drawBG(col>=0?col:style.panelBackgroundColor, a>=0?a:style.panelBackgroundAlpha, rounding); 80 | scalable = resizable; 81 | width = w; 82 | height = h; 83 | } 84 | public function close():void { 85 | stopDragging(); 86 | master.panels.tooltip(); 87 | if(parent){ 88 | parent.removeChild(this); 89 | } 90 | //dispatchEvent(new Event(CLOSED)); 91 | } 92 | // 93 | // SIZE 94 | // 95 | override public function set width(n:Number):void{ 96 | if(n < minimumWidth) n = minimumWidth; 97 | if(scaler) scaler.x = n; 98 | bg.width = n; 99 | } 100 | override public function set height(n:Number):void{ 101 | if(n < minimumHeight) n = minimumHeight; 102 | if(scaler) scaler.y = n; 103 | bg.height = n; 104 | } 105 | override public function get width():Number{ 106 | return bg.width; 107 | } 108 | override public function get height():Number{ 109 | return bg.height; 110 | } 111 | // 112 | // MOVING 113 | // 114 | public function registerSnaps(X:Array, Y:Array):void{ 115 | _snaps = [X,Y]; 116 | } 117 | protected function registerDragger(mc:DisplayObject, dereg:Boolean = false):void{ 118 | if(dereg){ 119 | mc.removeEventListener(MouseEvent.MOUSE_DOWN, onDraggerMouseDown); 120 | }else{ 121 | mc.addEventListener(MouseEvent.MOUSE_DOWN, onDraggerMouseDown, false, 0, true); 122 | } 123 | } 124 | private function onDraggerMouseDown(e:MouseEvent):void{ 125 | if(!stage || !moveable) return; 126 | // 127 | _resizeTxt = new TextField(); 128 | _resizeTxt.name = "positioningField"; 129 | _resizeTxt.autoSize = TextFieldAutoSize.LEFT; 130 | formatText(_resizeTxt); 131 | addChild(_resizeTxt); 132 | updateDragText(); 133 | // 134 | _dragOffset = new Point(mouseX,mouseY); // using this way instead of startDrag, so that it can control snapping. 135 | _snaps = [[],[]]; 136 | dispatchEvent(new Event(STARTED_DRAGGING)); 137 | stage.addEventListener(MouseEvent.MOUSE_UP, onDraggerMouseUp, false, 0, true); 138 | stage.addEventListener(MouseEvent.MOUSE_MOVE, onDraggerMouseMove, false, 0, true); 139 | } 140 | private function onDraggerMouseMove(e:MouseEvent = null):void{ 141 | if(snapping==0) return; 142 | // YEE HA, SNAPPING! 143 | var p:Point = returnSnappedFor(parent.mouseX-_dragOffset.x, parent.mouseY-_dragOffset.y); 144 | x = p.x; 145 | y = p.y; 146 | updateDragText(); 147 | } 148 | private function updateDragText():void{ 149 | _resizeTxt.text = ""+x+","+y+""; 150 | } 151 | private function onDraggerMouseUp(e:MouseEvent):void{ 152 | stopDragging(); 153 | } 154 | private function stopDragging():void{ 155 | _snaps = null; 156 | if(stage){ 157 | stage.removeEventListener(MouseEvent.MOUSE_UP, onDraggerMouseUp); 158 | stage.removeEventListener(MouseEvent.MOUSE_MOVE, onDraggerMouseMove); 159 | } 160 | if(_resizeTxt && _resizeTxt.parent){ 161 | _resizeTxt.parent.removeChild(_resizeTxt); 162 | } 163 | _resizeTxt = null; 164 | } 165 | // 166 | // SCALING 167 | // 168 | public function get scalable():Boolean{ 169 | return scaler?true:false; 170 | } 171 | public function set scalable(b:Boolean):void{ 172 | if(b && !scaler){ 173 | scaler = new Sprite(); 174 | scaler.name = "scaler"; 175 | scaler.graphics.beginFill(style.panelScalerColor, style.panelBackgroundAlpha); 176 | scaler.graphics.lineTo(-10, 0); 177 | scaler.graphics.lineTo(0, -10); 178 | scaler.graphics.endFill(); 179 | scaler.buttonMode = true; 180 | scaler.doubleClickEnabled = true; 181 | scaler.addEventListener(MouseEvent.MOUSE_DOWN,onScalerMouseDown, false, 0, true); 182 | addChild(scaler); 183 | }else if(!b && scaler){ 184 | if(contains(scaler)){ 185 | removeChild(scaler); 186 | } 187 | scaler = null; 188 | } 189 | } 190 | private function onScalerMouseDown(e:Event):void{ 191 | _resizeTxt = new TextField(); 192 | _resizeTxt.name = "resizingField"; 193 | _resizeTxt.autoSize = TextFieldAutoSize.RIGHT; 194 | _resizeTxt.x = -4; 195 | _resizeTxt.y = -17; 196 | formatText(_resizeTxt); 197 | scaler.addChild(_resizeTxt); 198 | updateScaleText(); 199 | _dragOffset = new Point(scaler.mouseX,scaler.mouseY); // using this way instead of startDrag, so that it can control snapping. 200 | _snaps = [[],[]]; 201 | scaler.stage.addEventListener(MouseEvent.MOUSE_UP,onScalerMouseUp, false, 0, true); 202 | scaler.stage.addEventListener(MouseEvent.MOUSE_MOVE,updateScale, false, 0, true); 203 | dispatchEvent(new Event(STARTED_SCALING)); 204 | } 205 | private function updateScale(e:Event = null):void{ 206 | var p:Point = returnSnappedFor(x+mouseX-_dragOffset.x, y+mouseY-_dragOffset.x); 207 | p.x-=x; 208 | p.y-=y; 209 | width = p.x"; 215 | } 216 | public function stopScaling():void{ 217 | onScalerMouseUp(null); 218 | } 219 | private function onScalerMouseUp(e:Event):void{ 220 | scaler.stage.removeEventListener(MouseEvent.MOUSE_UP,onScalerMouseUp); 221 | scaler.stage.removeEventListener(MouseEvent.MOUSE_MOVE,updateScale); 222 | updateScale(); 223 | _snaps = null; 224 | if(_resizeTxt && _resizeTxt.parent){ 225 | _resizeTxt.parent.removeChild(_resizeTxt); 226 | } 227 | _resizeTxt = null; 228 | } 229 | // 230 | // 231 | // 232 | private function formatText(txt:TextField):void{ 233 | txt.background = true; 234 | txt.backgroundColor = style.panelBackgroundColor; 235 | txt.styleSheet = style.css; 236 | txt.mouseEnabled = false; 237 | } 238 | private function returnSnappedFor(X:Number,Y:Number):Point{ 239 | var ex:Number = X+width; 240 | var Xs:Array = _snaps[0]; 241 | for each(var Xi:Number in Xs){ 242 | if(Math.abs(Xi-X)0){ 279 | // kinda a hack really :( 280 | var scrollH:Number = field.scrollH; 281 | var w:Number = field.width; 282 | field.width = w+scrollH; 283 | index = field.getCharIndexAtPoint(field.mouseX+scrollH, field.mouseY); 284 | field.width = w; 285 | field.scrollH = scrollH; 286 | }else{ 287 | index = field.getCharIndexAtPoint(field.mouseX, field.mouseY); 288 | } 289 | var url:String = null; 290 | var txt:String = null; 291 | if(index>0){ 292 | // TextField.getXMLText(...) is not documented 293 | var X:XML = new XML(field.getXMLText(index,index+1)); 294 | if(X.hasOwnProperty("textformat")){ 295 | var txtformat:XML = X["textformat"][0] as XML; 296 | if(txtformat){ 297 | url = txtformat.@url; 298 | txt = txtformat.toString(); 299 | } 300 | } 301 | } 302 | field.dispatchEvent(new TextEvent(TEXT_LINK,false,false,url)); 303 | } 304 | } 305 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Permission Check ANE for iOS/Android 2 | This AIR Native Extensions lets you check the permission status of different iOS/Android sources like the camera, photos, contacts, calendar, reminders, location, mic and etc. This ANE also allows you to request for a permission if its status is still unknown (on iOS) or denied (on Android). 3 | 4 | **NOTE:** If you need other permissions, just leave us a message in the issues section and we will gladly add it to the currently supported permissions. 5 | 6 | Here are the list of permissions that this ANE currently supports: 7 | 8 | **on iOS:** 9 | 10 | * CAMERA 11 | * MIC 12 | * CONTACTS 13 | * CALENDAR 14 | * PHOTOS 15 | * REMINDER 16 | * LOCATION (when in app) 17 | * LOCATION (always) 18 | 19 | **on Android:** 20 | 21 | * CAMERA 22 | * MIC 23 | * CONTACTS 24 | * CALENDAR 25 | * PHONE 26 | * STORAGE 27 | * LOCATION 28 | * SENSORS 29 | * SMS 30 | 31 | 32 | [find the latest **asdoc** for this ANE here.](http://myflashlab.github.io/asdoc/com/myflashlab/air/extensions/nativePermissions/package-detail.html) 33 | 34 | # Air Usage 35 | ```actionscript 36 | import com.myflashlab.air.extensions.nativePermissions.PermissionCheck; 37 | 38 | // initialize the ane 39 | PermissionCheck.init(); 40 | 41 | // check for a permission state 42 | var permissionState:int = PermissionCheck.check(PermissionCheck.SOURCE_CAMERA); 43 | // PermissionCheck.SOURCE_CAMERA > both platforms 44 | // PermissionCheck.SOURCE_MIC > both platforms 45 | // PermissionCheck.SOURCE_CONTACTS > both platforms 46 | // PermissionCheck.SOURCE_CALENDAR > both platforms 47 | // PermissionCheck.SOURCE_PHOTOS > iOS ONLY 48 | // PermissionCheck.SOURCE_REMINDER > iOS ONLY 49 | // PermissionCheck.SOURCE_LOCATION_WHEN_IN_USE > iOS ONLY 50 | // PermissionCheck.SOURCE_LOCATION_ALWAYS > iOS ONLY 51 | // PermissionCheck.SOURCE_PHONE > Android ONLY 52 | // PermissionCheck.SOURCE_STORAGE > Android ONLY 53 | // PermissionCheck.SOURCE_LOCATION > Android ONLY 54 | // PermissionCheck.SOURCE_SENSORS > Android ONLY 55 | // PermissionCheck.SOURCE_SMS > Android ONLY 56 | 57 | /* 58 | The returned state will be one of these values: 59 | PermissionCheck.PERMISSION_UNKNOWN > iOS ONLY when it's the first time that you are calling the feature. 60 | PermissionCheck.PERMISSION_DENIED 61 | PermissionCheck.PERMISSION_GRANTED 62 | */ 63 | 64 | // if the state is PERMISSION_UNKNOWN on iOS or PERMISSION_DENIED on Android, you can request for a permission like this: 65 | PermissionCheck.request(PermissionCheck.SOURCE_CAMERA, onRequestResult); 66 | 67 | private function onRequestResult($obj:Object):void 68 | { 69 | trace("permission for " + $obj.source + ": " + $obj.state); 70 | } 71 | 72 | /* 73 | ON iOS: 74 | When you request for a permission which is currently in UNKNOWN 75 | state, a dialog window will open and asks for user's permission 76 | if the app should have access to the requested resource. No matter 77 | what the decision of the user would be, you will never again be 78 | able to request for that permission again! Don't ask me why, it's 79 | how iOS works :) 80 | 81 | So, What would happen if a user has denied a request but later she 82 | changes her mind? well, in that case, you should take the user to 83 | the app's settings menu using ```PermissionCheck.openSettings();``` 84 | where user can see the list of permissions she has granted to your 85 | app. 86 | 87 | NOTICE: as soon as a user changes the state of a permission in the 88 | settings menu, your app will be shut down by OS. 89 | 90 | -------------------------------------------------------------------- 91 | 92 | ON ANDROID: 93 | As long as a feature permission is in DENIED state, you can request 94 | for user's permission and a dialog will open by the ANE. Even the 95 | first time that you are asking for a permission, the state is DENIED. 96 | 97 | Optionally, you can call ```PermissionCheck.openSettings();``` to open 98 | the app settings window so users can see the list of features that 99 | your app has requested permissions for. 100 | */ 101 | ``` 102 | 103 | # Air .xml manifest 104 | ```xml 105 | 108 | 109 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 169 | 170 | 171 | 172 | MinimumOSVersion 173 | 10.0 174 | 175 | 188 | 189 | 190 | NSCameraUsageDescription 191 | My description about why I need this feature in my app 192 | 193 | 194 | NSMicrophoneUsageDescription 195 | My description about why I need this feature in my app 196 | 197 | 198 | NSContactsUsageDescription 199 | My description about why I need this feature in my app 200 | 201 | 202 | NSCalendarsUsageDescription 203 | My description about why I need this feature in my app 204 | 205 | 206 | NSPhotoLibraryUsageDescription 207 | My description about why I need this feature in my app 208 | 209 | 210 | NSRemindersUsageDescription 211 | My description about why I need this feature in my app 212 | 213 | 214 | NSLocationWhenInUseUsageDescription 215 | My description about why I need this feature in my app 216 | 217 | 218 | NSLocationAlwaysUsageDescription 219 | My description about why I need this feature in my app 220 | NSLocationAlwaysAndWhenInUseUsageDescription 221 | My description about why I need this feature in my app 222 | 223 | 224 | NSMotionUsageDescription 225 | My description about why I need this feature in my app 226 | 227 | 228 | 230 | 231 | 232 | 234 | 235 | 236 | 238 | 239 | 240 | 242 | 243 | 244 | 246 | 247 | 248 | 250 | 251 | 252 | 254 | 255 | 256 | 257 | 258 | 259 | 262 | 263 | 264 | com.myflashlab.air.extensions.permissionCheck 265 | 266 | 267 | com.myflashlab.air.extensions.dependency.overrideAir 268 | com.myflashlab.air.extensions.dependency.androidx.core 269 | 270 | 271 | --> 272 | ``` 273 | 274 | # Requirements 275 | 1. iOS 10.0+ 276 | 2. AirSDK 33+ 277 | 3. Android 19+ 278 | 4. The following dependencies 279 | * ```com.myflashlab.air.extensions.dependency.overrideAir``` 280 | * ```com.myflashlab.air.extensions.dependency.androidx.core``` 281 | 282 | # Commercial Version 283 | https://www.myflashlabs.com/product/native-access-permission-check-settings-menu-air-native-extension/ 284 | 285 | [![Permission Check ANE](https://www.myflashlabs.com/wp-content/uploads/2016/06/product_adobe-air-ane-permission-check-2018-595x738.jpg)](https://www.myflashlabs.com/product/native-access-permission-check-settings-menu-air-native-extension/) 286 | 287 | # Tutorials 288 | [How to embed ANEs into **FlashBuilder**, **FlashCC** and **FlashDevelop**](https://www.youtube.com/watch?v=Oubsb_3F3ec&list=PL_mmSjScdnxnSDTMYb1iDX4LemhIJrt1O) 289 | [Understanding How Permissions Work before the release of AIR 24](http://www.myflashlabs.com/understanding-android-ios-permissions-in-adobe-air-apps/) 290 | [How to work with Permissions after the release of AIR SDK 24](http://www.myflashlabs.com/adobe-air-app-permissions-android-ios/) 291 | 292 | # Premium Support # 293 | [![Premium Support package](https://www.myflashlabs.com/wp-content/uploads/2016/06/professional-support.jpg)](https://www.myflashlabs.com/product/myflashlabs-support/) 294 | If you are an [active MyFlashLabs club member](https://www.myflashlabs.com/product/myflashlabs-club-membership/), you will have access to our private and secure support ticket system for all our ANEs. Even if you are not a member, you can still receive premium help if you purchase the [premium support package](https://www.myflashlabs.com/product/myflashlabs-support/). -------------------------------------------------------------------------------- /AIR/src/com/luaye/console/core/CommandTools.as: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2008-2009 Lu Aye Oo 4 | * 5 | * @author Lu Aye Oo 6 | * 7 | * http://code.google.com/p/flash-console/ 8 | * 9 | * 10 | * This software is provided 'as-is', without any express or implied 11 | * warranty. In no event will the authors be held liable for any damages 12 | * arising from the use of this software. 13 | * Permission is granted to anyone to use this software for any purpose, 14 | * including commercial applications, and to alter it and redistribute it 15 | * freely, subject to the following restrictions: 16 | * 1. The origin of this software must not be misrepresented; you must not 17 | * claim that you wrote the original software. If you use this software 18 | * in a product, an acknowledgment in the product documentation would be 19 | * appreciated but is not required. 20 | * 2. Altered source versions must be plainly marked as such, and must not be 21 | * misrepresented as being the original software. 22 | * 3. This notice may not be removed or altered from any source distribution. 23 | * 24 | */ 25 | package com.luaye.console.core { 26 | import com.luaye.console.utils.WeakObject; 27 | import com.luaye.console.Console; 28 | 29 | import flash.display.DisplayObject; 30 | import flash.display.DisplayObjectContainer; 31 | import flash.utils.getQualifiedClassName; 32 | import flash.utils.describeType; 33 | 34 | public class CommandTools { 35 | 36 | private var _mapBases:WeakObject; 37 | private var _mapBaseIndex:uint = 1; 38 | private var _report:Function; 39 | 40 | public function CommandTools(f:Function) { 41 | _report = f; 42 | _mapBases = new WeakObject(); 43 | } 44 | public function report(obj:*,priority:Number = 1, skipSafe:Boolean = true):void{ 45 | _report(obj, priority, skipSafe); 46 | } 47 | public function inspect(obj:Object, viewAll:Boolean= true):void { 48 | // 49 | // Class extends... extendsClass 50 | // Class implements... implementsInterface 51 | // constant // statics 52 | // methods 53 | // accessors 54 | // varaibles 55 | // values 56 | // EVENTS .. metadata name="Event" 57 | // 58 | var V:XML = describeType(obj); 59 | var cls:Object = obj is Class?obj:obj.constructor; 60 | var clsV:XML = describeType(cls); 61 | var self:String = V.@name; 62 | var str:String = ""+self+""; 63 | var props:Array = []; 64 | var props2:Array = []; 65 | var staticPrefix:String = "[static]"; 66 | var nodes:XMLList; 67 | if(V.@isDynamic=="true"){ 68 | props.push("dynamic"); 69 | } 70 | if(V.@isFinal=="true"){ 71 | props.push("final"); 72 | } 73 | if(V.@isStatic=="true"){ 74 | props.push("static"); 75 | } 76 | if(props.length > 0){ 77 | str += " "+props.join(" | ")+""; 78 | } 79 | report(str+"
", -2); 80 | // 81 | // extends... 82 | // 83 | props = []; 84 | nodes = V.extendsClass; 85 | for each (var extendX:XML in nodes) { 86 | props.push(extendX.@type.toString()); 87 | if(!viewAll) break; 88 | } 89 | if(props.length){ 90 | report("Extends: "+props.join(" > ")+"
", 5); 91 | } 92 | // 93 | // implements... 94 | // 95 | props = []; 96 | nodes = V.implementsInterface; 97 | for each (var implementX:XML in nodes) { 98 | props.push(implementX.@type.toString()); 99 | } 100 | if(props.length){ 101 | report("Implements: "+props.join("; ")+"
", 5); 102 | } 103 | // 104 | // constants... 105 | // 106 | props = []; 107 | nodes = clsV..constant; 108 | for each (var constantX:XML in nodes) { 109 | props.push(constantX.@name+"("+constantX.@type+")"); 110 | } 111 | if(props.length){ 112 | report("Constants: "+props.join("; ")+"
", 5); 113 | } 114 | // 115 | // methods 116 | // 117 | props = []; 118 | props2 = []; 119 | nodes = clsV..method; // '..' to include from 120 | for each (var methodX:XML in nodes) { 121 | var mparamsList:XMLList = methodX.parameter; 122 | str = methodX.parent().name()=="factory"?"":staticPrefix; 123 | if(viewAll){ 124 | var params:Array = []; 125 | for each(var paraX:XML in mparamsList){ 126 | params.push(paraX.@optional=="true"?(""+paraX.@type+""):paraX.@type); 127 | } 128 | str += methodX.@name+"("+params.join(",")+"):"+methodX.@returnType+""; 129 | }else{ 130 | str += methodX.@name+"("+mparamsList.length()+"):"+methodX.@returnType+""; 131 | } 132 | arr = (self==methodX.@declaredBy?props:props2); 133 | arr.push(str); 134 | } 135 | makeInheritLine(props, props2, viewAll, "Methods", viewAll?"
":"; "); 136 | // 137 | // accessors 138 | // 139 | var arr:Array; 140 | props = []; 141 | props2 = []; 142 | nodes = clsV..accessor; // '..' to include from 143 | for each (var accessorX:XML in nodes) { 144 | str = accessorX.parent().name()=="factory"?"":staticPrefix; 145 | str += (accessorX.@access=="readonly"?(""+accessorX.@name+""):accessorX.@name)+"("+accessorX.@type+")"; 146 | arr = (self==accessorX.@declaredBy?props:props2); 147 | arr.push(str); 148 | } 149 | makeInheritLine(props, props2, viewAll, "Accessors", "; "); 150 | // 151 | // variables 152 | // 153 | props = []; 154 | nodes = clsV..variable; 155 | for each (var variableX:XML in nodes) { 156 | str = (variableX.parent().name()=="factory"?"":staticPrefix)+variableX.@name+"("+variableX.@type+")"; 157 | props.push(str); 158 | } 159 | if(props.length){ 160 | report("Variables: "+props.join("; ")+"
", 5); 161 | } 162 | // 163 | // dynamic values 164 | // 165 | props = []; 166 | for (var X:String in obj) { 167 | props.push(X+"("+getQualifiedClassName(obj[X])+")"); 168 | } 169 | if(props.length){ 170 | report("Values: "+props.join("; ")+"
", 5); 171 | } 172 | // 173 | // events 174 | // metadata name="Event" 175 | props = []; 176 | nodes = V.metadata; 177 | for each (var metadataX:XML in nodes) { 178 | if(metadataX.@name=="Event"){ 179 | var mn:XMLList = metadataX.arg; 180 | props.push(mn.(@key=="name").@value+"("+mn.(@key=="type").@value+")"); 181 | } 182 | } 183 | if(props.length){ 184 | report("Events: "+props.join("; ")+"
", 5); 185 | } 186 | // 187 | // display's parents and direct children 188 | // 189 | if (viewAll && obj is DisplayObjectContainer) { 190 | props = []; 191 | var mc:DisplayObjectContainer = obj as DisplayObjectContainer; 192 | var clen:int = mc.numChildren; 193 | for (var ci:int = 0; ci"+child.name+":("+ci+")"+getQualifiedClassName(child)); 196 | } 197 | if(props.length){ 198 | report("Children: "+props.join("; ")+"
", 5); 199 | } 200 | var theParent:DisplayObjectContainer = mc.parent; 201 | if (theParent) { 202 | props = ["("+theParent.getChildIndex(mc)+")"]; 203 | while (theParent) { 204 | var pr:DisplayObjectContainer = theParent; 205 | theParent = theParent.parent; 206 | props.push(""+pr.name+":("+(theParent?theParent.getChildIndex(pr):"")+")"+getQualifiedClassName(pr)); 207 | } 208 | if(props.length){ 209 | report("Parents: "+props.join("; ")+"
", 5); 210 | } 211 | } 212 | } 213 | if(!viewAll){ 214 | report("Tip: use /inspectfull to see full inspection with inheritance",-1); 215 | } 216 | } 217 | private function makeInheritLine(props:Array, props2:Array, viewAll:Boolean, type:String, breaker:String):void{ 218 | var str:String = ""; 219 | if(props.length || props2.length){ 220 | str += ""+type+": "+props.join(breaker); 221 | if(viewAll){ 222 | str += (props.length?breaker:"")+""+props2.join(breaker)+""; 223 | }else if(props2.length){ 224 | str += (props.length?breaker:"")+"+ "+props2.length+" inherited"; 225 | } 226 | report(str+"
", 5); 227 | } 228 | } 229 | public function map(base:DisplayObjectContainer, maxstep:uint = 0):void{ 230 | if(!base){ 231 | report("It is not a DisplayObjectContainer", 10); 232 | return; 233 | } 234 | _mapBases[_mapBaseIndex] = base; 235 | var basestr:String = _mapBaseIndex+Console.MAPPING_SPLITTER; 236 | 237 | var list:Array = new Array(); 238 | var index:int = 0; 239 | list.push(base); 240 | while(index0){ 269 | indexes.pop(); 270 | steps--; 271 | } 272 | if((lastmcDO as DisplayObjectContainer).contains(mcDO)){ 273 | steps++; 274 | indexes.push(mcDO.name); 275 | break; 276 | } 277 | } 278 | } 279 | } 280 | } 281 | var str:String = ""; 282 | for(i=0;i"+mcDO.name+""; 288 | if(mcDO is DisplayObjectContainer){ 289 | n = ""+n+""; 290 | }else{ 291 | n = ""+n+""; 292 | } 293 | str += n+" ("+getQualifiedClassName(mcDO)+")"; 294 | report(str,mcDO is DisplayObjectContainer?5:2); 295 | }else if(!wasHiding){ 296 | wasHiding = true; 297 | report(str+"...",5); 298 | } 299 | lastmcDO = mcDO; 300 | } 301 | _mapBaseIndex++; 302 | report(base.name+":"+getQualifiedClassName(base)+" has "+list.length+" children/sub-children.", 10); 303 | report("Click on the name to return a reference to the child clip.
Note that clip references will be broken when display list is changed",-2); 304 | } 305 | public function reMap(path:String, mc:DisplayObjectContainer):DisplayObject{ 306 | var pathArr:Array = path.split(Console.MAPPING_SPLITTER); 307 | var first:String = pathArr.shift(); 308 | if(first != "0") mc = _mapBases[first]; 309 | var child:DisplayObject = mc as DisplayObject; 310 | try{ 311 | for each(var nn:String in pathArr){ 312 | if(!nn) break; 313 | child = mc.getChildByName(nn); 314 | if(child is DisplayObjectContainer){ 315 | mc = child as DisplayObjectContainer;; 316 | }else{ 317 | // assume it reached to end since there can no longer be a child 318 | break; 319 | } 320 | } 321 | return child; 322 | } catch (e:Error) { 323 | report("Problem getting the clip reference. Display list must have changed since last map request",10); 324 | //debug(e.getStackTrace()); 325 | } 326 | return null; 327 | } 328 | public function printHelp():void { 329 | report("____Command Line Help___",10); 330 | report("/filter (text) = filter/search logs for matching text",5); 331 | report("// = return to previous scope",5); 332 | report("/base = return to base scope (same as typing $base)",5); 333 | report("/store (name) = store current scope to that name (default is weak reference). to call back: $(name)",5); 334 | report("/savestrong (name) = store current scope as strong reference",5); 335 | report("/stored = list all stored variables",5); 336 | report("/inspect = get info of your current scope.",5); 337 | report("/inspectfull = get more detailed info of your current scope.",5); 338 | report("/map = get the display list map starting from your current scope",5); 339 | report("/strong true = turn on strong referencing, you need to turn this on if you want to start manipulating with instances that are newly created.",5); 340 | report("/string = return the param of this command as a string. This is useful if you want to paste a block of text to use in commandline.",5); 341 | report("Press up/down arrow keys to recall previous commands",2); 342 | report("__Examples:",10); 343 | report("stage.width",5); 344 | report("stage.scaleMode = flash.display.StageScaleMode.NO_SCALE",5); 345 | report("stage.frameRate = 12",5); 346 | report("__________",10); 347 | } 348 | } 349 | } -------------------------------------------------------------------------------- /AIR/src/Main.as: -------------------------------------------------------------------------------- 1 | package 2 | { 3 | import com.doitflash.consts.Direction; 4 | import com.doitflash.consts.Orientation; 5 | import com.doitflash.mobileProject.commonCpuSrc.DeviceInfo; 6 | import com.doitflash.starling.utils.list.List; 7 | import com.doitflash.text.modules.MySprite; 8 | 9 | import com.luaye.console.C; 10 | 11 | import flash.desktop.NativeApplication; 12 | import flash.desktop.SystemIdleMode; 13 | import flash.display.Sprite; 14 | import flash.display.StageAlign; 15 | import flash.display.StageScaleMode; 16 | import flash.events.Event; 17 | import flash.events.InvokeEvent; 18 | import flash.events.KeyboardEvent; 19 | import flash.events.MouseEvent; 20 | import flash.text.AntiAliasType; 21 | import flash.text.TextField; 22 | import flash.text.TextFieldAutoSize; 23 | import flash.text.TextFormat; 24 | import flash.text.TextFormatAlign; 25 | import flash.ui.Keyboard; 26 | import flash.ui.Multitouch; 27 | import flash.ui.MultitouchInputMode; 28 | 29 | import com.myflashlab.air.extensions.nativePermissions.PermissionCheck; 30 | import com.myflashlab.air.extensions.dependency.OverrideAir; 31 | 32 | /** 33 | * ... 34 | * @author Hadi Tavakoli - 6/7/2016 4:38 PM 35 | */ 36 | public class Main extends Sprite 37 | { 38 | private const BTN_WIDTH:Number = 150; 39 | private const BTN_HEIGHT:Number = 60; 40 | private const BTN_SPACE:Number = 2; 41 | private var _txt:TextField; 42 | private var _body:Sprite; 43 | private var _list:List; 44 | private var _numRows:int = 1; 45 | 46 | public function Main():void 47 | { 48 | Multitouch.inputMode = MultitouchInputMode.GESTURE; 49 | NativeApplication.nativeApplication.addEventListener(Event.ACTIVATE, handleActivate); 50 | NativeApplication.nativeApplication.addEventListener(Event.DEACTIVATE, handleDeactivate); 51 | NativeApplication.nativeApplication.addEventListener(InvokeEvent.INVOKE, onInvoke); 52 | NativeApplication.nativeApplication.addEventListener(KeyboardEvent.KEY_DOWN, handleKeys); 53 | 54 | stage.addEventListener(Event.RESIZE, onResize); 55 | stage.scaleMode = StageScaleMode.NO_SCALE; 56 | stage.align = StageAlign.TOP_LEFT; 57 | 58 | C.startOnStage(this, "`"); 59 | C.commandLine = false; 60 | C.commandLineAllowed = false; 61 | C.x = 20; 62 | C.width = 250; 63 | C.height = 150; 64 | C.strongRef = true; 65 | C.visible = true; 66 | C.scaleX = C.scaleY = DeviceInfo.dpiScaleMultiplier; 67 | 68 | _txt = new TextField(); 69 | _txt.autoSize = TextFieldAutoSize.LEFT; 70 | _txt.antiAliasType = AntiAliasType.ADVANCED; 71 | _txt.multiline = true; 72 | _txt.wordWrap = true; 73 | _txt.embedFonts = false; 74 | _txt.htmlText = "Permission Check ANE V"+PermissionCheck.VERSION+""; 75 | _txt.scaleX = _txt.scaleY = DeviceInfo.dpiScaleMultiplier; 76 | this.addChild(_txt); 77 | 78 | _body = new Sprite(); 79 | this.addChild(_body); 80 | 81 | _list = new List(); 82 | _list.holder = _body; 83 | _list.itemsHolder = new Sprite(); 84 | _list.orientation = Orientation.VERTICAL; 85 | _list.hDirection = Direction.LEFT_TO_RIGHT; 86 | _list.vDirection = Direction.TOP_TO_BOTTOM; 87 | _list.space = BTN_SPACE; 88 | 89 | onInit(); 90 | onResize(); 91 | } 92 | 93 | private function onInvoke(e:InvokeEvent):void 94 | { 95 | NativeApplication.nativeApplication.removeEventListener(InvokeEvent.INVOKE, onInvoke); 96 | } 97 | 98 | private function handleActivate(e:Event):void 99 | { 100 | NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE; 101 | } 102 | 103 | private function handleDeactivate(e:Event):void 104 | { 105 | NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.NORMAL; 106 | } 107 | 108 | private function handleKeys(e:KeyboardEvent):void 109 | { 110 | if(e.keyCode == Keyboard.BACK) 111 | { 112 | e.preventDefault(); 113 | NativeApplication.nativeApplication.exit(); 114 | } 115 | } 116 | 117 | private function onResize(e:*=null):void 118 | { 119 | if (_txt) 120 | { 121 | _txt.y = 150 * (1 / DeviceInfo.dpiScaleMultiplier); 122 | _txt.width = stage.stageWidth * (1 / DeviceInfo.dpiScaleMultiplier); 123 | 124 | C.x = 0; 125 | C.y = _txt.y + _txt.height + 0; 126 | C.width = stage.stageWidth * (1 / DeviceInfo.dpiScaleMultiplier); 127 | C.height = 300 * (1 / DeviceInfo.dpiScaleMultiplier); 128 | } 129 | 130 | if (_list) 131 | { 132 | _numRows = Math.floor(stage.stageWidth / (BTN_WIDTH * DeviceInfo.dpiScaleMultiplier + BTN_SPACE)); 133 | _list.row = _numRows; 134 | _list.itemArrange(); 135 | } 136 | 137 | if (_body) 138 | { 139 | _body.y = stage.stageHeight - _body.height; 140 | } 141 | } 142 | 143 | private function onInit():void 144 | { 145 | // Remove OverrideAir debugger in production builds 146 | OverrideAir.enableDebugger(function ($ane:String, $class:String, $msg:String):void 147 | { 148 | trace($ane+" ("+$class+") "+$msg); 149 | }); 150 | 151 | // initialize the ANE 152 | PermissionCheck.init(); 153 | 154 | var btn0:MySprite = createBtn("check permissions", 0xFF9900); 155 | btn0.addEventListener(MouseEvent.CLICK, checkPermissions); 156 | _list.add(btn0); 157 | 158 | function checkPermissions(e:MouseEvent):void 159 | { 160 | var permissionState:int; 161 | 162 | C.log(""); 163 | 164 | // ----------------------------------------------------------------------- on both platforms 165 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_CAMERA); 166 | C.log("PermissionCheck.SOURCE_CAMERA = " + prettify(permissionState)); 167 | 168 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_MIC); 169 | C.log("PermissionCheck.SOURCE_MIC = " + prettify(permissionState)); 170 | 171 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_CONTACTS); 172 | C.log("PermissionCheck.SOURCE_CONTACTS = " + prettify(permissionState)); 173 | 174 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_CALENDAR); 175 | C.log("PermissionCheck.SOURCE_CALENDAR = " + prettify(permissionState)); 176 | 177 | // ----------------------------------------------------------------------- on iOS ONLY 178 | if (OverrideAir.os == OverrideAir.IOS) 179 | { 180 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_PHOTOS); 181 | C.log("PermissionCheck.SOURCE_PHOTOS = " + prettify(permissionState)); 182 | 183 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_REMINDER); 184 | C.log("PermissionCheck.SOURCE_REMINDER = " + prettify(permissionState)); 185 | 186 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_LOCATION_ALWAYS); 187 | C.log("PermissionCheck.SOURCE_LOCATION_ALWAYS = " + prettify(permissionState)); 188 | 189 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_LOCATION_WHEN_IN_USE); 190 | C.log("PermissionCheck.SOURCE_LOCATION_WHEN_IN_USE = " + prettify(permissionState)); 191 | } 192 | 193 | // ----------------------------------------------------------------------- on Android ONLY 194 | if (OverrideAir.os == OverrideAir.ANDROID) 195 | { 196 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_PHONE); 197 | C.log("PermissionCheck.SOURCE_PHONE = " + prettify(permissionState)); 198 | 199 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_STORAGE); 200 | C.log("PermissionCheck.SOURCE_STORAGE = " + prettify(permissionState)); 201 | 202 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_LOCATION); 203 | C.log("PermissionCheck.SOURCE_LOCATION = " + prettify(permissionState)); 204 | 205 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_SENSORS); 206 | C.log("PermissionCheck.SOURCE_SENSORS = " + prettify(permissionState)); 207 | 208 | permissionState = PermissionCheck.check(PermissionCheck.SOURCE_SMS); 209 | C.log("PermissionCheck.SOURCE_SMS = " + prettify(permissionState)); 210 | } 211 | 212 | C.log(""); 213 | C.log("----------------"); 214 | } 215 | 216 | var btn00:MySprite = createBtn("Open Settings", 0xFF9900); 217 | btn00.addEventListener(MouseEvent.CLICK, openSettings); 218 | _list.add(btn00); 219 | 220 | function openSettings(e:MouseEvent):void 221 | { 222 | PermissionCheck.openSettings(); 223 | } 224 | 225 | // -------------------------------------------------------------------- on both platforms 226 | 227 | var btn1:MySprite = createBtn("request CAMERA"); 228 | btn1.addEventListener(MouseEvent.CLICK, requestCamera); 229 | _list.add(btn1); 230 | 231 | function requestCamera(e:MouseEvent):void 232 | { 233 | PermissionCheck.request(PermissionCheck.SOURCE_CAMERA, onRequestResult); 234 | } 235 | 236 | var btn2:MySprite = createBtn("request MIC"); 237 | btn2.addEventListener(MouseEvent.CLICK, requestMic); 238 | _list.add(btn2); 239 | 240 | function requestMic(e:MouseEvent):void 241 | { 242 | PermissionCheck.request(PermissionCheck.SOURCE_MIC, onRequestResult); 243 | } 244 | 245 | var btn4:MySprite = createBtn("request CONTACTS"); 246 | btn4.addEventListener(MouseEvent.CLICK, requestCONTACTS); 247 | _list.add(btn4); 248 | 249 | function requestCONTACTS(e:MouseEvent):void 250 | { 251 | PermissionCheck.request(PermissionCheck.SOURCE_CONTACTS, onRequestResult); 252 | } 253 | 254 | var btn5:MySprite = createBtn("request CALENDAR"); 255 | btn5.addEventListener(MouseEvent.CLICK, requestCALENDAR); 256 | _list.add(btn5); 257 | 258 | function requestCALENDAR(e:MouseEvent):void 259 | { 260 | PermissionCheck.request(PermissionCheck.SOURCE_CALENDAR, onRequestResult); 261 | } 262 | 263 | // ----------------------------------------------------------------------- on iOS ONLY 264 | if (OverrideAir.os == OverrideAir.IOS) 265 | { 266 | var btn3:MySprite = createBtn("request PHOTOS"); 267 | btn3.addEventListener(MouseEvent.CLICK, requestPHOTOS); 268 | _list.add(btn3); 269 | 270 | function requestPHOTOS(e:MouseEvent):void 271 | { 272 | PermissionCheck.request(PermissionCheck.SOURCE_PHOTOS, onRequestResult); 273 | } 274 | 275 | var btn6:MySprite = createBtn("request REMINDER"); 276 | btn6.addEventListener(MouseEvent.CLICK, requestREMINDER); 277 | _list.add(btn6); 278 | 279 | function requestREMINDER(e:MouseEvent):void 280 | { 281 | PermissionCheck.request(PermissionCheck.SOURCE_REMINDER, onRequestResult); 282 | } 283 | 284 | var btn20:MySprite = createBtn("request LOCATION when in use"); 285 | btn20.addEventListener(MouseEvent.CLICK, requestLocationWhenInUse); 286 | _list.add(btn20); 287 | 288 | function requestLocationWhenInUse(e:MouseEvent):void 289 | { 290 | PermissionCheck.request(PermissionCheck.SOURCE_LOCATION_WHEN_IN_USE, onRequestResult); 291 | } 292 | 293 | var btn21:MySprite = createBtn("request LOCATION always access"); 294 | btn21.addEventListener(MouseEvent.CLICK, requestLocationAlways); 295 | _list.add(btn21); 296 | 297 | function requestLocationAlways(e:MouseEvent):void 298 | { 299 | PermissionCheck.request(PermissionCheck.SOURCE_LOCATION_ALWAYS, onRequestResult); 300 | } 301 | } 302 | 303 | // ----------------------------------------------------------------------- on Android ONLY 304 | if (OverrideAir.os == OverrideAir.ANDROID) 305 | { 306 | var btn7:MySprite = createBtn("request PHONE"); 307 | btn7.addEventListener(MouseEvent.CLICK, requestPHONE); 308 | _list.add(btn7); 309 | 310 | function requestPHONE(e:MouseEvent):void 311 | { 312 | PermissionCheck.request(PermissionCheck.SOURCE_PHONE, onRequestResult); 313 | } 314 | 315 | var btn8:MySprite = createBtn("request STORAGE"); 316 | btn8.addEventListener(MouseEvent.CLICK, requestSTORAGE); 317 | _list.add(btn8); 318 | 319 | function requestSTORAGE(e:MouseEvent):void 320 | { 321 | PermissionCheck.request(PermissionCheck.SOURCE_STORAGE, onRequestResult); 322 | } 323 | 324 | var btn9:MySprite = createBtn("request LOCATION"); 325 | btn9.addEventListener(MouseEvent.CLICK, requestLOCATION); 326 | _list.add(btn9); 327 | 328 | function requestLOCATION(e:MouseEvent):void 329 | { 330 | PermissionCheck.request(PermissionCheck.SOURCE_LOCATION, onRequestResult); 331 | } 332 | 333 | var btn10:MySprite = createBtn("request SENSORS"); 334 | btn10.addEventListener(MouseEvent.CLICK, requestSENSORS); 335 | _list.add(btn10); 336 | 337 | function requestSENSORS(e:MouseEvent):void 338 | { 339 | PermissionCheck.request(PermissionCheck.SOURCE_SENSORS, onRequestResult); 340 | } 341 | 342 | var btn11:MySprite = createBtn("request SMS"); 343 | btn11.addEventListener(MouseEvent.CLICK, requestSMS); 344 | _list.add(btn11); 345 | 346 | function requestSMS(e:MouseEvent):void 347 | { 348 | PermissionCheck.request(PermissionCheck.SOURCE_SMS, onRequestResult); 349 | } 350 | 351 | var btn12:MySprite = createBtn("request ALL"); 352 | btn12.addEventListener(MouseEvent.CLICK, requestALL); 353 | _list.add(btn12); 354 | 355 | function requestALL(e:MouseEvent):void 356 | { 357 | PermissionCheck.requestMulti( 358 | [ 359 | PermissionCheck.SOURCE_CAMERA, 360 | PermissionCheck.SOURCE_MIC, 361 | PermissionCheck.SOURCE_CONTACTS, 362 | PermissionCheck.SOURCE_CALENDAR, 363 | PermissionCheck.SOURCE_PHONE, 364 | PermissionCheck.SOURCE_LOCATION, 365 | PermissionCheck.SOURCE_STORAGE, 366 | PermissionCheck.SOURCE_SENSORS, 367 | PermissionCheck.SOURCE_SMS 368 | ], 369 | onRequestMultiResult 370 | ); 371 | } 372 | } 373 | } 374 | 375 | private function onRequestResult($obj:Object):void 376 | { 377 | C.log("permission for " + $obj.source + ": " + prettify($obj.state)); 378 | } 379 | 380 | private function onRequestMultiResult($arr:Array):void 381 | { 382 | for(var i:int=0; i < $arr.length; i++) 383 | { 384 | C.log("permission for " + $arr[i].source + ": " + prettify($arr[i].state)) 385 | } 386 | } 387 | 388 | private function prettify($state:int):String 389 | { 390 | var str:String; 391 | 392 | switch($state) 393 | { 394 | case PermissionCheck.PERMISSION_UNKNOWN: 395 | 396 | str = "UNKNOWN"; 397 | 398 | break; 399 | case PermissionCheck.PERMISSION_DENIED: 400 | 401 | str = "DENIED"; 402 | 403 | break; 404 | case PermissionCheck.PERMISSION_GRANTED: 405 | 406 | str = "GRANTED"; 407 | 408 | break; 409 | case PermissionCheck.PERMISSION_OS_ERR: 410 | 411 | str = "Not available!"; 412 | 413 | break; 414 | } 415 | 416 | return str; 417 | } 418 | 419 | 420 | 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | private function createBtn($str:String, $bgColor:uint=0xDFE4FF):MySprite 443 | { 444 | var sp:MySprite = new MySprite(); 445 | sp.addEventListener(MouseEvent.MOUSE_OVER, onOver); 446 | sp.addEventListener(MouseEvent.MOUSE_OUT, onOut); 447 | sp.addEventListener(MouseEvent.CLICK, onOut); 448 | sp.bgAlpha = 1; 449 | sp.bgColor = $bgColor; 450 | sp.drawBg(); 451 | sp.width = BTN_WIDTH * DeviceInfo.dpiScaleMultiplier; 452 | sp.height = BTN_HEIGHT * DeviceInfo.dpiScaleMultiplier; 453 | 454 | function onOver(e:MouseEvent):void 455 | { 456 | sp.bgAlpha = 1; 457 | sp.bgColor = 0xFFDB48; 458 | sp.drawBg(); 459 | } 460 | 461 | function onOut(e:MouseEvent):void 462 | { 463 | sp.bgAlpha = 1; 464 | sp.bgColor = $bgColor; 465 | sp.drawBg(); 466 | } 467 | 468 | var format:TextFormat = new TextFormat("Arimo", 16, 0x666666, null, null, null, null, null, TextFormatAlign.CENTER); 469 | 470 | var txt:TextField = new TextField(); 471 | txt.autoSize = TextFieldAutoSize.LEFT; 472 | txt.antiAliasType = AntiAliasType.ADVANCED; 473 | txt.mouseEnabled = false; 474 | txt.multiline = true; 475 | txt.wordWrap = true; 476 | txt.scaleX = txt.scaleY = DeviceInfo.dpiScaleMultiplier; 477 | txt.width = sp.width * (1 / DeviceInfo.dpiScaleMultiplier); 478 | txt.defaultTextFormat = format; 479 | txt.text = $str; 480 | 481 | txt.y = sp.height - txt.height >> 1; 482 | sp.addChild(txt); 483 | 484 | return sp; 485 | } 486 | } 487 | 488 | } --------------------------------------------------------------------------------