Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

For v0.4

Squashed commit of the following:

commit ae0e7f1
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Tue Aug 7 22:42:36 2012 +0300

    New build target: apk with captive runtime

commit c7bb31e
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Tue Aug 7 22:41:51 2012 +0300

    Example for touch and gesture cancelation

    Couldn't really test that because of a AIR bug on Android

commit a71709f
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Tue Aug 7 22:41:01 2012 +0300

    Update example for improved SwipeGesture

commit ea7f7e9
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Tue Aug 7 22:40:23 2012 +0300

    MXML gesture definition example

commit fd55737
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Jul 11 13:35:35 2012 +0300

    Change rotation values from degrees to radians

commit 6e818c5
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Thu Jul 5 10:19:09 2012 +0300

    Demo Gestouch fix in c2d31b743bbe0821d92dd815fc90f2b2b0071f83

commit 89f75ab
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Jul 4 21:52:20 2012 +0300

    Update IDE files

    (sorry for not ignoring those)

commit 4427c7f
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Jul 4 21:51:26 2012 +0300

    Cleanup build.xml

commit cafe1cb
Merge: 340a246 0e862b9
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Jul 4 21:50:53 2012 +0300

    Merge branch 'refs/heads/features/starling' into develop

commit 0e862b9
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Jul 4 21:50:32 2012 +0300

    Update for new API + one more example/test

commit 1b9573b
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Sun Mar 18 12:13:34 2012 +0200

    Fixes for simplified API

commit 17baeee
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Mar 14 15:23:00 2012 +0200

    starling initial commit

commit 340a246
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Mar 7 01:24:45 2012 +0200

    cleanup

commit 08f46c4
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Mar 7 01:24:35 2012 +0200

    Examples for requireGestureToFail API

commit a1715db
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Wed Mar 7 01:24:07 2012 +0200

    Update to reflect SwipeGesture API changes

commit 7158fcf
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Tue Mar 6 10:08:32 2012 +0200

    Updates to reflect last API changes

commit 2659881
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Fri Feb 17 16:30:30 2012 +0200

    Revert "Update for recent API changes"

    This reverts commit 8ae3814.

commit 8ae3814
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Fri Feb 3 16:06:00 2012 +0200

    Update for recent API changes

commit fb5994c
Author: Pavel fljot <pavel.fljot@gmail.com>
Date:   Tue Nov 22 02:37:28 2011 +0200

    Examples for the new architecture
  • Loading branch information...
commit 4d35bbc0065712d15c20bdaa9ad22007afea0e72 1 parent e06df55
@fljot authored
Showing with 1,294 additions and 167 deletions.
  1. +1 −0  .settings/com.powerflasher.fdt.classpath
  2. +4 −3 .settings/com.powerflasher.fdt.core.prefs
  3. BIN  back-button.psd
  4. +2 −2 build.template.properties
  5. +87 −17 build.xml
  6. +2 −2 build/air/descriptor-template-app.xml
  7. +4 −5 build/android/descriptor-template-apk.xml
  8. +4 −5 build/iOS/descriptor-template-ipa.xml
  9. BIN  libs/starling.swc
  10. BIN  src/assets/images/back-button.png
  11. +6 −3 src/org/gestouch/examples/model/ExamplesModel.as
  12. +228 −0 src/org/gestouch/examples/starling/ConflictGesturesExample.as
  13. +81 −0 src/org/gestouch/examples/starling/StarlingExampleBase.as
  14. +63 −0 src/org/gestouch/examples/starling/TransformedViewportExample.as
  15. +1 −2  src/org/gestouch/examples/views/ConflictGesturesView.mxml
  16. +4 −11 src/org/gestouch/examples/views/ExampleViewBase.as
  17. +15 −4 src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml
  18. +22 −13 src/org/gestouch/examples/views/LongPressGestureAdvancedView.mxml
  19. +1 −2  src/org/gestouch/examples/views/RotateGestureView.mxml
  20. +96 −0 src/org/gestouch/examples/views/StarlingExampleViewBase.as
  21. +1 −1  src/org/gestouch/examples/views/SwipeGestureView.mxml
  22. +27 −95 src/org/gestouch/examples/views/TapGestureView.mxml
  23. +1 −2  src/org/gestouch/examples/views/TransformGestureView.mxml
  24. +250 −0 src_external/fr/kouma/starling/utils/Stats.as
  25. +212 −0 src_external/fr/kouma/starling/utils/standard_07_55.fnt
  26. BIN  src_external/fr/kouma/starling/utils/standard_07_55.png
  27. +182 −0 src_external/net/hires/debug/Stats.as
