Permalink
Browse files

starling initial commit

  • Loading branch information...
1 parent 340a246 commit 17baeee54278a0dfb6bb2ab5fb04d04b42c850e6 @fljot committed Mar 14, 2012
Showing with 1,164 additions and 49 deletions.
  1. +1 −0 .settings/com.powerflasher.fdt.classpath
  2. +3 −3 .settings/com.powerflasher.fdt.core.prefs
  3. BIN back-button.psd
  4. +2 −2 build.template.properties
  5. +2 −2 build/air/descriptor-template-app.xml
  6. +4 −5 build/android/descriptor-template-apk.xml
  7. +4 −5 build/iOS/descriptor-template-ipa.xml
  8. BIN libs/starling.swc
  9. BIN src/assets/images/back-button.png
  10. +3 −1 src/org/gestouch/examples/model/ExamplesModel.as
  11. +193 −0 src/org/gestouch/examples/starling/ConflictGesturesExample.as
  12. +53 −0 src/org/gestouch/examples/starling/StarlingExample.as
  13. +91 −0 src/org/gestouch/examples/starling/StarlingExampleBase.as
  14. +6 −5 src/org/gestouch/examples/views/ConflictGesturesView.mxml
  15. +4 −2 src/org/gestouch/examples/views/DependentSwipingGesturesView.mxml
  16. +4 −3 src/org/gestouch/examples/views/DependentTapGesturesView.mxml
  17. +1 −1 src/org/gestouch/examples/views/GestouchExamplesHomeView.mxml
  18. +3 −2 src/org/gestouch/examples/views/LongPressGestureAdvancedView.mxml
  19. +3 −2 src/org/gestouch/examples/views/LongPressGestureView.mxml
  20. +2 −1 src/org/gestouch/examples/views/PanGestureView.mxml
  21. +3 −2 src/org/gestouch/examples/views/RotateGestureView.mxml
  22. +24 −0 src/org/gestouch/examples/views/StarlingConflictGesturesView.as
  23. +95 −0 src/org/gestouch/examples/views/StarlingExampleViewBase.as
  24. +6 −5 src/org/gestouch/examples/views/SwipeGestureView.mxml
  25. +4 −3 src/org/gestouch/examples/views/TapGestureUsageView.mxml
  26. +5 −3 src/org/gestouch/examples/views/TapGestureView.mxml
  27. +2 −1 src/org/gestouch/examples/views/TransformGestureView.mxml
  28. +2 −1 src/org/gestouch/examples/views/ZoomGestureView.mxml
  29. +250 −0 src_external/fr/kouma/starling/utils/Stats.as
  30. +212 −0 src_external/fr/kouma/starling/utils/standard_07_55.fnt
  31. BIN src_external/fr/kouma/starling/utils/standard_07_55.png
  32. +182 −0 src_external/net/hires/debug/Stats.as
@@ -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>
@@ -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
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -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
@@ -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> -->
@@ -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> -->
@@ -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
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -1,12 +1,13 @@
package org.gestouch.examples.model
{
- import org.gestouch.examples.views.DependentSwipingGesturesView;
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.StarlingConflictGesturesView;
import org.gestouch.examples.views.SwipeGestureView;
import org.gestouch.examples.views.TapGestureUsageView;
import org.gestouch.examples.views.TapGestureView;
@@ -35,6 +36,7 @@ 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: StarlingConflictGesturesView}
]
);
@@ -0,0 +1,193 @@
+package org.gestouch.examples.starling
+{
+ import com.greensock.TweenMax;
+ import flash.geom.Matrix;
+ import flash.geom.Point;
+ 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.extensions.starling.StarlingDisplayObjectAdapter;
+ import org.gestouch.gestures.Gesture;
+ import org.gestouch.gestures.TapGesture;
+ import org.gestouch.gestures.TransformGesture;
+ import org.gestouch.utils.GestureUtils;
+ import starling.display.DisplayObject;
+ import starling.display.Image;
+ import starling.display.Sprite;
+ import starling.textures.Texture;
+
+
+
+
+ /**
+ * @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(new StarlingDisplayObjectAdapter(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(new StarlingDisplayObjectAdapter(image));
+ tap.addEventListener(TapGestureEvent.GESTURE_TAP, onTap, false, 0, true);
+
+ var freeTransform:TransformGesture = new TransformGesture(new StarlingDisplayObjectAdapter(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;
+ }
+ }
+}
@@ -0,0 +1,53 @@
+package org.gestouch.examples.starling
+{
+ import flash.display.Sprite;
+ import flash.display.StageAlign;
+ import flash.display.StageScaleMode;
+ import flash.geom.Rectangle;
+ import org.gestouch.core.GesturesManager;
+ import org.gestouch.core.IGesturesManager;
+ import org.gestouch.extensions.starling.StarlingDisplayListAdapter;
+ import org.gestouch.extensions.starling.StarlingInputAdapter;
+ import starling.core.Starling;
+ import starling.display.DisplayObject;
+ import starling.events.ResizeEvent;
+
+
+
+ [SWF(backgroundColor="#FFFFFF", frameRate="60", width="640", height="480")]
+ /**
+ * @author Pavel fljot
+ */
+ public class StarlingExample extends Sprite
+ {
+ private var starling:Starling;
+
+
+ public function StarlingExample()
+ {
+ stage.scaleMode = StageScaleMode.NO_SCALE;
+ stage.align = StageAlign.TOP_LEFT;
+
+ Starling.multitouchEnabled = true; // useful on mobile devices
+ Starling.handleLostContext = true; // deactivate on mobile devices (to save memory)
+
+ starling = new Starling(StarlingRoot, stage);
+ starling.enableErrorChecking = false;
+ starling.stage.addEventListener(ResizeEvent.RESIZE, starling_resizeHandler);
+ starling.start();
+
+ var gesturesManager:IGesturesManager = GesturesManager.getInstance();
+ gesturesManager.addDisplayListAdapter(starling.display.DisplayObject, new StarlingDisplayListAdapter());
+ gesturesManager.addInputAdapter(new StarlingInputAdapter(starling));
+ }
+
+
+ private function starling_resizeHandler(event:ResizeEvent):void
+ {
+ var rect:Rectangle = new Rectangle(0, 0, event.width, event.height);
+ starling.viewPort = rect;
+ starling.stage.stageWidth = rect.width;
+ starling.stage.stageHeight = rect.height;
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 17baeee

Please sign in to comment.