`

Flex 设置模式窗口 不可移出 当前窗口外

阅读更多
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009" 
			   xmlns:s="library://ns.adobe.com/flex/spark" 
			   xmlns:mx="library://ns.adobe.com/flex/mx"
			   xmlns:parsley="http://www.spicefactory.org/parsley"
			   
			   title="Market Movers"
			   width="790" height="500" xmlns:analytics="au.com.tabcorp.neo.analytics.*" 
			   xmlns:components="au.com.tabcorp.neo.common.components.*"
			   windowMoving="onWindowMovingHandler(event)"
			   currentState="{marketMoversPM.dataLoaded?'normal':'loading'}">
	<fx:Script>
		<![CDATA[
			
			import embeddedAssets.EmbeddedResourceModel;
			
			import mx.events.FlexEvent;
			
			import spark.events.TitleWindowBoundsEvent;
			
			[Bindable]
			public var marketMoversPM:MarketMoversPopupPM;
			
			/**
			 *  windowMovig event handler
			 */
			protected function onWindowMovingHandler(event:TitleWindowBoundsEvent):void
			{
				// code to restrict at left and right
				if (event.afterBounds.left < marketMoversPM.PANEL_MOVE_RESTRICTION_LEFT) {
					event.afterBounds.left = marketMoversPM.PANEL_MOVE_RESTRICTION_LEFT - 50;
				} else if (event.afterBounds.right > systemManager.stage.stageWidth + marketMoversPM.PANEL_MOVE_RESTRICTION_RIGHT)
				{
					event.afterBounds.left = systemManager.stage.stageWidth - 75;
				}
				
				// code to restrict at Top and Bottom
				if (event.afterBounds.top < 0) 
				{
					event.afterBounds.top = 0;
				}
				else if (event.afterBounds.bottom > systemManager.stage.stageHeight + marketMoversPM.PANEL_MOVE_RESTRICTION_BOTTOM) 
				{
					event.afterBounds.top = this.height + 75;
				}
			}
			
		]]>
	</fx:Script>
	
	<fx:Declarations>
		<parsley:FastInject property="marketMoversPM" 
							type="{MarketMoversPopupPM}" injectionComplete="marketMoversPM.onInjectionComplete()" />
				
		<analytics:LocationProvider location="{marketMoversPM.marketMoversTabLocation}" >
			<analytics:EventListenerActivationWatcher />
		</analytics:LocationProvider>
	</fx:Declarations>
	<s:states>
		<s:State name="normal"/>
		<s:State name="loading"/>
	</s:states>
	
	<s:Scroller id="scorllbar" width="100%" height="100%"  horizontalScrollPolicy="off"  verticalScrollPolicy="auto">
		<s:VGroup gap="0" width="100%" height="100%" paddingLeft="{scorllbar.visible?5:0}"
				  visible="true"
				  visible.loading="false" 
				  includeInLayout.normal="true"
				  includeInLayout.loading="false">
		
			<!-- Date, Help and Print buttons-->
			<s:HGroup width="760" height="47"
					  verticalAlign="middle">
				
				<components:DateLabel id="dateLabel" 
									  date="{marketMoversPM.serverTimeModel.currentTimeDate}" 
									  dateTimePattern="EEE dd MMM yyyy" 
									  timeZoneOffset="{marketMoversPM.serverTimeModel.globalTimeZoneOffset}" 
									  styleName="header1"/>
				
				<mx:Spacer width="100%"/>
				
				<s:Button label="Print" buttonMode="true" useHandCursor="true"
						  click="marketMoversPM.printClickHandler(this)" 
						  styleName="printButton"/>
				<s:Button click="marketMoversPM.helpClickHandler()"  buttonMode="true" useHandCursor="true"
						  skinClass="au.com.tabcorp.neo.common.presentation.skins.InfoButtonSkin"
						  height="18" width="18"/>
			</s:HGroup>
			
			<s:Line width="760">
				<s:stroke>
					<s:SolidColorStroke color="#DDDDDD" weight="2"/>
				</s:stroke>
			</s:Line>
			<s:HGroup width="100%" height="70" verticalAlign="middle" horizontalAlign="center">
				<s:ButtonBar id="buttonBarMarketMovers" 
							 dataProvider="{marketMoversPM.ac}"
							 selectedItem="{marketMoversPM.selectedRaceOption}"
							 selectedIndex="@{marketMoversPM.selectedIndexButtonBar}"
							 change="marketMoversPM.onChangeMarketMoversButtonBar(event)"
							 enabled="{marketMoversPM.enableButtonBar}"/>
			</s:HGroup>
			
			<!-- DataGrid DataGroup -->		
				<s:DataGroup dataProvider="{marketMoversPM.model.marketMovers}" height="100%">
					
					<s:layout>
						<s:VerticalLayout />
					</s:layout>
					
					<s:itemRenderer>
						<fx:Component>
							<presentation:MarketMoversIRv2 marketMoversPM="{outerDocument.marketMoversPM}" />
						</fx:Component>
					</s:itemRenderer>
					
				</s:DataGroup>
		</s:VGroup>
		
	</s:Scroller>
	<s:HGroup width="100%" height="100%" 
			  horizontalAlign="center"
			  verticalAlign="middle"
			  visible="false"
			  visible.loading="true" 
			  includeInLayout="false"
			  includeInLayout.loading="true">
		<mx:SWFLoader source="{EmbeddedResourceModel.loadingIcon}" />
	</s:HGroup>
</s:TitleWindow>

 

package au.com.tabcorp.neo.racing.marketmovers.presentation
{
	
	import flash.display.DisplayObject;
	import flash.events.Event;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	
	import mx.collections.ArrayCollection;
	import mx.collections.ListCollectionView;
	import mx.core.FlexGlobals;
	import mx.core.IFlexDisplayObject;
	import mx.core.UIComponent;
	import mx.managers.PopUpManager;
	
	import org.spicefactory.lib.reflect.types.Void;
	
	import spark.collections.Sort;
	import spark.collections.SortField;
	import spark.events.IndexChangeEvent;
	import spark.events.TitleWindowBoundsEvent;
	
	public class MarketMoversPopupPM extends Broadcaster
	{
		[Inject] [Bindable] 	
		public var serverTimeModel:ServerTimeModel;
		
		[Inject] [Bindable]
		public var model:MarketMoversModel;
		/**
		 * DG column widths so we can match footer to DG
		 */ 
		public const SMALL_COLUMN_WIDTH:int = 30;
		public const MEDIUM_COLUMN_WIDTH:int = 70;
		public const MEDIUM_COLUMN_WIDTH_2:int = 85;
		public const MEDIUM_COLUMN_WIDTH_3:int = 100;
		public const LARGE_COLUMN_WIDTH:int = 160;
		public const LARGE_COLUMN_WIDTH_2:int = 170;
		public const PANEL_WIDTH:int = 760;
		
		public const PANEL_MOVE_RESTRICTION_LEFT:int = -660;
		public const PANEL_MOVE_RESTRICTION_RIGHT:int = 660;
		public const PANEL_MOVE_RESTRICTION_BOTTOM:int = 450;
		
		[Bidnable]
		public var marketMoversListView:ListCollectionView;
		[Bindable]
		public var selectedRaceOption:Object;
		[Bindable]
		public var ac:ArrayCollection;
		[Bindable]
		public var arrRaceNos:ArrayCollection;
		[Bindable]
		public var marketMoversTabLocation : String = MARKET_MOVERS_LOCATION;
		[Bindable] public var dataLoaded:Boolean;
		
		private static const MARKET_MOVERS_LOCATION:String 	= "informational:market movers";
		private static const NEXT_3_RACES_TO_GO:String 		= "informational:next 3 races to go";
		private static const INDEX_VIEW_CURRENT_RACE : int = 0;
		private static const INDEX_VIEW_NEXT_THREE_RACE : int = 1;
		
		/**
		 *  variable to store the currentRace Details at PM level only - not into to model 
		 */		
		private var _currentRacingCode : String;
		private var _currentMeetingName : String;
		private var _currentMeetingDateRaw : Date;
		private var _currentRaceNumber : int;
		
		private var _enableButtonBar : Boolean;
		private var _todayDate:Date;
		private var _numberSortField:SortField;
		private var _numberSort:Sort;
		private var _runnerNameSortField : SortField;
		private var _runnerNameSort : Sort;
		private var _oddsSortField : SortField;
		private var _oddsSort : Sort;
		private var _percentChangeSortField : SortField;
		private var _percentChangeSort : Sort;
		private var _selectedIndexButtonBar : int;
		private var callFromExternal : Boolean = true;
		
		public function MarketMoversPopupPM()
		{
			ac = new ArrayCollection([
				{value: MarketMoversModel.MARKET_MOVERS_CURRENT_VIEW, label: "CURRENT RACE"},
				{value: MarketMoversModel.MARKET_MOVERS_NEXT_3_RACES, label: "NEXT 3 RACES"}
			]);
			
			// sort fields
			_numberSortField = new SortField();
			_numberSortField.name = 'runnerNumber';
			_numberSortField.numeric = true;
			_numberSort = new Sort();
			_numberSort.fields = [_numberSortField];
			
			_runnerNameSortField = new SortField();
			_runnerNameSortField.name = 'runnerName';
			_runnerNameSort = new Sort();
			_runnerNameSort.fields = [_runnerNameSortField];
			
			_oddsSortField = new SortField();
			_oddsSortField.name = RacingConstants.SORT_LABEL_OPENING_ODDS;
			_oddsSort = new Sort();
			_oddsSort.fields = [_oddsSortField];
			
			_percentChangeSortField = new SortField();
			_percentChangeSortField.name = RacingConstants.SORT_LABEL_PERCENT_CHANGE;
			_percentChangeSort = new Sort();
			_percentChangeSort.fields = [_percentChangeSortField];
		}
		
		[Init]
		public function onInjectionComplete() : void
		{
			todayDate = serverTimeModel.currentTimeDate;
			marketMoversListView = new ListCollectionView(model.marketMovers);
			dataLoaded = true;
			
		}
		
		[Init]
		public function init():void
		{
			var source:Array = new Array(1, 2, 3);
			arrRaceNos = new ArrayCollection(source);
			
			if(serverTimeModel.currentTimeDate)
				onInjectionComplete();
		}
		
		public function onWeatherIcon_clickHandler(meetingMNC3:String, meetingName:String):void
		{
			broadcast(new GetWeatherInfoMessage(meetingMNC3, meetingName));
		}
		
		public function onTrackClickHandler(source:MarketMoversVO):void
		{
			var trackRequest:TrackRequest = new TrackRequest();
			trackRequest.meetingCode = source.meetingCode;
			trackRequest.meetingName = source.meetingName;
			trackRequest.raceNumber = source.raceNumber;
			trackRequest.racingCode = source.racingCode;
			trackRequest.meetingDateRaw = source.raceStartTime;//race.meeting.meetingDate;
			broadcast(new GetTrackEvent(trackRequest));
		}
		
		///////////////////////////////////////////////////////////////////////
		//                           handlers                                //
		///////////////////////////////////////////////////////////////////////
		
		public function onChangeMarketMoversButtonBar(event:IndexChangeEvent):void
		{
			selectedRaceOption = event.currentTarget.selectedItem;
			
			//model.changeRaceListView(selectedRaceOption.value);
			getMarketMoversData(selectedIndexButtonBar);
			
			// TODO : show loader - while getting new data
			
			//analytics: track the market movers/next 3 races to go location
			if(selectedRaceOption.value == MarketMoversModel.MARKET_MOVERS_NEXT_3_RACES)
				marketMoversTabLocation = NEXT_3_RACES_TO_GO;
			else
				marketMoversTabLocation = MARKET_MOVERS_LOCATION;
			dispatchEvent(new LocationChangeEvent());
		}
		
		// ----------------------------------------------------------
		// 					PUBLIC METHODS
		// ----------------------------------------------------------
		
		private function getMarketMoversData(selectedIndex:int) : void
		{
			callFromExternal = false;
			if(selectedIndex == INDEX_VIEW_CURRENT_RACE)
			{
				dataLoaded = false;
				// call to a specific race MarketMovers ( current race )
				var request:MarketMoversRequest = new MarketMoversRequest();
				request.racingCode = this._currentRacingCode;
				request.raceNumber = this._currentRaceNumber;
				request.meetingName = this._currentMeetingName;
				request.meetingDateRaw = this._currentMeetingDateRaw;
				broadcast(new MarketMoversMessage(request));
			}
			else if(selectedIndex == INDEX_VIEW_NEXT_THREE_RACE)
			{
				dataLoaded = false;
				// for the default market movers call - like the RacingOverview
				var mmRequest : MarketMoversRequest = new MarketMoversRequest();
				var msg:CallMarketMoversMessage = new CallMarketMoversMessage(mmRequest);
				broadcast(msg);
			}
		}
		
		public function storeCurrentRaceDetails(req : MarketMoversRequest) : void
		{
			this._currentRacingCode = req.racingCode;
			this._currentMeetingName = req.meetingName;
			this._currentMeetingDateRaw = req.meetingDateRaw;
			this._currentRaceNumber = req.raceNumber;
		}
		
		public function removeCurrentRaceDetails() : void
		{
			this._currentRacingCode = null;
			this._currentMeetingName = null;
			this._currentMeetingDateRaw = new Date();
			this._currentRaceNumber = 0;
		}

		
		public function printClickHandler(component:UIComponent):void
		{
			var printReceipt:PrintPreviewPopUp = new PrintPreviewPopUp();
			PopUpManager.addPopUp(printReceipt as IFlexDisplayObject, FlexGlobals.topLevelApplication as DisplayObject, true);
			
			if(component.height>0 && component.width>0)
			{
				printReceipt.toBePrintData = component;
				printReceipt.x = FlexGlobals.topLevelApplication.width/2 - component.width/2;
				printReceipt.y = FlexGlobals.topLevelApplication.height/2 - component.height/2;
				PopUpManager.bringToFront(printReceipt as IFlexDisplayObject );
			}
		}
		
		public function navigateToRacePage(marketMoversVO:MarketMoversVO) : void
		{
			var request:RaceDetailsRequestV2 = new RaceDetailsRequestV2();
			request.meetingName = marketMoversVO.meetingName;
			request.meetingCode = marketMoversVO.meetingCode;
			request.meetingDateRaw = marketMoversVO.raceStartTime;
			request.racingCode = marketMoversVO.racingCode;
			request.raceNumber = String(marketMoversVO.raceNumber);
			
			broadcast(new RacingNavigatorMessage(RacingNavigatorModel.BETTING_PAGE, null, false, request));
			
			closeMarketMovers();
		}
		
		/**
		 *  to close the market movers popup
		 */		
		[MessageHandler]
		public function messageHandlerCloseMarketMoversPopup( message : CloseMarketMoversPopupMessage) : void
		{
			// next call will be from external only
			callFromExternal = true;
		}
		
		public function closeMarketMovers() : void
		{
			callFromExternal = true;
			var message : CloseMarketMoversPopupMessage = new CloseMarketMoversPopupMessage(
				CloseMarketMoversPopupMessage.Close_Market_Movers_Popup_Message);
			broadcast(message);
		}
		
		// ----------------------------------------------------------
		// 					SUBSCRIBE HANDLER
		// ----------------------------------------------------------
		
		private var _requestedRaceNo:int;
		
		private var _marketMoversRequest:MarketMoversRequest;
		
		public function get marketMoversRequest():MarketMoversRequest
		{
			return _marketMoversRequest
		}
		
		public function get requestedRaceNo():int
		{
			return _requestedRaceNo;
		}
		
		[Subscribe] 
		public function set marketMoversRequest(value:MarketMoversRequest):void
		{
			_marketMoversRequest = value;
			if (marketMoversRequest)
			{
				_requestedRaceNo = marketMoversRequest.raceNumber;
				broadcast(new MarketMoversMessage(marketMoversRequest));
			}
		}
		
		public function viewToBeShown(showCurrentRace:Boolean = false) : void
		{
			if(callFromExternal)
			{
				if(showCurrentRace)
				{
					// show current race button
					enableButtonBar = true;
					callFromExternal = true;
					selectedIndexButtonBar = INDEX_VIEW_CURRENT_RACE;
					selectedRaceOption = ac.getItemAt(INDEX_VIEW_CURRENT_RACE);
				}
				else
				{
					selectedIndexButtonBar = INDEX_VIEW_NEXT_THREE_RACE;
					selectedRaceOption = ac.getItemAt(INDEX_VIEW_NEXT_THREE_RACE);
					enableButtonBar = false;
				}
			}
		}
		
		// Getter / Setter
		[Bindable(event="todayDateChanged")]
		public function get todayDate():Date
		{
			return _todayDate;
		}
		
		public function set todayDate(value:Date):void
		{
			_todayDate = value;
			dispatchEvent(new Event("todayDateChanged"));
		}

		[Bindable(event="selectedIndexButtonBarChange")]
		public function get selectedIndexButtonBar():int
		{
			return _selectedIndexButtonBar;
		}

		public function set selectedIndexButtonBar(value:int):void
		{
			_selectedIndexButtonBar = value;
			dispatchEvent(new Event("selectedIndexButtonBarChange"));
		}

		[Bindable(event="enableButtonBarChange")]
		public function get enableButtonBar():Boolean
		{
			return _enableButtonBar;
		}

		public function set enableButtonBar(value:Boolean):void
		{
			if( _enableButtonBar !== value)
			{
				_enableButtonBar = value;
				dispatchEvent(new Event("enableButtonBarChange"));
			}
		}
	}
}

 

分享到:
评论

相关推荐

    flex 窗口拖动与尺寸改变

    在IT领域,尤其是在Web开发中,Flex是一种常用于创建可伸缩、响应式的用户界面的技术。Flex,全称为Adobe Flex,最初由Macromedia开发,后来被Adobe公司接手,现在则是一个开源项目Apache Flex。Flex提供了强大的...

    Flex4 Air 自定义窗口

    开发者可以利用`NativeWindowInitOptions`来设置窗口的初始属性,如位置、大小、图标、是否可调整大小等。 要实现窗口最小化到托盘,我们需要使用`NativeTrayIcon`类。当用户点击窗口的最小化按钮时,窗口将不再...

    flex 模仿WINDOWS窗口

    TitleWindow组件通常用于创建带有标题、可最小化、最大化和关闭功能的窗口,非常适合模仿Windows窗口的外观。 4. ActionScript 3.0:Flex的核心编程语言是ActionScript 3.0,它具有面向对象的特性,提高了性能和...

    flex 弹出窗口选择,支持autocomplete功能

    在本文中,我们将深入探讨如何在Flex环境中实现一个具有autocomplete(自动补全)功能的弹出窗口选择器。Flex是一种基于ActionScript的开源框架,用于构建富互联网应用程序(RIA),它允许开发者创建交互性强、用户...

    Flex 弹出窗口的数据传输

    在Flex中,`List`组件可以用来显示可选择的项目列表,通常与数据提供器结合使用,将数据模型映射到可视元素上。 `mywin.mxml`可能是一个弹出窗口或对话框,它是Flex中的`PopUpWindow`或`WindowedApplication`组件...

    flex 窗口托盘和全屏

    2. 创建TrayIcon对象:在Flex应用程序的初始化阶段,创建一个TrayIcon实例,并设置其图标和菜单项。菜单项可以包含“退出”和“还原”等操作。 3. 监听事件:添加事件监听器以处理用户在托盘菜单上的选择。例如,当...

    Flex 弹出窗口代码

    在Flex编程中,"弹出窗口代码"是一个常见的需求,特别是在设计用户交互界面时,我们经常需要实现点击按钮后打开一个新的窗口或者对话框来展示更多信息或进行特定操作。本篇将详细讲解如何在Flex中创建一个点击按钮后...

    flex窗口最大最小化

    可以添加两个按钮,分别绑定点击事件,事件处理函数中计算当前窗口尺寸和目标尺寸,然后动态设置元素的`width`和`height`属性。 例如,最大化时,窗口的宽度和高度可能设置为父容器的宽度减去边框,高度减去标题栏...

    flex设计模式flex设计模式flex设计模式

    flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式flex设计模式

    AdvDataGridDemo + Flex侧边停靠窗口

    "AdvDataGridDemo"是一个使用Flex技术实现的高级数据网格示例,而"Flex侧边停靠窗口"则是一种常见且实用的UI设计模式,它允许用户将窗口停靠到屏幕的边缘,以优化工作空间的使用。本文将深入探讨这两个知识点,并...

    FLEX网页果冻窗口效果(附拖动功能)

    FLEX网页果冻窗口效果(附拖动功能)FLEX网页果冻窗口效果(附拖动功能)FLEX网页果冻窗口效果(附拖动功能)FLEX网页果冻窗口效果(附拖动功能)FLEX网页果冻窗口效果(附拖动功能)FLEX网页果冻窗口效果(附拖动...

    flex的mvc模式

    这种模式在Flex开发中尤其重要,因为它有助于创建可维护、可扩展且易于测试的应用程序。 **Model(模型)** 模型层是应用程序的核心部分,它处理业务逻辑和数据管理。在Flex中,模型通常是数据类和数据访问对象...

    flex mdi 窗口的使用

    Flex MDI(Multiple Document Interface)是一种在Flex应用中实现多文档界面的技术,它允许用户在一个主窗口中同时打开和操作多个子窗口。Flex是Adobe公司推出的一种基于ActionScript的开源框架,主要用于构建富...

    flex RichFlex MDIW 窗口

    flex RichFlex MDIW 窗口,一个可以最大化,最小化,恢复/还原的窗口组件.

    flex 苹果桌面效果的弹出窗口

    标题中的“flex 苹果桌面效果的弹出窗口”指的是使用Adobe Flex技术在苹果桌面环境中实现类似苹果OS X系统的弹出窗口效果。Flex是一种开源的、基于ActionScript的框架,用于构建富互联网应用程序(RIA),它允许...

    flex 弹出窗口并居中显示

    本文将详细讲解如何利用Flex布局实现弹出窗口并使其居中显示,这对于创建各种交互式功能,如模态框、提示框等至关重要。 一、Flex布局基础 1. Flex容器:一个具有`display: flex`或`display: inline-flex`样式的...

    flex4舞台尺寸随浏览器窗口大小改变.rar

    flex4舞台尺寸随浏览器窗口大小改变.rar

    Flex设置下拉框ComboBox组件在不可编辑状态下的选中样式

    在某些情况下,我们可能希望禁用ComboBox的编辑功能,使其变为只读模式,同时还要保持良好的用户体验,即设置在不可编辑状态下选中项的特定样式。本篇文章将深入探讨如何实现这一目标。 首先,了解ComboBox的基本...

Global site tag (gtag.js) - Google Analytics