View
1  .settings/com.powerflasher.fdt.classpath
@@ -19,4 +19,5 @@
<AS3Classpath generateProblems="false" sdkBased="false" type="lib" useAsSharedCode="false">libs/MonsterDebuggerMobile.swc</AS3Classpath>
<AS3Classpath generateProblems="false" inclusion="complete" sdkBased="false" type="project" useAsSharedCode="false">Gestouch</AS3Classpath>
<AS3Classpath generateProblems="false" sdkBased="true" type="lib" useAsSharedCode="false">frameworks/libs/mx/mx.swc</AS3Classpath>
+ <AS3Classpath generateProblems="false" sdkBased="false" type="lib" useAsSharedCode="false">libs/starling.swc</AS3Classpath>
</AS3Classpath>
View
7 .settings/com.powerflasher.fdt.core.prefs
@@ -1,4 +1,5 @@
-#Mon Apr 25 18:42:57 EEST 2011
+#Sat Jun 30 16:36:50 EEST 2012
+AnesChanged=0
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 +9,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
View
BIN  back-button.psd
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
4 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
View
104 build.xml
@@ -179,6 +179,58 @@
</java>
</target>
+
+ <target name="package.apk.captive" description="" depends="ide.resetCompiler">
+ <var name="example.name" value="GestouchExamples" />
+
+ <compile.release input="${project.examplesPackage.dir}/${example.name}.mxml"
+ output="${example.name}.swf"
+ compilerArguments=""
+ />
+
+ <if>
+ <equals arg1="${project.android.certificate.password}" arg2=""/>
+ <then>
+ <input message="Certificate password:"
+ addproperty="var.project.app.certificate.password"/>
+ </then>
+ <else>
+ <var name="var.project.app.certificate.password" value="${project.android.certificate.password}" />
+ </else>
+ </if>
+
+ <var name="var.project.app.descriptor" value="${binrelease.dir}/${example.name}-apk.xml"/>
+ <copy file="${project.android.descriptor.template}" tofile="${var.project.app.descriptor}" overwrite="true">
+ <filterset>
+ <filter token="ID" value="${project.android.appID}" />
+ <filter token="FILENAME" value="${example.name}" />
+ <filter token="VERSION" value="${project.version}" />
+ <filter token="CONTENT" value="${example.name}.swf" />
+ </filterset>
+ </copy>
+
+ <java jar="${flexSDK.adt}" fork="true" failonerror="true">
+ <arg value="-package" />
+
+ <arg value="-target" />
+ <arg value="apk-captive-runtime" />
+
+ <arg value="-storetype" />
+ <arg value="pkcs12" />
+ <arg value="-keystore" />
+ <arg value="${project.android.certificate}"/>
+ <arg value="-storepass" />
+ <arg value="${var.project.app.certificate.password}" />
+
+ <arg value="${binrelease.dir}/${example.name}-captive.apk" />
+ <arg value="${var.project.app.descriptor}" />
+ <arg value="-C" />
+ <arg value="${binrelease.dir}" />
+ <arg value="${example.name}.swf" />
+ </java>
+ </target>
+
+
<target name="ide.startDebugger" description="Starts IDE Debugger">
<if>
<equals arg1="${user.ide}" arg2="FDT4"/>
@@ -225,26 +277,11 @@
<!-- Hidden targets and macro definitions-->
- <macrodef name="compile.example">
- <attribute name="exampleName" />
- <attribute name="compilerArguments" default="" />
- <attribute name="air" default="true" />
- <attribute name="openSWF" default="false" />
- <sequential>
- <compile.debug input="${project.examplesPackage.dir}/@{exampleName}.as"
- output="@{exampleName}.swf"
- compilerArguments="@{compilerArguments}"
- air="@{air}"
- openSWF="@{openSWF}"
- />
- </sequential>
- </macrodef>
-
<macrodef name="compile.debug">
<attribute name="input" />
<attribute name="output" />
- <attribute name="air" default="true" />
<attribute name="compilerArguments" default="" />
+ <attribute name="air" default="true" />
<attribute name="openSWF" default="false" />
<sequential>
<var name="var.compilerArguments" value="${project.baseCompilerArguments} ${project.debugCompilerArguments} @{compilerArguments}" />
@@ -256,7 +293,7 @@
</if>
<if>
- <equals arg1="${user.ide}" arg2="FDT4"/>
+ <equals arg1="${user.ide}" arg2="FDT4_foobar"/>
<then>
<fdt.launch.application projectname="${project.name}"
compilerarguments="${var.compilerArguments}"
@@ -299,4 +336,37 @@
</sequential>
</macrodef>
+ <macrodef name="compile.release">
+ <attribute name="input" />
+ <attribute name="output" />
+ <attribute name="compilerArguments" default="" />
+ <attribute name="air" default="true" />
+ <attribute name="openSWF" default="false" />
+ <sequential>
+ <var name="var.compilerArguments" value="${project.baseCompilerArguments} ${project.releaseCompilerArguments} @{compilerArguments}" />
+ <if>
+ <equals arg1="@{air}" arg2="true" />
+ <then>
+ <var name="var.compilerArguments" value="${var.compilerArguments} ${project.mobileCompilerArguments} +configname=airmobile" />
+ </then>
+ </if>
+
+ <java jar="${flexSDK.dir}/lib/mxmlc.jar" dir="${flexSDK.dir}/frameworks" fork="true" failonerror="true">
+ <arg value="${src.dir}/@{input}"/>
+ <arg value="-incremental=false"/>
+ <arg value="-headless-server=true"/>
+ <arg value="-debug=false"/>
+ <!--<arg value="+configname=flex"/>-->
+ <arg value="-source-path+=${src.dir}"/>
+ <arg value="-source-path+=${src_framework.dir}"/>
+ <arg value="-source-path+=${src_external.dir}"/>
+ <arg value="-library-path+=${flexSDK.dir}/frameworks/libs"/>
+ <arg value="-library-path+=${flexSDK.dir}/frameworks/libs/mx"/>
+ <arg value="-library-path+=${libs.dir}"/>
+ <arg value="-output=${binrelease.dir}/@{output}"/>
+ <arg line="${var.compilerArguments}"/>
+ </java>
+ </sequential>
+ </macrodef>
+
</project>
View
4 build/air/descriptor-template-app.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
-<application xmlns="http://ns.adobe.com/air/application/3.0">
+<application xmlns="http://ns.adobe.com/air/application/3.2">
<!-- Adobe AIR Application Descriptor File Template.
@@ -101,7 +101,7 @@
<!-- The render mode for the app (either auto, cpu, or gpu). Optional. Mobile only. Default auto -->
- <!-- <renderMode></renderMode> -->
+ <renderMode>direct</renderMode>
<!-- Whether or not to pan when a soft keyboard is raised or lowered (either "pan" or "none"). Optional. Defaults "pan." -->
<!-- <softKeyboardBehavior></softKeyboardBehavior> -->
View
9 build/android/descriptor-template-apk.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
-<application xmlns="http://ns.adobe.com/air/application/2.6">
+<application xmlns="http://ns.adobe.com/air/application/3.2">
<!-- Adobe AIR Application Descriptor File Template.
@@ -88,20 +88,19 @@
<!-- <maxSize></maxSize> -->
<!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape"). Optional. Mobile only. Default is the natural orientation of the device -->
-
<!-- <aspectRatio></aspectRatio> -->
<!-- Whether the app will begin auto-orienting on launch. Optional. Mobile only. Default false -->
-
<autoOrients>true</autoOrients>
<!-- Whether the app launches in full screen. Optional. Mobile only. Default false -->
-
<fullScreen>true</fullScreen>
<!-- The render mode for the app (either auto, cpu, or gpu). Optional. Mobile only. Default auto -->
+ <renderMode>direct</renderMode>
- <!-- <renderMode></renderMode> -->
+ <!-- Whether the default direct mode rendering context allocates storage for depth and stencil buffers. Optional. Default false. -->
+ <depthAndStencil>false</depthAndStencil>
<!-- Whether or not to pan when a soft keyboard is raised or lowered (either "pan" or "none"). Optional. Defaults "pan." -->
<!-- <softKeyboardBehavior></softKeyboardBehavior> -->
View
9 build/iOS/descriptor-template-ipa.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8" ?>
-<application xmlns="http://ns.adobe.com/air/application/2.6">
+<application xmlns="http://ns.adobe.com/air/application/3.2">
<!-- Adobe AIR Application Descriptor File Template.
@@ -88,20 +88,19 @@
<!-- <maxSize></maxSize> -->
<!-- The initial aspect ratio of the app when launched (either "portrait" or "landscape"). Optional. Mobile only. Default is the natural orientation of the device -->
-
<!-- <aspectRatio></aspectRatio> -->
<!-- Whether the app will begin auto-orienting on launch. Optional. Mobile only. Default false -->
-
<autoOrients>true</autoOrients>
<!-- Whether the app launches in full screen. Optional. Mobile only. Default false -->
-
<fullScreen>true</fullScreen>
<!-- The render mode for the app (either auto, cpu, or gpu). Optional. Mobile only. Default auto -->
+ <renderMode>direct</renderMode>
- <!-- <renderMode></renderMode> -->
+ <!-- Whether the default direct mode rendering context allocates storage for depth and stencil buffers. Optional. Default false. -->
+ <depthAndStencil>false</depthAndStencil>
<!-- Whether or not to pan when a soft keyboard is raised or lowered (either "pan" or "none"). Optional. Defaults "pan." -->
<!-- <softKeyboardBehavior></softKeyboardBehavior> -->
View
BIN  libs/starling.swc
Binary file not shown
View
BIN  src/assets/images/back-button.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 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;
}
}
View
228 src/org/gestouch/examples/starling/ConflictGesturesExample.as
@@ -0,0 +1,228 @@
+package org.gestouch.examples.starling
+{
+ import com.greensock.easing.Linear;
+ import com.greensock.TweenLite;
+ import starling.core.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.LongPressGestureEvent;
+ import org.gestouch.events.TapGestureEvent;
+ import org.gestouch.events.TransformGestureEvent;
+ import org.gestouch.gestures.Gesture;
+ import org.gestouch.gestures.LongPressGesture;
+ import org.gestouch.gestures.TapGesture;
+ import org.gestouch.gestures.TransformGesture;
+ import org.gestouch.utils.GestureUtils;
+
+ import flash.display.Graphics;
+ import flash.display.Shape;
+ 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);
+
+ // native stage still acts as the parent of everything
+ var longPress:LongPressGesture = new LongPressGesture(Starling.current.nativeStage);
+ longPress.addEventListener(LongPressGestureEvent.GESTURE_LONG_PRESS, onLongPress);
+ }
+
+
+ private function onLongPress(event:LongPressGestureEvent):void
+ {
+ if (event.gestureState != GestureState.BEGAN)
+ return;
+
+ const circle:Shape = new Shape();
+ var g:Graphics = circle.graphics;
+ g.beginFill(0x66ccff, 1);
+ g.drawCircle(0, 0, 100);
+ g.endFill();
+ Starling.current.nativeStage.addChild(circle);
+ circle.x = event.stageX;
+ circle.y = event.stageY;
+ TweenLite.to(circle, 0.5, {
+ alpha: 0,
+ scaleX: 0,
+ scaleY: 0,
+ ease: Linear.easeNone,
+ onComplete: circle.parent.removeChild,
+ onCompleteParams: [circle]
+ });
+ }
+
+
+ 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);
+ 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;
+ }
+ }
+}
View
81 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"));
+ }
+ }
+ }
+}
View
63 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}]});
+ }
+ }
+}
View
3  src/org/gestouch/examples/views/ConflictGesturesView.mxml
@@ -20,7 +20,6 @@
import org.gestouch.gestures.PanGesture;
import org.gestouch.gestures.RotateGesture;
import org.gestouch.gestures.ZoomGesture;
- import org.gestouch.utils.GestureUtils;
import mx.core.FlexGlobals;
import mx.core.UIComponent;
@@ -144,7 +143,7 @@
var matrix:Matrix = target.transform.matrix;
var transformPoint:Point = matrix.transformPoint(target.globalToLocal(gesture.location));
matrix.translate(-transformPoint.x, -transformPoint.y);
- matrix.rotate(event.rotation * GestureUtils.DEGREES_TO_RADIANS);
+ matrix.rotate(event.rotation);
matrix.translate(transformPoint.x, transformPoint.y);
target.transform.matrix = matrix;
}
View
15 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;
}
}
}
View
19 src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml
@@ -9,6 +9,8 @@
>
<fx:Script>
<![CDATA[
+ import mx.utils.ObjectUtil;
+ import org.gestouch.examples.model.ExamplesModel;
import mx.core.IFlexDisplayObject;
import spark.components.Button;
import spark.events.IndexChangeEvent;
@@ -22,6 +24,9 @@
private var debuggerButton:Button;
+ [Bindable]
+ private var dataModel:ExamplesModel;
+
override protected function init():void
{
@@ -29,7 +34,9 @@
debuggerButton = new Button();
debuggerButton.setStyle("icon", debuggerIconAsset);
debuggerButton.addEventListener(MouseEvent.CLICK, debuggerButton_clickHandler);
- actionContent = [debuggerButton];
+// actionContent = [debuggerButton];
+
+ dataModel = data as ExamplesModel;
}
@@ -45,10 +52,14 @@
{
if (event.newIndex > -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);
}
}
View
35 src/org/gestouch/examples/views/LongPressGestureAdvancedView.mxml
@@ -21,13 +21,14 @@
private var longPressGesture:LongPressGesture;
private var fingerToImageOffset:Point = new Point();
+ private var initialTransform:Matrix;
override protected function init():void
{
super.init();
- TweenPlugin.activate([GlowFilterPlugin]);
+ TweenPlugin.activate([GlowFilterPlugin]);
}
@@ -57,19 +58,27 @@
{
var loc:Point = globalToLocal(longPressGesture.location);
- if (event.gestureState == GestureState.BEGAN)
- {
- TweenMax.to(image, 0.5, {alpha: 0.5, glowFilter: {color: 0xEEEEEE * Math.random(), blurX: 16, blurY: 16, strength: 2, alpha: 1}});
- fingerToImageOffset.x = image.x - loc.x;
- fingerToImageOffset.y = image.y - loc.y;
- }
- else if (event.gestureState == GestureState.CHANGED)
- {
- image.move(fingerToImageOffset.x + loc.x, fingerToImageOffset.y + loc.y);
- }
- else if (event.gestureState == GestureState.ENDED)
+ switch (event.gestureState)
{
- TweenMax.to(image, 1, {alpha: 1, glowFilter: {alpha: 0, remove: true}});
+ case GestureState.BEGAN:
+ initialTransform = image.transform.matrix;
+ TweenMax.to(image, 0.5, {alpha: 0.5, glowFilter: {color: 0xEEEEEE * Math.random(), blurX: 16, blurY: 16, strength: 2, alpha: 1}});
+ fingerToImageOffset.x = image.x - loc.x;
+ fingerToImageOffset.y = image.y - loc.y;
+ break;
+
+ case GestureState.CHANGED:
+ image.move(fingerToImageOffset.x + loc.x, fingerToImageOffset.y + loc.y);
+ break;
+
+ case GestureState.ENDED:
+ TweenMax.to(image, 1, {alpha: 1, glowFilter: {alpha: 0, remove: true}});
+ break;
+
+ case GestureState.CANCELLED:
+ TweenMax.to(image, 0, {alpha: 1, glowFilter: {alpha: 0, remove: true}});
+ image.transform.matrix = initialTransform;
+ break;
}
}
]]>
View
3  src/org/gestouch/examples/views/RotateGestureView.mxml
@@ -16,7 +16,6 @@
import org.gestouch.events.RotateGestureEvent;
import org.gestouch.gestures.RotateGesture;
- import org.gestouch.utils.GestureUtils;
private var rotate:RotateGesture;
@@ -61,7 +60,7 @@
var matrix:Matrix = image.transform.matrix;
var transformPoint:Point = matrix.transformPoint(new Point(event.localX, event.localY));
matrix.translate(-transformPoint.x, -transformPoint.y);
- matrix.rotate(event.rotation * GestureUtils.DEGREES_TO_RADIANS);
+ matrix.rotate(event.rotation);
matrix.translate(transformPoint.x, transformPoint.y);
image.transform.matrix = matrix;
}
View
96 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);
+ }
+ }
+}
View
2  src/org/gestouch/examples/views/SwipeGestureView.mxml
@@ -179,7 +179,7 @@
<s:Label text="minVelocity"/>
<s:HSlider id="minVelocitySlider"
- minimum="0.5" maximum="3" stepSize="0.05" dataTipPrecision="2"
+ minimum="0.2" maximum="2" stepSize="0.05" dataTipPrecision="2"
change="onMinVelocitySliderChange(event)"/>
<s:Label text="direction"/>
View
122 src/org/gestouch/examples/views/TapGestureView.mxml
@@ -5,6 +5,7 @@
xmlns:views="org.gestouch.examples.views.*"
xmlns:controls="org.gestouch.examples.controls.*"
xmlns:containers="org.gestouch.examples.containers.*"
+ xmlns:gestures="org.gestouch.gestures.*"
>
<fx:Script>
@@ -13,100 +14,12 @@
import com.greensock.plugins.GlowFilterPlugin;
import com.greensock.plugins.TweenPlugin;
- import org.gestouch.events.TapGestureEvent;
- import org.gestouch.gestures.TapGesture;
-
-
- private var tapGesture:TapGesture;
-
override protected function init():void
{
super.init();
- TweenPlugin.activate([GlowFilterPlugin]);
- }
-
-
- override protected function onViewActivate():void
- {
- super.onViewActivate();
-
- tapGesture = new TapGesture(button);
- tapGesture.addEventListener(TapGestureEvent.GESTURE_TAP, onGesture);
-
- slopSlider.value = tapGesture.slop;
- touchesSlider.value = tapGesture.numTouchesRequired;
- tapsSlider.value = tapGesture.numTapsRequired;
- maxTapDelaySlider.value = tapGesture.maxTapDelay;
- maxTapDurationSlider.value = tapGesture.maxTapDuration;
- }
-
-
- override protected function onViewDeactivate():void
- {
- super.onViewDeactivate();
-
- if (tapGesture)
- {
- tapGesture.removeEventListener(TapGestureEvent.GESTURE_TAP, onGesture);
- tapGesture.dispose();
- tapGesture = null;
- }
- }
-
-
- private function onGesture(event:TapGestureEvent):void
- {
- TweenMax.fromTo(button, 1,
- {glowFilter: {color: 0xCCCCCC * Math.random(), blurX: 64, blurY: 64, strength: 3, alpha: 1, quality: 1}},
- {glowFilter: {alpha: 0, remove: true}}
- );
- }
-
-
- private function onSlopSliderChange(event:Event = null):void
- {
- if (tapGesture)
- {
- tapGesture.slop = slopSlider.value;
- }
- }
-
-
- private function onTouchesSliderChange(event:Event = null):void
- {
- if (tapGesture)
- {
- tapGesture.numTouchesRequired = touchesSlider.value;
- }
- }
-
-
- private function onTapsSliderChange(event:Event = null):void
- {
- if (tapGesture)
- {
- tapGesture.numTapsRequired = tapsSlider.value;
- }
- }
-
-
- private function onMaxTapDelaySliderChange(event:Event = null):void
- {
- if (tapGesture)
- {
- tapGesture.maxTapDelay = maxTapDelaySlider.value;
- }
- }
-
-
- private function onMaxTapDurationSliderChange(event:Event = null):void
- {
- if (tapGesture)
- {
- tapGesture.maxTapDuration = maxTapDurationSlider.value;
- }
+ TweenPlugin.activate([GlowFilterPlugin]);
}
]]>
</fx:Script>
@@ -117,29 +30,48 @@
<containers:SettingsPanel id="settings">
<s:Label text="slop"/>
<s:HSlider id="slopSlider"
- minimum="0" maximum="50" stepSize="1" dataTipPrecision="0"
- change="onSlopSliderChange(event)"/>
+ minimum="0" maximum="100" stepSize="1" dataTipPrecision="0"
+ value="@{tap.slop}"
+ />
<s:Label text="numTouchesRequired"/>
<s:HSlider id="touchesSlider"
minimum="1" maximum="4" stepSize="1" dataTipPrecision="0"
- change="onTouchesSliderChange(event)"/>
+ value="@{tap.numTouchesRequired}"
+ />
<s:Label text="numTapsRequired"/>
<s:HSlider id="tapsSlider"
minimum="1" maximum="4" stepSize="1" dataTipPrecision="0"
- change="onTapsSliderChange(event)"/>
+ value="@{tap.numTapsRequired}"
+ />
<s:Label text="maxTapDelay"/>
<s:HSlider id="maxTapDelaySlider"
minimum="300" maximum="1000" stepSize="100" dataTipPrecision="0"
- change="onMaxTapDelaySliderChange(event)"/>
+ value="@{tap.maxTapDelay}"
+ />
<s:Label text="maxTapDuration"/>
<s:HSlider id="maxTapDurationSlider"
minimum="500" maximum="5000" stepSize="100" dataTipPrecision="0"
- change="onMaxTapDurationSliderChange(event)"/>
+ value="@{tap.maxTapDuration}"
+ />
</containers:SettingsPanel>
+
+ <gestures:TapGesture id="tap" target="{button}"
+ maxTapDuration="@{maxTapDurationSlider.value}"
+ maxTapDelay="@{maxTapDelaySlider.value}"
+ numTapsRequired="@{tapsSlider.value}"
+ numTouchesRequired="@{touchesSlider.value}"
+ >
+ <gestures:gestureTap><![CDATA[
+ TweenMax.fromTo(button, 1,
+ {glowFilter: {color: 0xCCCCCC * Math.random(), blurX: 64, blurY: 64, strength: 3, alpha: 1, quality: 1}},
+ {glowFilter: {alpha: 0, remove: true}}
+ );
+ ]]></gestures:gestureTap>
+ </gestures:TapGesture>
</fx:Declarations>
</views:ExampleViewBase>
View
3  src/org/gestouch/examples/views/TransformGestureView.mxml
@@ -14,7 +14,6 @@
import org.gestouch.core.GestureState;
import org.gestouch.events.TransformGestureEvent;
import org.gestouch.gestures.TransformGesture;
- import org.gestouch.utils.GestureUtils;
private var transformGesture:TransformGesture;
@@ -59,7 +58,7 @@
// can easely perform these transformations without any additional transformations.
var transformPoint:Point = matrix.transformPoint(new Point(event.localX, event.localY));
matrix.translate(-transformPoint.x, -transformPoint.y);
- matrix.rotate(event.rotation * GestureUtils.DEGREES_TO_RADIANS);
+ matrix.rotate(event.rotation);
matrix.scale(event.scaleX, event.scaleY);
matrix.translate(transformPoint.x, transformPoint.y);
}
View
250 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;
+
+}
View
212 src_external/fr/kouma/starling/utils/standard_07_55.fnt
@@ -0,0 +1,212 @@
+<?xml version="1.0"?>
+<font>
+ <info face="standard 07_55" size="-8" bold="0" italic="0" charset="" unicode="1" stretchH="100" smooth="0" aa="1" padding="0,0,0,0" spacing="1,1" outline="0"/>
+ <common lineHeight="12" base="10" scaleW="128" scaleH="128" pages="1" packed="0" alphaChnl="1" redChnl="0" greenChnl="0" blueChnl="0"/>
+ <pages>
+ <page id="0" file="standard_07_55_0.png" />
+ </pages>
+ <chars count="202">
+ <char id="32" x="25" y="68" width="1" height="1" xoffset="0" yoffset="10" xadvance="3" page="0" chnl="15" />
+ <char id="33" x="37" y="54" width="1" height="7" xoffset="1" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="34" x="113" y="59" width="3" height="2" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="35" x="90" y="37" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="36" x="0" y="11" width="5" height="9" xoffset="0" yoffset="2" xadvance="6" page="0" chnl="15" />
+ <char id="37" x="106" y="20" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="38" x="48" y="30" width="6" height="7" xoffset="0" yoffset="3" xadvance="7" page="0" chnl="15" />
+ <char id="39" x="123" y="58" width="1" height="2" xoffset="0" yoffset="3" xadvance="2" page="0" chnl="15" />
+ <char id="40" x="62" y="11" width="3" height="9" xoffset="0" yoffset="2" xadvance="4" page="0" chnl="15" />
+ <char id="41" x="42" y="11" width="3" height="9" xoffset="0" yoffset="2" xadvance="4" page="0" chnl="15" />
+ <char id="42" x="94" y="53" width="5" height="5" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="43" x="88" y="53" width="5" height="5" xoffset="0" yoffset="4" xadvance="6" page="0" chnl="15" />
+ <char id="44" x="103" y="59" width="2" height="3" xoffset="0" yoffset="9" xadvance="3" page="0" chnl="15" />
+ <char id="45" x="12" y="68" width="4" height="1" xoffset="0" yoffset="6" xadvance="5" page="0" chnl="15" />
+ <char id="46" x="27" y="68" width="1" height="1" xoffset="0" yoffset="9" xadvance="2" page="0" chnl="15" />
+ <char id="47" x="50" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="48" x="96" y="37" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="49" x="32" y="54" width="2" height="7" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="50" x="102" y="37" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="51" x="108" y="37" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="52" x="114" y="36" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="53" x="120" y="36" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="54" x="6" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="55" x="12" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="56" x="18" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="57" x="84" y="37" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="58" x="63" y="60" width="1" height="4" xoffset="1" yoffset="5" xadvance="3" page="0" chnl="15" />
+ <char id="59" x="26" y="54" width="2" height="7" xoffset="0" yoffset="5" xadvance="3" page="0" chnl="15" />
+ <char id="60" x="48" y="61" width="3" height="5" xoffset="0" yoffset="5" xadvance="4" page="0" chnl="15" />
+ <char id="61" x="89" y="59" width="5" height="3" xoffset="0" yoffset="5" xadvance="6" page="0" chnl="15" />
+ <char id="62" x="40" y="62" width="3" height="5" xoffset="0" yoffset="5" xadvance="4" page="0" chnl="15" />
+ <char id="63" x="24" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="64" x="24" y="30" width="7" height="7" xoffset="0" yoffset="4" xadvance="8" page="0" chnl="15" />
+ <char id="65" x="30" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="66" x="36" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="67" x="122" y="20" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="68" x="69" y="30" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="69" x="75" y="29" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="70" x="81" y="29" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="71" x="87" y="29" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="72" x="93" y="29" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="73" x="43" y="54" width="1" height="7" xoffset="0" yoffset="3" xadvance="2" page="0" chnl="15" />
+ <char id="74" x="99" y="29" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="75" x="105" y="29" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="76" x="5" y="54" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="77" x="114" y="20" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="78" x="111" y="28" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="79" x="117" y="28" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="80" x="0" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="81" x="106" y="11" width="5" height="8" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="82" x="66" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="83" x="6" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="84" x="12" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="85" x="18" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="86" x="24" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="87" x="16" y="30" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="88" x="30" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="89" x="36" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="90" x="42" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="91" x="66" y="11" width="2" height="9" xoffset="0" yoffset="2" xadvance="3" page="0" chnl="15" />
+ <char id="92" x="65" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="93" x="72" y="11" width="2" height="9" xoffset="0" yoffset="2" xadvance="3" page="0" chnl="15" />
+ <char id="94" x="71" y="60" width="5" height="3" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="95" x="0" y="68" width="6" height="1" xoffset="0" yoffset="9" xadvance="7" page="0" chnl="15" />
+ <char id="96" x="117" y="59" width="2" height="2" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="97" x="30" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="98" x="113" y="45" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="99" x="35" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="100" x="108" y="45" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="101" x="122" y="52" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="102" x="29" y="54" width="2" height="7" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="103" x="63" y="46" width="4" height="7" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="104" x="78" y="45" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="105" x="126" y="36" width="1" height="7" xoffset="0" yoffset="3" xadvance="2" page="0" chnl="15" />
+ <char id="106" x="69" y="11" width="2" height="9" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="107" x="83" y="45" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="108" x="41" y="54" width="1" height="7" xoffset="0" yoffset="3" xadvance="2" page="0" chnl="15" />
+ <char id="109" x="64" y="54" width="7" height="5" xoffset="0" yoffset="5" xadvance="8" page="0" chnl="15" />
+ <char id="110" x="0" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="111" x="112" y="53" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="112" x="68" y="46" width="4" height="7" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="113" x="103" y="45" width="4" height="7" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="114" x="56" y="60" width="3" height="5" xoffset="0" yoffset="5" xadvance="4" page="0" chnl="15" />
+ <char id="115" x="52" y="61" width="3" height="5" xoffset="0" yoffset="5" xadvance="4" page="0" chnl="15" />
+ <char id="116" x="18" y="54" width="3" height="7" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="117" x="25" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="118" x="20" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="119" x="80" y="53" width="7" height="5" xoffset="0" yoffset="5" xadvance="8" page="0" chnl="15" />
+ <char id="120" x="15" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="121" x="73" y="46" width="4" height="7" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="122" x="10" y="62" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="123" x="46" y="11" width="3" height="9" xoffset="0" yoffset="2" xadvance="4" page="0" chnl="15" />
+ <char id="124" x="104" y="20" width="1" height="8" xoffset="1" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="125" x="50" y="11" width="3" height="9" xoffset="0" yoffset="2" xadvance="4" page="0" chnl="15" />
+ <char id="126" x="108" y="59" width="4" height="2" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="160" x="125" y="58" width="1" height="1" xoffset="0" yoffset="10" xadvance="3" page="0" chnl="15" />
+ <char id="161" x="39" y="54" width="1" height="7" xoffset="1" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="162" x="51" y="54" width="4" height="6" xoffset="0" yoffset="4" xadvance="5" page="0" chnl="15" />
+ <char id="163" x="54" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="164" x="55" y="30" width="6" height="7" xoffset="0" yoffset="3" xadvance="7" page="0" chnl="15" />
+ <char id="165" x="60" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="166" x="35" y="54" width="1" height="7" xoffset="1" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="167" x="10" y="54" width="3" height="7" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="168" x="21" y="68" width="3" height="1" xoffset="1" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="169" x="8" y="30" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="170" x="123" y="28" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="171" x="77" y="60" width="5" height="3" xoffset="0" yoffset="6" xadvance="6" page="0" chnl="15" />
+ <char id="172" x="83" y="59" width="5" height="3" xoffset="0" yoffset="6" xadvance="6" page="0" chnl="15" />
+ <char id="173" x="7" y="68" width="4" height="1" xoffset="0" yoffset="6" xadvance="5" page="0" chnl="15" />
+ <char id="174" x="32" y="30" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="175" x="17" y="68" width="3" height="1" xoffset="0" yoffset="4" xadvance="4" page="0" chnl="15" />
+ <char id="176" x="99" y="59" width="3" height="3" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="177" x="45" y="54" width="5" height="6" xoffset="0" yoffset="4" xadvance="6" page="0" chnl="15" />
+ <char id="178" x="5" y="62" width="4" height="5" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="179" x="44" y="62" width="3" height="5" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="180" x="120" y="59" width="2" height="2" xoffset="1" yoffset="2" xadvance="4" page="0" chnl="15" />
+ <char id="181" x="72" y="38" width="5" height="7" xoffset="0" yoffset="5" xadvance="6" page="0" chnl="15" />
+ <char id="182" x="78" y="37" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="183" x="29" y="68" width="1" height="1" xoffset="1" yoffset="6" xadvance="4" page="0" chnl="15" />
+ <char id="184" x="95" y="59" width="3" height="3" xoffset="0" yoffset="9" xadvance="4" page="0" chnl="15" />
+ <char id="185" x="60" y="60" width="2" height="5" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="186" x="53" y="46" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="187" x="65" y="60" width="5" height="3" xoffset="0" yoffset="6" xadvance="6" page="0" chnl="15" />
+ <char id="188" x="96" y="11" width="9" height="8" xoffset="0" yoffset="2" xadvance="10" page="0" chnl="15" />
+ <char id="189" x="86" y="11" width="9" height="8" xoffset="0" yoffset="2" xadvance="10" page="0" chnl="15" />
+ <char id="190" x="75" y="11" width="10" height="8" xoffset="0" yoffset="2" xadvance="11" page="0" chnl="15" />
+ <char id="191" x="48" y="38" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="192" x="90" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="193" x="96" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="194" x="102" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="195" x="18" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="196" x="12" y="11" width="5" height="9" xoffset="0" yoffset="1" xadvance="6" page="0" chnl="15" />
+ <char id="197" x="48" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="198" x="0" y="30" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="199" x="18" y="11" width="5" height="9" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="200" x="36" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="201" x="30" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="202" x="24" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="203" x="6" y="11" width="5" height="9" xoffset="0" yoffset="1" xadvance="6" page="0" chnl="15" />
+ <char id="204" x="117" y="0" width="2" height="10" xoffset="-1" yoffset="0" xadvance="2" page="0" chnl="15" />
+ <char id="205" x="120" y="0" width="2" height="10" xoffset="0" yoffset="0" xadvance="2" page="0" chnl="15" />
+ <char id="206" x="113" y="0" width="3" height="10" xoffset="-1" yoffset="0" xadvance="2" page="0" chnl="15" />
+ <char id="207" x="58" y="11" width="3" height="9" xoffset="-1" yoffset="1" xadvance="2" page="0" chnl="15" />
+ <char id="208" x="62" y="30" width="6" height="7" xoffset="0" yoffset="3" xadvance="7" page="0" chnl="15" />
+ <char id="209" x="72" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="210" x="60" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="211" x="12" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="212" x="0" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="213" x="80" y="20" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="214" x="30" y="11" width="5" height="9" xoffset="0" yoffset="1" xadvance="6" page="0" chnl="15" />
+ <char id="215" x="106" y="53" width="5" height="5" xoffset="0" yoffset="4" xadvance="6" page="0" chnl="15" />
+ <char id="216" x="42" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="217" x="78" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="218" x="84" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="219" x="6" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="220" x="36" y="11" width="5" height="9" xoffset="0" yoffset="1" xadvance="6" page="0" chnl="15" />
+ <char id="221" x="42" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="222" x="48" y="46" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="223" x="112" y="11" width="5" height="8" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="224" x="75" y="20" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="225" x="30" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="226" x="15" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="227" x="45" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="228" x="58" y="46" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="229" x="40" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="230" x="72" y="54" width="7" height="5" xoffset="0" yoffset="5" xadvance="8" page="0" chnl="15" />
+ <char id="231" x="0" y="54" width="4" height="7" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="232" x="55" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="233" x="25" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="234" x="20" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="235" x="123" y="44" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="236" x="98" y="20" width="2" height="8" xoffset="0" yoffset="2" xadvance="3" page="0" chnl="15" />
+ <char id="237" x="101" y="20" width="2" height="8" xoffset="0" yoffset="2" xadvance="2" page="0" chnl="15" />
+ <char id="238" x="90" y="20" width="3" height="8" xoffset="0" yoffset="2" xadvance="3" page="0" chnl="15" />
+ <char id="239" x="22" y="54" width="3" height="7" xoffset="0" yoffset="3" xadvance="3" page="0" chnl="15" />
+ <char id="240" x="118" y="44" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="241" x="70" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="242" x="123" y="10" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="243" x="118" y="11" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="244" x="85" y="20" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="245" x="0" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="246" x="93" y="45" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="247" x="100" y="53" width="5" height="5" xoffset="0" yoffset="4" xadvance="6" page="0" chnl="15" />
+ <char id="248" x="117" y="53" width="4" height="5" xoffset="0" yoffset="5" xadvance="5" page="0" chnl="15" />
+ <char id="249" x="5" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="250" x="10" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="251" x="35" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="252" x="98" y="45" width="4" height="7" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="253" x="108" y="0" width="4" height="10" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="254" x="88" y="45" width="4" height="7" xoffset="0" yoffset="4" xadvance="5" page="0" chnl="15" />
+ <char id="255" x="123" y="0" width="4" height="9" xoffset="0" yoffset="3" xadvance="5" page="0" chnl="15" />
+ <char id="305" x="106" y="59" width="1" height="3" xoffset="0" yoffset="7" xadvance="2" page="0" chnl="15" />
+ <char id="321" x="0" y="46" width="5" height="7" xoffset="0" yoffset="3" xadvance="6" page="0" chnl="15" />
+ <char id="322" x="14" y="54" width="3" height="7" xoffset="0" yoffset="3" xadvance="4" page="0" chnl="15" />
+ <char id="338" x="40" y="30" width="7" height="7" xoffset="0" yoffset="3" xadvance="8" page="0" chnl="15" />
+ <char id="339" x="56" y="54" width="7" height="5" xoffset="0" yoffset="5" xadvance="8" page="0" chnl="15" />
+ <char id="352" x="66" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="353" x="94" y="20" width="3" height="8" xoffset="0" yoffset="2" xadvance="4" page="0" chnl="15" />
+ <char id="376" x="24" y="11" width="5" height="9" xoffset="0" yoffset="1" xadvance="6" page="0" chnl="15" />
+ <char id="381" x="54" y="0" width="5" height="10" xoffset="0" yoffset="0" xadvance="6" page="0" chnl="15" />
+ <char id="382" x="60" y="21" width="4" height="8" xoffset="0" yoffset="2" xadvance="5" page="0" chnl="15" />
+ <char id="402" x="54" y="11" width="3" height="9" xoffset="1" yoffset="2" xadvance="6" page="0" chnl="15" />
+ </chars>
+</font>
View
BIN  src_external/fr/kouma/starling/utils/standard_07_55.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
182 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();
+
+ /**
+ * <b>Stats</b> FPS, MS and MEM, all in one.
+ */
+ public function Stats() : void {
+
+ mouseChildren = false;
+ mem_max = 0;
+
+ xml = <xml><fps>FPS:</fps><ms>MS:</ms><mem>MEM:</mem><memMax>MAX:</memMax></xml>;
+
+ 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;
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.