diff --git a/.settings/com.powerflasher.fdt.classpath b/.settings/com.powerflasher.fdt.classpath
index 6763a89..540ae14 100644
--- a/.settings/com.powerflasher.fdt.classpath
+++ b/.settings/com.powerflasher.fdt.classpath
@@ -19,4 +19,5 @@
libs/MonsterDebuggerMobile.swc
Gestouch
frameworks/libs/mx/mx.swc
+ libs/starling.swc
diff --git a/.settings/com.powerflasher.fdt.core.prefs b/.settings/com.powerflasher.fdt.core.prefs
index 0d4740a..51e3305 100644
--- a/.settings/com.powerflasher.fdt.core.prefs
+++ b/.settings/com.powerflasher.fdt.core.prefs
@@ -1,4 +1,4 @@
-#Mon Apr 25 18:42:57 EEST 2011
+#Thu Mar 08 20:28:06 EET 2012
com.powerflasher.fdt.core.CompatiblePlayers=AIR_Debug_Launcher
com.powerflasher.fdt.core.CompilerArguments=-load-config\="{flexSDK}/frameworks/airmobile-config.xml"\n-target-player\={playerVersion}\n-library-path+\="{flexSDK}/frameworks/locale/en_US"
com.powerflasher.fdt.core.DefaultOutputFolder=bin
@@ -8,8 +8,8 @@ com.powerflasher.fdt.core.PassClasspath=true
com.powerflasher.fdt.core.PassMainclass=true
com.powerflasher.fdt.core.PassRsls=false
com.powerflasher.fdt.core.PassSwcs=true
-com.powerflasher.fdt.core.PlayerVersion=10.2
+com.powerflasher.fdt.core.PlayerVersion=11.1
com.powerflasher.fdt.core.ProjectTypeHint=Flex 4.5 Mobile
com.powerflasher.fdt.core.Runtime=AIR
-com.powerflasher.fdt.core.SdkName=Flex 4.5
+com.powerflasher.fdt.core.SdkName=Flex 4.6
eclipse.preferences.version=1
diff --git a/back-button.psd b/back-button.psd
new file mode 100644
index 0000000..d2affa7
Binary files /dev/null and b/back-button.psd differ
diff --git a/build.template.properties b/build.template.properties
index f1c0ae2..9424db8 100644
--- a/build.template.properties
+++ b/build.template.properties
@@ -1,7 +1,7 @@
# IMPORTANT Change to your local system paths before using ANT
# Flex SDK related properties
-FLEX_HOME = path-to-flex-4.5-SDK#/Users/fljot/Development/SDKs/flex_sdk_4.5
+FLEX_HOME = path-to-flex-4.6-SDK(AIR 3.2)#/Users/fljot/Development/SDKs/flex_sdk_4.6
flexSDK.dir = ${FLEX_HOME}
flexSDK.adl = ${flexSDK.dir}/bin/adl
flexSDK.adt = ${flexSDK.dir}/lib/adt.jar
@@ -29,7 +29,7 @@ binrelease.dir = ${basedir}/bin
# Input
project.examplesPackage.dir = org/gestouch/examples
project.targetPlayerVersion = 10.2
-project.baseCompilerArguments = -default-size=800,600 --target-player=${project.targetPlayerVersion} -static-link-runtime-shared-libraries=true
+project.baseCompilerArguments = -default-size=800,600 --target-player=${project.targetPlayerVersion} -static-link-runtime-shared-libraries=true -swf-version=15
project.mobileCompilerArguments = -preloader=spark.preloaders.SplashScreen -theme="${flexSDK.dir}/frameworks/themes/Mobile/mobile.swc"
project.debugCompilerArguments = -define=CONFIG::Debug,true -define+=CONFIG::Release,false -verbose-stacktraces=true
project.releaseCompilerArguments = -define=CONFIG::Debug,false -define+=CONFIG::Release,true
diff --git a/build/air/descriptor-template-app.xml b/build/air/descriptor-template-app.xml
index ead1b3c..46fac86 100644
--- a/build/air/descriptor-template-app.xml
+++ b/build/air/descriptor-template-app.xml
@@ -1,5 +1,5 @@
-
+
-
+ direct
diff --git a/build/android/descriptor-template-apk.xml b/build/android/descriptor-template-apk.xml
index 3ec687d..356f887 100644
--- a/build/android/descriptor-template-apk.xml
+++ b/build/android/descriptor-template-apk.xml
@@ -1,5 +1,5 @@
-
+
-
-
true
-
true
+ direct
-
+
+ false
diff --git a/build/iOS/descriptor-template-ipa.xml b/build/iOS/descriptor-template-ipa.xml
index 97c332d..b5b03de 100644
--- a/build/iOS/descriptor-template-ipa.xml
+++ b/build/iOS/descriptor-template-ipa.xml
@@ -1,5 +1,5 @@
-
+
-
-
true
-
true
+ direct
-
+
+ false
diff --git a/libs/starling.swc b/libs/starling.swc
new file mode 100644
index 0000000..e819182
Binary files /dev/null and b/libs/starling.swc differ
diff --git a/src/assets/images/back-button.png b/src/assets/images/back-button.png
new file mode 100644
index 0000000..8386161
Binary files /dev/null and b/src/assets/images/back-button.png differ
diff --git a/src/org/gestouch/examples/model/ExamplesModel.as b/src/org/gestouch/examples/model/ExamplesModel.as
index 8484b4e..573767d 100644
--- a/src/org/gestouch/examples/model/ExamplesModel.as
+++ b/src/org/gestouch/examples/model/ExamplesModel.as
@@ -1,12 +1,15 @@
package org.gestouch.examples.model
{
- import org.gestouch.examples.views.DependentSwipingGesturesView;
+ import org.gestouch.examples.starling.ConflictGesturesExample;
+ import org.gestouch.examples.starling.TransformedViewportExample;
import org.gestouch.examples.views.ConflictGesturesView;
+ import org.gestouch.examples.views.DependentSwipingGesturesView;
import org.gestouch.examples.views.DependentTapGesturesView;
import org.gestouch.examples.views.LongPressGestureAdvancedView;
import org.gestouch.examples.views.LongPressGestureView;
import org.gestouch.examples.views.PanGestureView;
import org.gestouch.examples.views.RotateGestureView;
+ import org.gestouch.examples.views.StarlingExampleViewBase;
import org.gestouch.examples.views.SwipeGestureView;
import org.gestouch.examples.views.TapGestureUsageView;
import org.gestouch.examples.views.TapGestureView;
@@ -35,9 +38,9 @@ package org.gestouch.examples.model
,{label: "Conflicts Resolution Example", viewClass: ConflictGesturesView}
,{label: "Dependent Tap Gestures Example", viewClass: DependentTapGesturesView}
,{label: "Dependent Swiping Gestures Example", viewClass: DependentSwipingGesturesView}
+ ,{label: "Starling: Conflicts Example", viewClass: StarlingExampleViewBase, starlingMainClass: ConflictGesturesExample}
+ ,{label: "Starling: Transformed Viewport Example", viewClass: StarlingExampleViewBase, starlingMainClass: TransformedViewportExample}
]
);
-
- public var lastViewTitle:String;
}
}
\ No newline at end of file
diff --git a/src/org/gestouch/examples/starling/ConflictGesturesExample.as b/src/org/gestouch/examples/starling/ConflictGesturesExample.as
new file mode 100644
index 0000000..bd3e1a6
--- /dev/null
+++ b/src/org/gestouch/examples/starling/ConflictGesturesExample.as
@@ -0,0 +1,193 @@
+package org.gestouch.examples.starling
+{
+ import starling.display.DisplayObject;
+ import starling.display.Image;
+ import starling.display.Sprite;
+ import starling.textures.Texture;
+
+ import com.greensock.TweenMax;
+
+ import org.gestouch.core.GestureState;
+ import org.gestouch.core.IGestureDelegate;
+ import org.gestouch.core.Touch;
+ import org.gestouch.events.TapGestureEvent;
+ import org.gestouch.events.TransformGestureEvent;
+ import org.gestouch.gestures.Gesture;
+ import org.gestouch.gestures.TapGesture;
+ import org.gestouch.gestures.TransformGesture;
+ import org.gestouch.utils.GestureUtils;
+
+ import flash.geom.Matrix;
+ import flash.geom.Point;
+
+
+ /**
+ * @author Pavel fljot
+ */
+ public class ConflictGesturesExample extends StarlingExampleBase implements IGestureDelegate
+ {
+ [Embed(source="/assets/images/YellowSquare.png")]
+ private static const yellowAsset:Class;
+ [Embed(source="/assets/images/CyanSquare.png")]
+ private static const cyanAsset:Class;
+ [Embed(source="/assets/images/MagentaSquare.png")]
+ private static const magentaAsset:Class;
+
+ private var container:Sprite;
+ private var containerIsTransforming:Boolean;
+ private var innerActiveTransformGesturesCounter:uint;
+
+
+ public function ConflictGesturesExample()
+ {
+ super();
+ }
+
+
+ override protected function init():void
+ {
+ super.init();
+
+ container = new Sprite();
+ addChild(container);
+
+ var freeTransform:TransformGesture = new TransformGesture(stage);
+ freeTransform.addEventListener(TransformGestureEvent.GESTURE_TRANSFORM, onTransform, false, 0, true);
+ freeTransform.delegate = this;
+
+ var image:Image;
+ image = addImage(Texture.fromBitmap(new yellowAsset()));
+ image.x = stage.stageWidth - 3 * image.width >> 1;
+ image.y = stage.stageHeight - 3 * image.height >> 1;
+ container.addChild(image);
+ image = addImage(Texture.fromBitmap(new cyanAsset()));
+ image.x = stage.stageWidth - image.width >> 1;
+ image.y = stage.stageHeight - image.height >> 1;
+ container.addChild(image);
+ image = addImage(Texture.fromBitmap(new magentaAsset()));
+ image.x = stage.stageWidth + image.width >> 1;
+ image.y = stage.stageHeight + image.height >> 1;
+ container.addChild(image);
+ }
+
+
+ private function addImage(texture:Texture):Image
+ {
+ var image:Image = new Image(texture);
+ image.width = image.height = Math.min(stage.stageWidth, stage.stageHeight) / 3;
+
+ var tap:TapGesture = new TapGesture(image);
+ tap.addEventListener(TapGestureEvent.GESTURE_TAP, onTap, false, 0, true);
+
+ var freeTransform:TransformGesture = new TransformGesture(image);
+ freeTransform.addEventListener(TransformGestureEvent.GESTURE_TRANSFORM, onTransform, false, 0, true);
+ freeTransform.delegate = this;
+
+ return image;
+ }
+
+
+ private function onTransform(event:TransformGestureEvent):void
+ {
+ var target:DisplayObject = (event.target as Gesture).target as DisplayObject;
+ if (target == stage)
+ {
+ target = container;
+
+ if (event.gestureState == GestureState.BEGAN)
+ {
+ containerIsTransforming = true;
+ }
+ else if (event.gestureState == GestureState.ENDED || event.gestureState == GestureState.CANCELLED)
+ {
+ containerIsTransforming = false;
+ }
+ }
+ else
+ {
+ if (event.gestureState == GestureState.BEGAN)
+ {
+ innerActiveTransformGesturesCounter++;
+ }
+ else if (event.gestureState == GestureState.ENDED || event.gestureState == GestureState.CANCELLED)
+ {
+ innerActiveTransformGesturesCounter--;
+ }
+
+ // Recalculate offsets in case some parent is transformed
+ if (event.offsetX != 0 || event.offsetY != 0)
+ {
+ var offset:Point = target.parent.globalToLocal(new Point(event.offsetX, event.offsetY)).subtract(target.parent.globalToLocal(GestureUtils.GLOBAL_ZERO));
+ event.offsetX = offset.x;
+ event.offsetY = offset.y;
+ }
+ }
+
+ // Panning
+ target.x += event.offsetX;
+ target.y += event.offsetY;
+
+ if (event.scaleX != 1 || event.rotation != 0)
+ {
+ var m:Matrix = target.getTransformationMatrix(target.parent);
+
+ // Scale and rotation.
+ // NB! event.localX and event.stageX actually represent previous
+ // location of the centroid (middle point between two fingers so you
+ // can easely perform these transformations without any additional transformations.
+ var transformPoint:Point = m.transformPoint(new Point(event.localX, event.localY));
+ m.translate(-transformPoint.x, -transformPoint.y);
+ m.rotate(event.rotation * GestureUtils.DEGREES_TO_RADIANS);
+ m.scale(event.scaleX, event.scaleY);
+ m.translate(transformPoint.x, transformPoint.y);
+
+ target.x = m.tx;
+ target.y = m.ty;
+ target.rotation = Math.atan2(m.b, m.a);
+ target.scaleX = target.scaleY = Math.sqrt(m.a*m.a + m.b*m.b);
+ }
+ }
+
+
+ private function onTap(event:TapGestureEvent):void
+ {
+ trace("tap");
+ TweenMax.to((event.target as Gesture).target, 0.5, {bezierThrough:[{alpha:0.1}, {alpha:1}]});
+ }
+
+
+ public function gestureShouldReceiveTouch(gesture:Gesture, touch:Touch):Boolean
+ {
+ if (containerIsTransforming && gesture is TransformGesture && container.contains(gesture.target as DisplayObject))
+ {
+ // Let the inner transform gestures don't even receive touch
+ // if container's transform gesture is in progress
+ return false;
+ }
+
+ if (gesture is TransformGesture && gesture.target == stage && innerActiveTransformGesturesCounter > 0)
+ {
+ // One or more inner squares are currently transforming.
+ // To prevent strange offsets we ignore this touch for our stage transform gesture
+ return false;
+ }
+
+ // Default behavior
+ return true;
+ }
+
+
+ public function gestureShouldBegin(gesture:Gesture):Boolean
+ {
+ // Default behavior
+ return true;
+ }
+
+
+ public function gesturesShouldRecognizeSimultaneously(gesture:Gesture, otherGesture:Gesture):Boolean
+ {
+ // Default behavior
+ return false;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/org/gestouch/examples/starling/StarlingExampleBase.as b/src/org/gestouch/examples/starling/StarlingExampleBase.as
new file mode 100644
index 0000000..d78f3d8
--- /dev/null
+++ b/src/org/gestouch/examples/starling/StarlingExampleBase.as
@@ -0,0 +1,81 @@
+package org.gestouch.examples.starling
+{
+ import starling.core.Starling;
+ import starling.display.Image;
+ import starling.display.Sprite;
+ import starling.events.Event;
+ import starling.events.ResizeEvent;
+ import starling.events.Touch;
+ import starling.events.TouchEvent;
+ import starling.events.TouchPhase;
+ import starling.textures.Texture;
+
+ import flash.geom.Rectangle;
+ import flash.utils.setTimeout;
+
+
+ /**
+ * @author Pavel fljot
+ */
+ public class StarlingExampleBase extends Sprite
+ {
+ [Embed(source="/assets/images/back-button.png")]
+ private static const backButtonImage:Class;
+
+ private var backButton:Image;
+
+
+ public function StarlingExampleBase()
+ {
+ addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
+ }
+
+
+ public function resize(width:int, height:int):void
+ {
+ const rect:Rectangle = new Rectangle(0, 0, width, height);
+ const starling:Starling = Starling.current;
+ starling.viewPort = rect;
+ starling.stage.stageWidth = rect.width;
+ starling.stage.stageHeight = rect.height;
+
+ onResize(starling.stage.stageWidth, starling.stage.stageHeight);
+ }
+
+
+ protected function onResize(width:Number, height:Number):void
+ {
+
+ }
+
+
+ private function onAddedToStage(event:Event):void
+ {
+ removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
+
+ init();
+ }
+
+
+ protected function init():void
+ {
+ backButton = new Image(Texture.fromBitmap(new backButtonImage()));
+ backButton.x = backButton.y = 3;
+ backButton.scaleX = backButton.scaleY = 2;
+ backButton.addEventListener(TouchEvent.TOUCH, backButton_touchHandler);
+ addChild(backButton);
+
+ setTimeout(resize, 1, stage.stageWidth, stage.stageHeight);
+ }
+
+
+ private function backButton_touchHandler(event:TouchEvent):void
+ {
+ var touch:Touch = event.touches[0] as Touch;
+ if (touch.phase == TouchPhase.ENDED)
+ {
+ stage.dispatchEvent(new Event("quit"));
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/org/gestouch/examples/starling/TransformedViewportExample.as b/src/org/gestouch/examples/starling/TransformedViewportExample.as
new file mode 100644
index 0000000..68d398d
--- /dev/null
+++ b/src/org/gestouch/examples/starling/TransformedViewportExample.as
@@ -0,0 +1,63 @@
+package org.gestouch.examples.starling
+{
+ import starling.textures.Texture;
+ import starling.core.Starling;
+ import starling.display.Image;
+
+ import com.greensock.TweenMax;
+
+ import org.gestouch.events.TapGestureEvent;
+ import org.gestouch.gestures.Gesture;
+ import org.gestouch.gestures.TapGesture;
+
+ import flash.geom.Rectangle;
+
+
+ /**
+ * @author Pavel fljot
+ */
+ public class TransformedViewportExample extends StarlingExampleBase
+ {
+ [Embed(source="/assets/images/YellowSquare.png")]
+ private static const yellowAsset:Class;
+
+
+ public function TransformedViewportExample()
+ {
+ super();
+ }
+
+
+ override public function resize(width:int, height:int):void
+ {
+ const rect:Rectangle = new Rectangle(100, 100, width - 200, height - 200);
+ const starling:Starling = Starling.current;
+ starling.viewPort = rect;
+ starling.stage.stageWidth = rect.width;
+ starling.stage.stageHeight = rect.height;
+
+ onResize(starling.stage.stageWidth, starling.stage.stageHeight);
+ }
+
+
+ override protected function init():void
+ {
+ super.init();
+
+ var image:Image = new Image(Texture.fromBitmap(new yellowAsset()));
+ //image.width = image.height = Math.min(stage.stageWidth, stage.stageHeight) / 3;
+ image.y = 50;
+ addChild(image);
+
+ var tap:TapGesture = new TapGesture(image);
+ tap.addEventListener(TapGestureEvent.GESTURE_TAP, onTap, false, 0, true);
+ }
+
+
+ private function onTap(event:TapGestureEvent):void
+ {
+ trace("tap");
+ TweenMax.to((event.target as Gesture).target, 0.5, {bezierThrough:[{alpha:0.1}, {alpha:1}]});
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/org/gestouch/examples/views/ExampleViewBase.as b/src/org/gestouch/examples/views/ExampleViewBase.as
index 260a213..525efe0 100644
--- a/src/org/gestouch/examples/views/ExampleViewBase.as
+++ b/src/org/gestouch/examples/views/ExampleViewBase.as
@@ -4,8 +4,6 @@ package org.gestouch.examples.views
import spark.components.View;
import spark.events.ViewNavigatorEvent;
- import org.gestouch.examples.model.ExamplesModel;
-
import mx.core.UIComponent;
import mx.events.FlexEvent;
import mx.events.ResizeEvent;
@@ -25,9 +23,6 @@ package org.gestouch.examples.views
private var backButton:Button;
private var settingsButton:Button;
- [Bindable]
- protected var dataModel:ExamplesModel;
-
public function ExampleViewBase()
{
@@ -85,13 +80,11 @@ package org.gestouch.examples.views
protected function onViewActivate():void
{
- if (!dataModel && data)
- {
- dataModel = data as ExamplesModel;
-
- if (dataModel.lastViewTitle)
+ if (data)
+ {
+ if (data.hasOwnProperty("title"))
{
- title = dataModel.lastViewTitle;
+ title = data.title;
}
}
}
diff --git a/src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml b/src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml
index 9a7f61d..20600a4 100644
--- a/src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml
+++ b/src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml
@@ -9,6 +9,8 @@
>
-1)
{
- var exampleName:String = list.selectedItem.label;
- dataModel.lastViewTitle = exampleName;
+ const data:Object = {};
+ for (var k:* in list.selectedItem)
+ {
+ data[k] = list.selectedItem[k];
+ }
+ data.title = list.selectedItem.label;
var viewClass:Class = list.selectedItem.viewClass;
- navigator.pushView(viewClass, dataModel);
+ navigator.pushView(viewClass, data);
}
}
diff --git a/src/org/gestouch/examples/views/StarlingExampleViewBase.as b/src/org/gestouch/examples/views/StarlingExampleViewBase.as
new file mode 100644
index 0000000..76aa093
--- /dev/null
+++ b/src/org/gestouch/examples/views/StarlingExampleViewBase.as
@@ -0,0 +1,96 @@
+package org.gestouch.examples.views
+{
+ import starling.core.Starling;
+ import starling.display.DisplayObject;
+ import starling.events.ResizeEvent;
+
+ import org.gestouch.core.Gestouch;
+ import org.gestouch.examples.starling.StarlingExampleBase;
+ import org.gestouch.extensions.starling.StarlingDisplayListAdapter;
+ import org.gestouch.extensions.starling.StarlingTouchHitTester;
+ import org.gestouch.input.NativeInputAdapter;
+
+
+ /**
+ * @author Pavel fljot
+ */
+ public class StarlingExampleViewBase extends ExampleViewBase
+ {
+ protected var starling:Starling;
+ private var starlingTouchHitTester:StarlingTouchHitTester;
+
+ {
+ initStarlingAndGestouchForStarling();
+ }
+
+
+ public function StarlingExampleViewBase()
+ {
+ super();
+ }
+
+
+ private static function initStarlingAndGestouchForStarling():void
+ {
+ Starling.multitouchEnabled = true; // useful on mobile devices
+ Starling.handleLostContext = true; // deactivate on mobile devices (to save memory)
+
+ Gestouch.addDisplayListAdapter(starling.display.DisplayObject, new StarlingDisplayListAdapter());
+ }
+
+
+ override protected function init():void
+ {
+ super.init();
+
+ var starlingMainClass:Class = data.starlingMainClass as Class;
+
+ starling = new Starling(starlingMainClass, stage);
+ starling.enableErrorChecking = true;
+ starling.stage.color = 0xEFEFEF;
+// starling.stage.addEventListener(ResizeEvent.RESIZE, starling_resizeHandler);
+ starling.stage.addEventListener("quit", quitHandler);
+ starling.start();
+
+ // Initialized native (default) input adapter. Needed for non-DisplayList usage.
+ Gestouch.inputAdapter ||= new NativeInputAdapter(stage);
+
+ starlingTouchHitTester = new StarlingTouchHitTester(starling);
+ Gestouch.addTouchHitTester(starlingTouchHitTester, -1);
+
+ root.visible = false;
+ }
+
+
+ private function quitHandler(...args):void
+ {
+ navigator.popView();
+ }
+
+
+ override protected function onViewDeactivate():void
+ {
+ super.onViewDeactivate();
+
+ if (starlingTouchHitTester)
+ {
+ Gestouch.removeTouchHitTester(starlingTouchHitTester);
+ starlingTouchHitTester = null;
+ }
+
+ starling.stage.removeEventListener(ResizeEvent.RESIZE, starling_resizeHandler);
+ starling.stage.removeEventListener("quit", quitHandler);
+
+ starling.dispose();
+ starling = null;
+
+ root.visible = true;
+ }
+
+
+ private function starling_resizeHandler(event:ResizeEvent):void
+ {
+ (starling.stage.getChildAt(0) as StarlingExampleBase).resize(event.width, event.height);
+ }
+ }
+}
\ No newline at end of file
diff --git a/src_external/fr/kouma/starling/utils/Stats.as b/src_external/fr/kouma/starling/utils/Stats.as
new file mode 100644
index 0000000..a21fda2
--- /dev/null
+++ b/src_external/fr/kouma/starling/utils/Stats.as
@@ -0,0 +1,250 @@
+/**
+ * Stats.as, a Starling port of Mrdoob Stat.as
+ * For original version, see :
+ * https://github.com/mrdoob/Hi-ReS-Stats
+ *
+ * And :
+ * http://www.starling-framework.org
+ *
+ * Released under MIT license:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * How to use:
+ *
+ * addChild( new Stats() );
+ *
+ *
+ * Author : Nicolas Gans
+ * To get the latest updates and make suggestions,
+ * see : http://forum.starling-framework.org/topic/starling-port-of-mrdoobs-stats-class
+ *
+ *
+ * HISTORY :
+ *
+ * 2011-09-26
+ * V0.3 :
+ * - since a commit (https://github.com/PrimaryFeather/Starling-Framework/commit/f0a1a18ffff727c2c83f6eeaca13aa59ecdb2bd7)
+ * gives us access to the nativeStage in the Starling.as class, I just removed the dirty hack of version 0.2
+ * *** PLEASE UPDATE your Starling framework to the last version ***
+ *
+ * 2011-09-23
+ * V0.2 :
+ * - added Bitmap Font support for better performances and display
+ * - Use a dirty hack to access to flash.display.Stage::frameRate since we have no access to the stage.frameRate in Starling
+ * Now you don't have to pass the frameRate to the constructor
+ *
+ * 2011-09-22
+ * V0.1 :
+ * - First version, quick port of Mrdoob's Stats
+ *
+ **/
+package fr.kouma.starling.utils
+{
+ import flash.display.Bitmap;
+ import flash.display.BitmapData;
+ import flash.display.Stage;
+ import flash.geom.Rectangle;
+ import flash.system.System;
+
+ import starling.core.Starling;
+ import starling.display.Image;
+ import starling.display.Sprite;
+ import starling.events.EnterFrameEvent;
+ import starling.events.Event;
+ import starling.events.Touch;
+ import starling.events.TouchEvent;
+ import starling.events.TouchPhase;
+ import starling.text.BitmapFont;
+ import starling.text.TextField;
+ import starling.textures.Texture;
+ import starling.utils.HAlign;
+
+ public class Stats extends Sprite
+ {
+
+ protected static const version:String = "V0.3";
+
+ protected const WIDTH:uint = 70;
+ protected const HEIGHT:uint = 100;
+
+ protected var fps:uint;
+ protected var ms:uint;
+ protected var mem:Number;
+ protected var memMax:Number;
+
+ protected var frameTime:Number = 0;
+ protected var frameCount:uint;
+
+ protected var colors:Colors = new Colors();
+
+ protected var fpsText:TextField;
+ protected var msText:TextField;
+ protected var memText:TextField;
+ protected var memMaxText:TextField;
+
+ protected var graphHeight:Number;
+ protected var graphWidth:Number;
+ protected var graphTexture:Texture;
+ protected var graphImage:Image;
+
+ protected const GRAPH_Y:Number = 50;
+
+ protected var graphBuffer:BitmapData;
+ protected var rectangle:Rectangle;
+
+ protected var fpsGraph:uint;
+ protected var memGraph:uint;
+ protected var memMaxGraph:uint;
+
+ protected var nativeStage:flash.display.Stage;
+
+ protected var fontSize:Number = 10;
+ protected var fontFamily:String = "standard 07_55";
+
+ [Embed(source = "standard_07_55.png")]
+ protected static const StandardAtlas:Class;
+
+ [Embed(source="standard_07_55.fnt", mimeType="application/octet-stream")]
+ protected static const StandardXML:Class;
+
+ public function Stats():void
+ {
+ init();
+ }
+
+ protected function init():void
+ {
+ // access to nativeStage thx to commit
+ // see https://github.com/PrimaryFeather/Starling-Framework/commit/f0a1a18ffff727c2c83f6eeaca13aa59ecdb2bd7
+ nativeStage = Starling.current.nativeStage;
+
+ memMax = 0;
+
+ var spacer:Number = 6;
+
+ // bitmap font
+ var fontBitmap:Bitmap = new StandardAtlas();
+ var fontTexture:Texture = Texture.fromBitmap(fontBitmap);
+ var fontXML:XML = XML(new StandardXML());
+ TextField.registerBitmapFont(new BitmapFont(fontTexture, fontXML));
+
+ fontSize = BitmapFont.NATIVE_SIZE;
+
+ fpsText = new TextField(WIDTH, 14, "FPS: ?", fontFamily, fontSize, colors.fps);
+ fpsText.hAlign = HAlign.LEFT;
+
+ msText = new TextField(WIDTH, 14, "MS: ?", fontFamily, fontSize, colors.ms);
+ msText.y = fpsText.y + fpsText.height - spacer;
+ msText.hAlign = HAlign.LEFT;
+
+ memText = new TextField(WIDTH, 14, "MEM: ?", fontFamily, fontSize, colors.mem);
+ memText.y = msText.y + msText.height - spacer;
+ memText.hAlign = HAlign.LEFT;
+
+ memMaxText = new TextField(WIDTH, 14, "MAX: ?", fontFamily, fontSize, colors.memmax);
+ memMaxText.y = memText.y + memText.height - spacer;
+ memMaxText.hAlign = HAlign.LEFT;
+
+ rectangle = new Rectangle(WIDTH - 1, GRAPH_Y, 1, HEIGHT - GRAPH_Y);
+ graphHeight = HEIGHT - GRAPH_Y;
+ graphWidth = WIDTH - 1;
+
+ addEventListener(starling.events.Event.ADDED_TO_STAGE, onAdded);
+ addEventListener(starling.events.Event.REMOVED_FROM_STAGE, destroy);
+ }
+
+ protected function onAdded(event:Event):void
+ {
+
+ addChild(fpsText);
+ addChild(msText);
+ addChild(memText);
+ addChild(memMaxText);
+
+ graphBuffer = new BitmapData(WIDTH, HEIGHT, false, colors.bg);
+ graphTexture = Texture.fromBitmapData(graphBuffer);
+ graphImage = new Image(graphTexture);
+ addChildAt(graphImage, 0);
+
+ // since the frameRate is stuck at 60 fps, we don't need this one
+ //addEventListener(TouchEvent.TOUCH, onClick);
+ addEventListener(starling.events.Event.ENTER_FRAME, update);
+
+ }
+
+ // since the frameRate is stuck at 60 fps, we don't need this one
+ protected function onClick(event:TouchEvent):void
+ {
+ var touch:Touch = event.getTouch(this);
+
+ if (touch && touch.phase == TouchPhase.BEGAN)
+ {
+ var mouseY:Number = touch.getLocation(this).y;
+ mouseY / HEIGHT > .5 ? nativeStage.frameRate-- : nativeStage.frameRate++;
+ fpsText.text = "FPS: " + fps + " / " + nativeStage.frameRate;
+ }
+ }
+
+ protected function destroy(event:Event):void
+ {
+ removeChildren();
+ graphBuffer.dispose();
+ graphImage.dispose();
+ removeEventListener(starling.events.Event.ENTER_FRAME, update);
+ //removeEventListener(TouchEvent.TOUCH, onClick);
+ }
+
+ protected function update(event:EnterFrameEvent) : void
+ {
+
+ frameCount++;
+ frameTime += event.passedTime;
+
+ ms = event.passedTime * 1000;
+ msText.text = "MS: " + ms;
+
+ if (frameTime > 1)
+ {
+ fps = int(frameCount / frameTime);
+
+ fpsText.text = "FPS: " + fps + " / " + nativeStage.frameRate;
+
+ mem = Number((System.totalMemory * 0.000000954).toFixed(3));
+ memMax = memMax > mem ? memMax : mem;
+
+ memText.text = "MEM: " + String(mem);
+ memMaxText.text = "MAX: " + String(memMax);
+
+ fpsGraph = Math.min(graphHeight, ( fps / nativeStage.frameRate ) * graphHeight);
+ memGraph = Math.min(graphHeight, Math.sqrt(Math.sqrt(mem * 5000))) - 2;
+ memMaxGraph = Math.min(graphHeight, Math.sqrt(Math.sqrt(memMax * 5000))) - 2;
+
+ graphBuffer.scroll(-1, 0);
+
+ graphBuffer.fillRect(rectangle, colors.bg);
+ graphBuffer.setPixel(graphWidth, graphHeight - fpsGraph + GRAPH_Y, colors.fps);
+ graphBuffer.setPixel(graphWidth, graphHeight - (ms >> 1) + GRAPH_Y, colors.ms);
+ graphBuffer.setPixel(graphWidth, graphHeight - memGraph + GRAPH_Y, colors.mem);
+ graphBuffer.setPixel(graphWidth, graphHeight - memMaxGraph + GRAPH_Y, colors.memmax);
+
+ graphImage.texture.dispose();
+ graphImage.texture = Texture.fromBitmapData(graphBuffer);
+
+ frameTime = frameCount = 0;
+ }
+
+
+ }
+
+ }
+}
+
+class Colors {
+
+ public var bg : uint = 0x000033;
+ public var fps : uint = 0xffff00;
+ public var ms : uint = 0x00ff00;
+ public var mem : uint = 0x00ffff;
+ public var memmax : uint = 0xff0070;
+
+}
\ No newline at end of file
diff --git a/src_external/fr/kouma/starling/utils/standard_07_55.fnt b/src_external/fr/kouma/starling/utils/standard_07_55.fnt
new file mode 100644
index 0000000..e66f823
--- /dev/null
+++ b/src_external/fr/kouma/starling/utils/standard_07_55.fnt
@@ -0,0 +1,212 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src_external/fr/kouma/starling/utils/standard_07_55.png b/src_external/fr/kouma/starling/utils/standard_07_55.png
new file mode 100644
index 0000000..50bde67
Binary files /dev/null and b/src_external/fr/kouma/starling/utils/standard_07_55.png differ
diff --git a/src_external/net/hires/debug/Stats.as b/src_external/net/hires/debug/Stats.as
new file mode 100644
index 0000000..000b2ca
--- /dev/null
+++ b/src_external/net/hires/debug/Stats.as
@@ -0,0 +1,182 @@
+/**
+ * stats.as
+ * http://github.com/mrdoob/stats.as
+ *
+ * Released under MIT license:
+ * http://www.opensource.org/licenses/mit-license.php
+ *
+ * How to use:
+ *
+ * addChild( new Stats() );
+ *
+ **/
+
+package net.hires.debug {
+
+ import flash.display.BitmapData;
+ import flash.display.Sprite;
+ import flash.events.Event;
+ import flash.events.MouseEvent;
+ import flash.geom.Matrix;
+ import flash.geom.Rectangle;
+ import flash.system.System;
+ import flash.text.StyleSheet;
+ import flash.text.TextField;
+ import flash.utils.getTimer;
+
+ public class Stats extends Sprite {
+
+ protected const WIDTH : uint = 70;
+ protected const HEIGHT : uint = 100;
+
+ protected var xml : XML;
+
+ protected var text : TextField;
+ protected var style : StyleSheet;
+
+ protected var timer : uint;
+ protected var fps : uint;
+ protected var ms : uint;
+ protected var ms_prev : uint;
+ protected var mem : Number;
+ protected var mem_max : Number;
+
+ protected var graph : BitmapData;
+ protected var rectangle : Rectangle;
+
+ protected var fps_graph : uint;
+ protected var mem_graph : uint;
+ protected var mem_max_graph : uint;
+
+ protected var colors : Colors = new Colors();
+
+ /**
+ * Stats FPS, MS and MEM, all in one.
+ */
+ public function Stats() : void {
+
+ mouseChildren = false;
+ mem_max = 0;
+
+ xml = FPS:MS:MEM:MAX:;
+
+ style = new StyleSheet();
+ style.setStyle('xml', {fontSize:'9px', fontFamily:'_sans', leading:'-2px'});
+ style.setStyle('fps', {color: hex2css(colors.fps)});
+ style.setStyle('ms', {color: hex2css(colors.ms)});
+ style.setStyle('mem', {color: hex2css(colors.mem)});
+ style.setStyle('memMax', {color: hex2css(colors.memmax)});
+
+ text = new TextField();
+ text.width = WIDTH;
+ text.height = 50;
+ text.styleSheet = style;
+ text.condenseWhite = true;
+ text.selectable = false;
+ text.mouseEnabled = false;
+
+ rectangle = new Rectangle(WIDTH - 1, 0, 1, HEIGHT - 50);
+
+ addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
+ addEventListener(Event.REMOVED_FROM_STAGE, destroy, false, 0, true);
+
+ }
+
+ private function init(e : Event) : void {
+
+ graphics.beginFill(colors.bg);
+ graphics.drawRect(0, 0, WIDTH, HEIGHT);
+ graphics.endFill();
+
+ addChild(text);
+
+ graph = new BitmapData(WIDTH, HEIGHT - 50, false, colors.bg);
+ graphics.beginBitmapFill(graph, new Matrix(1, 0, 0, 1, 0, 50));
+ graphics.drawRect(0, 50, WIDTH, HEIGHT - 50);
+
+ addEventListener(MouseEvent.CLICK, onClick);
+ addEventListener(Event.ENTER_FRAME, update);
+
+ }
+
+ private function destroy(e : Event) : void {
+
+ graphics.clear();
+
+ while(numChildren > 0)
+ removeChildAt(0);
+
+ graph.dispose();
+
+ removeEventListener(MouseEvent.CLICK, onClick);
+ removeEventListener(Event.ENTER_FRAME, update);
+
+ }
+
+ private function update(e : Event) : void {
+
+ timer = getTimer();
+
+ if( timer - 1000 > ms_prev ) {
+
+ ms_prev = timer;
+ mem = Number((System.totalMemory * 0.000000954).toFixed(3));
+ mem_max = mem_max > mem ? mem_max : mem;
+
+ fps_graph = Math.min(graph.height, ( fps / stage.frameRate ) * graph.height);
+ mem_graph = Math.min(graph.height, Math.sqrt(Math.sqrt(mem * 5000))) - 2;
+ mem_max_graph = Math.min(graph.height, Math.sqrt(Math.sqrt(mem_max * 5000))) - 2;
+
+ graph.scroll(-1, 0);
+
+ graph.fillRect(rectangle, colors.bg);
+ graph.setPixel(graph.width - 1, graph.height - fps_graph, colors.fps);
+ graph.setPixel(graph.width - 1, graph.height - ( ( timer - ms ) >> 1 ), colors.ms);
+ graph.setPixel(graph.width - 1, graph.height - mem_graph, colors.mem);
+ graph.setPixel(graph.width - 1, graph.height - mem_max_graph, colors.memmax);
+
+ xml.fps = "FPS: " + fps + " / " + stage.frameRate;
+ xml.mem = "MEM: " + mem;
+ xml.memMax = "MAX: " + mem_max;
+
+ fps = 0;
+
+ }
+
+ fps++;
+
+ xml.ms = "MS: " + (timer - ms);
+ ms = timer;
+
+ text.htmlText = xml;
+ }
+
+ private function onClick(e : MouseEvent) : void {
+
+ mouseY / height > .5 ? stage.frameRate-- : stage.frameRate++;
+ xml.fps = "FPS: " + fps + " / " + stage.frameRate;
+ text.htmlText = xml;
+
+ }
+
+ // .. Utils
+
+ private function hex2css( color : int ) : String {
+
+ return "#" + color.toString(16);
+
+ }
+
+ }
+
+}
+
+class Colors {
+
+ public var bg : uint = 0x000033;
+ public var fps : uint = 0xffff00;
+ public var ms : uint = 0x00ff00;
+ public var mem : uint = 0x00ffff;
+ public var memmax : uint = 0xff0070;
+
+}
\ No newline at end of file