You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by bi...@apache.org on 2014/11/04 20:15:57 UTC

[07/22] git commit: [flex-examples] [refs/heads/develop] - added slide to open, uses mousedown events and works off 20 pixels of the left side of the screen

added slide to open, uses mousedown events and works off 20 pixels of the left side of the screen

Signed-off-by: OmPrakash Muppirala <bi...@gmail.com>


Project: http://git-wip-us.apache.org/repos/asf/flex-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-examples/commit/1edb5707
Tree: http://git-wip-us.apache.org/repos/asf/flex-examples/tree/1edb5707
Diff: http://git-wip-us.apache.org/repos/asf/flex-examples/diff/1edb5707

Branch: refs/heads/develop
Commit: 1edb5707b65fa340aed96ecc16c034bb88119930
Parents: 975d032
Author: nasha001 <na...@DM-DT-NASH.hartford.gov>
Authored: Thu Jan 16 14:40:04 2014 -0500
Committer: OmPrakash Muppirala <bi...@gmail.com>
Committed: Tue Nov 4 11:07:32 2014 -0800

----------------------------------------------------------------------
 tourdeflexmobile/src/TourDeFlexMobile.mxml | 74 ++++++++++++++++---------
 1 file changed, 48 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-examples/blob/1edb5707/tourdeflexmobile/src/TourDeFlexMobile.mxml
----------------------------------------------------------------------
diff --git a/tourdeflexmobile/src/TourDeFlexMobile.mxml b/tourdeflexmobile/src/TourDeFlexMobile.mxml
index 71a2704..f73ba31 100644
--- a/tourdeflexmobile/src/TourDeFlexMobile.mxml
+++ b/tourdeflexmobile/src/TourDeFlexMobile.mxml
@@ -27,12 +27,14 @@ limitations under the License.
 	
 	<fx:Script>
 		<![CDATA[
-			import mx.core.FlexGlobals;
-			import mx.events.FlexEvent;
-			import flash.utils.Timer;
+			import flash.events.Event;
 			import flash.events.MouseEvent;
 			import flash.events.TimerEvent;
-			import flash.events.Event;
+			import flash.utils.Timer;
+			
+			import mx.core.FlexGlobals;
+			import mx.events.FlexEvent;
+			
 			import spark.events.IndexChangeEvent;
 			
 			import AIRViews.AccelerometerView;
@@ -60,14 +62,6 @@ limitations under the License.
 			
 			import views.HttpServiceView;
 			
-			private var isOpen:Boolean;	
-			
-			[Bindable]
-			private var currentStageWidth:Number;
-			
-			[Bindable]
-			private var currentStageHeight:Number;
-			
 			public static var SLIDE_INTERVAL:int = 40;			
 			public static var STEPS:int = 6; 
 			
@@ -79,15 +73,16 @@ limitations under the License.
 			
 			protected function init(event:FlexEvent):void
 			{
+				stage.addEventListener(MouseEvent.MOUSE_DOWN, mouseDown); 
 				btn.addEventListener(MouseEvent.CLICK, slideButtonHandler);
 				_slideTimer.addEventListener(TimerEvent.TIMER, doSlide);		
 				_slideTimer.addEventListener(TimerEvent.TIMER_COMPLETE, slideComplete); 				
 			}
 			
-/*******************************************
-	*used some code from Macomponents UISlideOutNavigation, replaced the actionscript elements with flex UI elements and was able to apply
-	*the same drag to close behavior
-*********************************************/  
+			/*******************************************
+			 *used some code from Macomponents UISlideOutNavigation, replaced the actionscript elements with flex UI elements and was able to apply
+			 *the same drag to close behavior
+			 *********************************************/  
 			
 			public function open(animated:Boolean = true):void 
 			{				
@@ -104,7 +99,8 @@ limitations under the License.
 				{	
 					navigators.x = lateralMenu.width;	
 					!navigators.mouseEnabled;
-				}				
+				}		
+				stage.addEventListener(MouseEvent.CLICK, close);
 			}
 			
 			public function close(animated:Boolean = true):void 
@@ -121,11 +117,10 @@ limitations under the License.
 					navigators.x = 0;				
 				}			
 			} 
-		
+			
 			protected function changeHandler(event:IndexChangeEvent):void
 			{
 				close();
-				stage.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDown); 
 				navigator.pushView(componentsList.selectedItem.view);
 			}
 			
@@ -143,7 +138,7 @@ limitations under the License.
 				}
 				
 			}
-						
+			
 			protected function mouseDown(event:MouseEvent):void 
 			{			
 				if (!navigators.mouseEnabled && mouseX > lateralMenu.width && mouseY > 45) 
@@ -151,7 +146,13 @@ limitations under the License.
 					_startX = mouseX;				
 					stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp);					
 					stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);			
-				}		
+				}	
+				if (navigators.mouseEnabled && mouseX < 20)
+				{
+					_startX = mouseX;	
+					stage.addEventListener(MouseEvent.MOUSE_UP, mouseUp1);	
+					stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove1);
+				}
 			} 			
 			
 			protected function doSlide(event:TimerEvent):void 
@@ -173,7 +174,9 @@ limitations under the License.
 			
 			protected function mouseMove(event:MouseEvent):void 
 			{							
-				navigators.x = Math.max(Math.min(mouseX - _startX + lateralMenu.width, lateralMenu.width), 0);				
+				
+				navigators.x = Math.max(Math.min(mouseX - _startX + lateralMenu.width, lateralMenu.width), 0);	
+				
 			} 
 			
 			protected function mouseUp(event:MouseEvent):void 
@@ -186,17 +189,36 @@ limitations under the License.
 				_slideTimer.start();
 				
 			}
-					
+			
+			protected function mouseMove1(event:MouseEvent):void 
+			{				
+				navigators.mouseEnabled = navigators.mouseChildren = false;		
+				navigators.x = Math.max(Math.min(mouseX + _startX, lateralMenu.width), 0);				
+			} 
+			
+			protected function mouseUp1(event:MouseEvent):void 
+			{		
+				stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUp1);
+				stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove1);						
+				navigators.mouseEnabled = navigators.mouseChildren = mouseX < lateralMenu.width / 2;
+				_slideTimer.repeatCount = Math.max(navigators.mouseEnabled ? Math.floor(STEPS * navigators.x / lateralMenu.width) : Math.floor(STEPS * (1 - navigators.x / lateralMenu.width)), 1);		
+				_slideTimer.reset();				
+				_slideTimer.start();
+				
+				
+				
+			}
 		]]>
 	</fx:Script>
 	
 	<fx:Declarations>
-
+		
 	</fx:Declarations>
 	
 	
 	
-	<s:Group id="lateralMenu" width="225" y="0" height="100%">	
+	<s:Group id="lateralMenu" width="225" y="0" height="100%">
+		
 		<s:List id="componentsList" itemRenderer="renderers.MenuRenderer" width="225" height="100%" 
 				change="changeHandler(event)" contentBackgroundColor="#000000">
 			<s:ArrayList>
@@ -232,7 +254,7 @@ limitations under the License.
 		</s:List>
 	</s:Group>
 	
-	<s:Group id="navigators" width="{FlexGlobals.topLevelApplication.width}" height="{FlexGlobals.topLevelApplication.height}">
+	<s:Group id="navigators" width="{FlexGlobals.topLevelApplication.width}" height="{FlexGlobals.topLevelApplication.height}" >
 		<s:ViewNavigator id="navigator" firstView="views.BlogView" width="100%" height="100%">
 			<s:navigationContent>
 				<s:Button icon="@Embed('assets/images/logo.png')" height="35" width="77" label="Menu" id="btn"/>