반응형

밑에 내용은 참고하고...중요한건...

Application 안에

 

/* Create dummy variables. */
   private var dragManager:DragManager;
   private var popUpManager:PopUpManager;

더미 객체 생성해주고...

 

Module 안에서

Alert.show("더이상 띄우지마세요~","module",4,null,null,null,4 , this.moduleFactory);

 

해주면됨..

 

------------------

 

If you use modules/sub apps and pop ups(Alert, ToolTip, TitleWindow, etc.) then you probably would be interested in some of the api changes that were introduced by the “Per-Module Style Management” feature in Flex 4. As I mentioned in my previous posts that StyleManager is no longer a singleton class and all modules and sub apps have their own instance of the Style Manager. So when you define a style in a module or sub app, the style definition is managed by the style manager instance of the module/sub app. This works well for most components but pop ups are a special case (all pop ups depend on the PopUpManager)

PopUpManager is a singleton and hence it lives in the top level application domain. When a component is displayed using the PopUpManager it will try to get its styles via the StyleManager in the top level application domain and so the styles that are defined in your module/sub app will be ignored. In order to provide a solution for this situation some apis were modified to accept a new optional parameter. Via the optional parameter the module factory can be specified (which is then internally used to locate the correct style manager). Some apis that were modified are:

  • mx.controls.Alert – show() method was modified to take an optional moduleFactory parameter
  • mx.manager.PopUpManager- createPopUp() and addPopUp() methods were modified to take an optional moduleFactory parameter

So if you are defining styles in your modules/sub apps, you should then pass the moduleFactory parameter to these methods. Lets look at some examples:

Following the code for a main app that loads one module(which shows Alert and TitleWindow) and one sub application (which shows ToolTip).

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
			   xmlns:mx="library://ns.adobe.com/flex/mx" width="600" height="500" >
	<fx:Style>
		@namespace s "library://ns.adobe.com/flex/spark";
		@namespace mx "library://ns.adobe.com/flex/mx";
 
		s|TitleWindow
		{
			chromeColor: #FF0000;
		}
	</fx:Style>
	<fx:Script>
		<![CDATA[
			import mx.events.FlexEvent;
			import mx.managers.PopUpManager;
 
			import spark.components.TitleWindow;
 
			private var placeHolder: PopUpManager;
			private var placeHolder2: TitleWindow;
 
			protected function popup_load_clickHandler(event:MouseEvent):void {
				if(mod_loader_pop.url == null) {
					mod_loader_pop.url = "PopUpModule.swf";
				} else {
					mod_loader_pop.loadModule();
				}
			}
 
			protected function popup_unload_clickHandler(event:MouseEvent):void {
				mod_loader_pop.unloadModule();
			}
 
			protected function toolTip_load_clickHandler(event:MouseEvent):void {
				swfLoader.load("ToolTipSubApp.swf");
			}
 
			protected function toolTip_unload_clickHandler(event:MouseEvent):void {
				swfLoader.unloadAndStop();
			}
		]]>
	</fx:Script>
	<s:layout>
		<s:VerticalLayout paddingTop="5" paddingLeft="5" />
	</s:layout>
	<s:HGroup>
		<s:Button id="popup_load" label="Load PopUp Module" click="popup_load_clickHandler(event)"/>
		<s:Button id="popup_unload" label="Unload PopUp Module" click="popup_unload_clickHandler(event)" />
		<s:Button id="toolTip_load" label="Load ToolTip App" click="toolTip_load_clickHandler(event)"/>
		<s:Button id="toolTip_unload" label="Unload ToolTip App" click="toolTip_unload_clickHandler(event)" />
	</s:HGroup>
	<s:HGroup>
		<mx:ModuleLoader id="mod_loader_pop"/>
		<mx:SWFLoader id="swfLoader" />
	</s:HGroup>
</s:Application>

If you notice, the above app sets the chromeColor for the TitleWindow to #FF0000. Also it does not use any Alert.

Let’s look at the code for the module (PopUpModule.mxml):

<?xml version="1.0" encoding="utf-8"?>
<mx:Module xmlns:fx="http://ns.adobe.com/mxml/2009" 
		   xmlns:s="library://ns.adobe.com/flex/spark" 
		   xmlns:mx="library://ns.adobe.com/flex/mx" >
	<fx:Style>
		@namespace s "library://ns.adobe.com/flex/spark";
		@namespace mx "library://ns.adobe.com/flex/mx";
 
		s|TitleWindow
		{
			fontSize: 32;
		}
	</fx:Style>
	<fx:Script>
		<![CDATA[
			import mx.events.CloseEvent;
			import mx.managers.PopUpManager;
			import spark.components.TitleWindow;
			import mx.controls.Alert;
 
			public var titleWindow: TitleWindow;
 
			protected function btn1_clickHandler(event:MouseEvent):void {
				Alert.show("clicked","module",4,null,null,null,4);
			}
 
			protected function btn2_clickHandler(event:MouseEvent):void
			{
				Alert.show("clicked","module",4,null,null,null,4 , this.moduleFactory);
			}
 
			protected function btn1_1_clickHandler(event:MouseEvent):void {
				titleWindow = PopUpManager.createPopUp(DisplayObject(systemManager),TitleWindow, true, null) as TitleWindow;
				titleWindow.title ="Title Window";
				titleWindow.width = 136;
				titleWindow.addEventListener(CloseEvent.CLOSE, closeMe, false, 0, true); 
			}
 
			protected function btn2_1_clickHandler(event:MouseEvent):void {
				titleWindow = PopUpManager.createPopUp(DisplayObject(systemManager),TitleWindow, true, null, moduleFactory) as TitleWindow;
				titleWindow.title ="Module Title Window";
				titleWindow.width = 426;
				titleWindow.addEventListener(CloseEvent.CLOSE, closeMe, false, 0, true); 
			}
 
			private function closeMe(e:CloseEvent):void {
				PopUpManager.removePopUp(titleWindow);
				titleWindow.removeEventListener(CloseEvent.CLOSE, closeMe);
			}
		]]>
	</fx:Script>
	<s:Panel width="100%" height="100%" title="PopUp Module ">
		<s:layout>
			<s:VerticalLayout paddingTop="5" paddingLeft="5" />
		</s:layout>
		<s:Button label="Show alert" id="btn1" click="btn1_clickHandler(event)" />
		<s:Button label="Show alert (with moduleFactory)" id="btn2" click="btn2_clickHandler(event)" />
		<s:Button label="show title window" id="btn1_1" click="btn1_1_clickHandler(event)" />
		<s:Button label="show title window (with moduleFactory)" id="btn2_1" click="btn2_1_clickHandler(event)" />
	</s:Panel>
</mx:Module>

The module defines the fontSize for the TitleWindow. Also it has two calls to Alert.show() (with and without the moduleFactory parameter). Similarly two calls to PopUpManager.createPopUp() (with and without the moduleFactory parameter). When you run the example code, you will notice the only the Alert and TitleWindow displayed with the moduleFactory parameter are able to pick the correct styles.

Before looking at the running swf, lets also look at the code for the sub application (ToolTipSubApp.mxml):

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" height="200" width="200" 
			   xmlns:s="library://ns.adobe.com/flex/spark">
	<fx:Script>
		<![CDATA[
			import flash.events.MouseEvent;
 
			import mx.core.IToolTip;
			import mx.managers.ToolTipManager;
 
			public var mytoolTip:IToolTip;
 
			protected function panel1_mouseOverHandler(event:MouseEvent):void {
				if(useContext.selected) {
					mytoolTip = ToolTipManager.createToolTip("This is a custom tooltip in a sub App", 100, 100, null,this);
				} else {
					mytoolTip = ToolTipManager.createToolTip("This is a custom tooltip in a sub App", 100, 100, null);					
				}
			}
 
			protected function panel1_mouseOutHandler(event:MouseEvent):void {
				ToolTipManager.destroyToolTip(mytoolTip);
			}
		]]>
	</fx:Script>
	<fx:Style>
		@namespace ns "library://ns.adobe.com/flex/mx";
		@namespace s "library://ns.adobe.com/flex/spark";
 
		ns|ToolTip
		{
			color: blue;
			fontSize: 22;
		}
	</fx:Style>
	<s:layout>
		<s:VerticalLayout />
	</s:layout>
	<s:Panel width="100%" height="90%" mouseOver="panel1_mouseOverHandler(event)" mouseOut="panel1_mouseOutHandler(event)" title="Sub App">
	</s:Panel>
	<s:CheckBox label="pass context" id="useContext" />
</s:Application>

The sub app contains a Panel and a CheckBox, it also contains a style declaration for the ToolTip. When you move the mouse over the panel it displays a tooltip. By default it does not passes the context to the createToolTip method, but when the checkbox is selected it passes the content parameter. In the previous releases the context parameter was not used, but starting from Flex 4 it is being used to locate the current moduleFactory. Only when you pass the context (by selecting the checkbox) the styles for ToolTip defined in the sub app are picked.

Let’s look at the running swf now:



If you load the PopUp Module and click on the “Show alert” button, you would notice that the Alert doesn’t show up with the proper window or title bar. This reason for this broken appearance of Alert is that when the module factory is *not* passed, Alert will try to get its style from the top level style manager. But the main app does not use Alert, so the styles for Alert are not available in the main app. The solution is to pass the moduleFactory to the Alert.show() method. When you click on the “Show Alert (with moduleFactory)” button, you would see an Alert with correct Styles.

Also when you click on the “Show title window” button, you would notice that the title window shows up with chromeColor red but the fontSize style defined in the module is ignored. This reason for this is same (i.e. when the module factory is *not* passed, TitleWindow will try to get its style from the top level style manager. But the main app only sets chromeColor to red, and the modified fontSize style is not available in the main app) . The solution is to pass the moduleFactory to the PopUpManager.createPopUp() method. And when you click on the “Show title window (with moduleFactory)” button, you would see an TitleWindow with correct fontSize and chromeColor.

You would also notice similar behavioral difference when you load the Tool Tip app and play with the tool tip. The ToolTip styles defined in the sub app will only be picked when you pass the context (by selecting the checkbox) to the ToolTipManager.createToolTip() method. Passing the context sets the correct moduleFactory (which is then used to get to the correct style manager).

So, I hope you find this information useful and continue to create awesome looking and mind blowing apps.

 

Posted by 1010
반응형

출처 : http://hmjkor.tistory.com/323

 

flex 3.x

html
<object id="paramTest" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="300" height="120">
<param name="movie" value="Example.swf" />
<param name="flashVars" value="
type=typevar&name=namevar" />
<object type="application/x-shockwave-flash"
data="Example.swf" width="300" height="120"
flashVars="type=typevar&name=namevar">
</object>



flex
creationComplete="init()"

private function init():void{
var type:String = Application.application.parameters.type as String;
var name : String = Application.application.parameters.name as String;
}



flex 4.x

html

var flashvars = {};

flashvars.type = "타입변수";
flashvars.name = "이름변수";


flex
creationComplete="init()"

private function init():void{
var type:String =
parameters.type as String;
var name : String = parameters.name as String;
}



flex 4.5

html

var flashvars = {};

flashvars.type = "타입변수";
flashvars.name = "이름변수";


flex
creationComplete="init()"

private function init():void{
var type:String =
FlexGlobals.topLevelApplication.parameters.type as String;
var name : String = FlexGlobals.topLevelApplication.parameters.name as String;
}
Posted by 1010
반응형

I haven't seen this well documented before, but if you're component was using the style manager and is throwing a bunch of warnings in Flex 4, you need to get the "global" style manager now. You probably see this error:
"3608: 'getStyleDeclaration' has been deprecated since 4.0. Please use 'IStyleManager2.getStyleDeclaration on a style manager instance'."

This is really easy to fix, but not extremely well documented. StyleManager is no longer a global singleton, but there is an instance of it running already at the top of your app. Flex 4 has a new static class called FlexGlobals. You can use that to get a reference to the top of your app and then get the instantiated one.

//Flex 3 code
StyleManager.getStyleDeclaration("someStyle");
//Flex 4 code
FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration("someStyle");

출처 : http://www.jonathanrowny.com/journal/migrating-flex-4-stylemanager

Posted by 1010
반응형

flex

 

Note: You can specify a percentage value in the MXML width attribute, such as width="100%", but you cannot use a percentage value in the width property in ActionScript. Use the percentWidth property instead.

 

 

mxml 에서는 width 를 100% 로 줄수 있지만 ActionScript 에서는 100% 가 먹지 않으니...

 

percentWidth  이걸로 주면됨 (0~100) 으로...

ex:

 

_SWFLoader.percentWidth = 100;
_SWFLoader.percentHeight = 100;

Posted by 1010
00.Flex,Flash,ActionScript2013. 3. 28. 18:46
반응형

출처 : http://blog.jidolstar.com/527

 

Flash에서는 Remoting 호출을 위한 클래스가 존재하지 않는다. NetConnection을 가지고 할 수 있으나 Remoting 호출을 위한 전용 클래스가 아니기 때문에 실용적이지 못하다.

Flex에서는 Remoting 호출을 위해서 RemoteObject 클래스가 있다. 하지만 Flex 전용이라 Flash CS3, 4 개발자는 쓸 수 없다.

여기서는 NetConnection을 한번 wrapping하여 Remoting 호출을 구현한 Service 클래스를 소개한다. 이 Service 클래스는 byteArray.org 블로그 운영자가 만든 것으로 필요할 때 사용하면 매우 유용할 것이라 생각한다.

mport org.bytearray.remoting.Service;
import org.bytearray.remoting.PendingCall;
import org.bytearray.remoting.events.FaultEvent;
import org.bytearray.remoting.events.ResultEvent;

var service:Service=new Service("HelloRemoting",
"http://localhost:8001/amfphp/gateway.php");

var pendingCall:PendingCall=service.sayHello("remoting");
pendingCall.addEventListener(ResultEvent.RESULT,onResult);
pendingCall.addEventListener(FaultEvent.FAULT,onFault);

function onResult(e:ResultEvent):void{
trace(e.result);
}

function onFault(e:FaultEvent):void{
trace(e.fault);
}

사용법은 위처럼 너무 간단하다. AMFPHP, OpenAMF등으로 Remoting 서비스를 위한 서버를 구축하고 클라이언트는 Flash를 통해 개발하려는 사람에게 매우 유용할 듯 싶다. 또는 Flex가 아닌 순수 ActionScript 3.0 으로만 개발하려는 사람에게도 괜찮을 것 같다.



더 자세한 내용은 아래에 이 코드를 만든 원저자의 글을 보길 바란다.


Making Flash Remoting easier in Flash CS3

Posted by 1010
00.Flex,Flash,ActionScript2013. 3. 28. 18:36
반응형

Finally Updated: Embedding HTML in a Flex application using an IFrame

I've updated to Flex 2 (and which can also be used in Flex 3) the code by Christophe Coenraets for embedding HTML in a Flex application using an iframe.

You can see a demo of it here.

You can download the code here.

To run locally, first compile IFrameDemo.mxml. If you are using Flex Builder, unclick "Generate HTML wrapper file" in the Flex Compiler settings before publishing, since there is an existing HTML wrapper. After this, you can view IFrameDemo.html. If you get a "Security sandbox violation" error, you need to put the IFrameDemo directory in the local-trusted sandbox. See the Flex documentation for information on updating FlashPlayerTrust files.

There's been some comments below that say these instructions are no longer valid in Flex Builder 3. So check out the comments if these instructions don't work for you.

The one cause for limitations in this code is the use of opaque for wmode. I've seen reports of tabbing problems in the player, and running more than one player when using opaque wmode seems to degrade performance.

Check below the ad for some very important updates. The comments also have a lot of excellent details in them.

Update 1: see this post for an update to the code that needs less HTML changes, allows multiple HTML pages to be referenced at once, and controls the HTML visibility as needed.

Update 2 (an important update that I highly suggest you read): for my new views on iframes and Flex, read my post from July 2008: Don't Use IFrames for HTML in Flex

Posted by 1010
00.Flex,Flash,ActionScript2013. 3. 28. 16:05
반응형

컬럼차트
1. 컬럼에 라벨 넣기
http://blog.flexexamples.com/2008/01/23/displaying-the-labels-vertically-in-flex-columnchart-control/
2. Custom라벨
http://blog.flexexamples.com/2007/11/25/adding-custom-labels-to-a-flex-columnchart-controls-column-series/
3. 컬럼 width change
http://blog.flexexamples.com/2007/11/24/changing-the-default-column-width-ratio-of-a-columnchart-control-in-flex/
4. 컬럼 color mouseover change
http://blog.flexexamples.com/2007/11/24/setting-a-columnchart-controls-item-roll-over-color-and-item-selection-color-in-flex/
5. 컬럼 color gradient fill-in
http://blog.flexexamples.com/2007/11/22/creating-a-radial-gradient-fill-on-a-columnchart-controls-column-series-in-flex/
6. 컬럼 세부화
http://demo.quietlyscheming.com/drillDown/app.html


라인차트
1. 배경 격자
http://blog.flexexamples.com/2007/11/15/displaying-grid-lines-in-a-flex-linechart-control/
2. 라인 color change
http://blog.flexexamples.com/2007/11/13/changing-default-line-colors-in-a-flex-linechart-control/

3. 라인차트 레전드 체크박스

http://flexdevtips.blogspot.com/2009/10/linechart-with-checkbox-legend.html

4. 라인차트 동적으로 그리기

http://blog.daum.net/_blog/BlogTypeView.do?blogid=0AIhE&articleno=17147067#ajax_history_home

5. Add and remove lineseries - Flex LineChart

http://whatsmytitletoday.blogspot.com/2008/12/add-and-remove-lineseries-flex.html

6. 라인의 포인트에 동글뱅이, 네모등으로 표시기

http://thesunrises.tistory.com/58

7. Line Chart BackgroundElement color

http://kb.cnblogs.com/a/1587795/

8.레전드의 기준값을 여러개 주지

http://livedocs.adobe.com/flex/3/html/help.html?content=charts_types_12.html


파이차트
1. item클릭시 alert Display
http://blog.flexexamples.com/2007/11/15/displaying-a-pieseries-items-data-when-a-user-clicks-an-item-in-a-flex-piechart-control/
2. item mouseover시 value강조
http://blog.flexexamples.com/2007/11/10/exploding-wedges-in-a-flex-piechart-control-based-on-user-input/
3. PieChart Crea By Only AS3
http://blog.flexexamples.com/2007/11/07/creating-a-simple-piechart-in-flex-using-actionscript/
4. Custom Label Position
http://blog.flexexamples.com/2007/11/04/positioning-labels-in-a-flex-piechart-control/


바차트
1. Custom Label Axis
http://blog.flexexamples.com/2007/10/15/rotating-labels-in-a-flex-chart-axis-using-the-labelrotation-style/
2. Animate Bar Value
http://blog.flexexamples.com/2007/10/15/using-data-effects-to-animate-chart-data/
3. End of Bar Chart
http://blog.flexexamples.com/2007/10/11/creating-clustered-stacked-overlaid-and-100-bar-charts-in-flex-3/


CartesianDataCanvas 사용하여 차트에 선 그리기

1. FLEX 3 : Custom ColumnChart (adding display objects to chart)

http://www.codesofmylife.com/2011/03/02/flex-3-custom-columnchart-adding-display-objects-to-chart-2/

2. Drawing on chart controls

http://livedocs.adobe.com/flex/3/html/help.html?content=charts_eventsandeffects_13.html

3. Flex Chart Zoom Window

http://blog.ninjacaptain.com/tag/cartesiandatacanvas/


기타검색

Setting a ColumnChart control’s item roll over color and item selection color in Flex
: Chart 에 롤 오버 시, 색상이 변경
Adding a stroke around a ColumnSeries item in a Flex ColumnChart control
: 컬럼 시리즈에 외곽선 처리
Creating a radial gradient fill on a ColumnChart control’s column series in Flex
: 컬럼 색상에 그라데이션 처리
Animating a Flex PieChart control’s rotation when a user clicks on an item
: 파이 차트 클릭 시, 움직임 처리
Setting specific minimum and maximum ranges for a Flex LineChart control LinearAxis
: 라인 차트 최소, 최대값 범위 지정
Aligning data in a Flex LineChart control to horizontal and vertical tick marks
: 백그라운드에 색상 입력하기
Alternating background column colors in a Flex LineSeries chart
: 백그라운드에 색상 입력하기
Changing a chart legend’s direction
: 범례 표시
Creating a custom label function on a Flex LineChart control’s category axis
: 카테고리 축(X축) 라벨 표시
Changing the horizontal grid line frequency in a Flex LineChart control using the horizontalChangeCount style
: 수평 그리드 라인 처리
Displaying grid lines in a Flex LineChart control
: 그리드 라인 표시 처리
Alternating background row colors in a Flex LineSeries chart
: 백그라운드에 색상 입력하기
Customizing the horizontal grid lines in a Flex LineChart control
: 그리드 라인 색상 처리
Displaying a PieSeries item’s data when a user clicks an item in a Flex PieChart control
: 파이 차트 외곽선 및 아이템 클릭 시 표현
Changing default line colors in a Flex LineChart control
: 라인 차트 색상 바꾸기
Removing the default drop shadow from a LineChart chart in Flex
: 라인 차트 그림자 없애기
Controlling whether a LineChart should set its base value at zero
: 라인 차트 기준 값이 0일 때, 아닐 때
Drawing transparent pie wedges in a Flex PieChart control
: 파이 차트 부분 투명하게 만들기
Exploding all wedges in a Flex PieChart control using the explodeRadius property
: 파이 차트 아이템 간격 조정하기
Customizing radial strokes in a Flex PieChart control
: 파이 차트 아이템 간격 선색상, 굵기, Cap(?) 조정하기
Customizing callout strokes in a Flex PieChart control
: 파이 차트 아이템 지정 선색상, 굵기, Cap(?) 조정하기
Exploding wedges in a Flex PieChart control based on user input
: 파이 차트 아이템 선택 시, 선택된 아이템만 떨어져서 보여주기
Creating a simple PieChart in Flex using ActionScript
: ActionScript로 파이 차트 생성하기
Creating custom fills in a Flex PieChart control using the fillFunction property
: 파이 차트 아이템 색상 지정하기
Rotating a Flex PieChart control when a user clicks on an item
: 파이 차트 아이템 선택 시, 회전하며 표현하기
Exploding wedges in a Flex PieChart control
: 파이 차트 롤 오버 시, 음영 주기
Customizing strokes in a Flex PieChart control
: 파이 차트 외곽선 굵기 조정하기
Removing the drop shadow from a Flex PieChart control
: 파이 차트 그림자 없애기
Positioning labels in a Flex PieChart control
: 파이 차트 라벨 위치 조정하기
Creating a custom data tip function on a Flex PieChart control
: 롤 오버 시, Data Tip 한꺼번에 보여주기
Displaying all data tips at once on a Flex PieChart control
: Data Tip 한꺼번에 보여주기
Dropping labels in a Flex Chart
: 라벨(X 축) 드롭하여 보여주기
Rotating labels in a Flex chart axis using the labelRotation style
: 라벨(X, Y축) 회전 시키기
Changing the bar width ratio on a Flex Bar Chart
: 막대 차트 막대 넓이 조정하기
Using data effects to animate chart data
: 차트 표현 시, 효과 주기
Creating donut shaped Pie charts using the innerRadius style
: 파이 차트 도넛형태로 표현하기
Creating clustered, stacked, overlaid, and 100% Bar charts in Flex 3
: 막대 차트 표현 방법
Setting a Flex Pie Chart’s start angle
: 파이 차트 시작점(각도) 조정하기
Animating data changes in a Flex Pie Chart
: 파이 차트 변환 시, 효과 주기
Using special characters in your Flex applications
: 특수문자 표현하기

[출처] flex chart examples|작성자 고구 마

Posted by 1010
00.Flex,Flash,ActionScript2013. 3. 27. 13:15
반응형
Posted by 1010
00.Flex,Flash,ActionScript2013. 3. 21. 20:29
반응형

출처 : http://hks003.egloos.com/1957266

 

dataGrid 에서 아이템렌더(itemRenderer)를 사용하는 가장 기본적인 소스코드 인것같다. 아이템렌더 사용에 익숙해지기 위해서 많이 보아두어야 할듯 ^^

[결과물]


[Source file test.mxml]


[Source as file CustomComp.as ] 같은 디렉토리에


<원본출처: 바로가기>

Posted by 1010
00.Flex,Flash,ActionScript2013. 3. 21. 19:02
반응형
////////////////////////////////////////////////////////////////////////////////
//
//  Licensed to the Apache Software Foundation (ASF) under one or more
//  contributor license agreements.  See the NOTICE file distributed with
//  this work for additional information regarding copyright ownership.
//  The ASF licenses this file to You under the Apache License, Version 2.0
//  (the "License"); you may not use this file except in compliance with
//  the License.  You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
//
////////////////////////////////////////////////////////////////////////////////
package
{

import flash.display.Loader;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;

/**
 *  Classes used by the networking protocols go here
 */
import mx.messaging.config.ConfigMap; ConfigMap;
import mx.messaging.messages.AcknowledgeMessage; AcknowledgeMessage;
import mx.messaging.messages.AcknowledgeMessageExt; AcknowledgeMessageExt;
import mx.messaging.messages.AsyncMessage; AsyncMessage;
import mx.messaging.messages.AsyncMessageExt; AsyncMessageExt;
import mx.messaging.messages.CommandMessage; CommandMessage;
import mx.messaging.messages.CommandMessageExt; CommandMessageExt;
import mx.messaging.messages.ErrorMessage; ErrorMessage;
import mx.messaging.messages.HTTPRequestMessage; HTTPRequestMessage;
import mx.messaging.messages.MessagePerformanceInfo; MessagePerformanceInfo;
import mx.messaging.messages.RemotingMessage; RemotingMessage;
import mx.messaging.messages.SOAPMessage; SOAPMessage;
import mx.core.mx_internal;

[SWF(width="600", height="700")]
public class air_Bootstrap_Managers extends Sprite
{
    /**
     *  The URL of the application SWF to be loaded
     *  by this bootstrap loader.
     */
    private static const applicationURL:String = "assets/zzaird_Bootstrap_Managers_Child.swf";

	public var portNumber : Number=80;
    /**
     *  Constructor.
     */
    public function air_Bootstrap_Managers()
    {
        super();

        if (ApplicationDomain.currentDomain.hasDefinition("mx.core::UIComponent"))
            throw new Error("UIComponent should not be in Bootstrap.");

        stage.scaleMode = StageScaleMode.NO_SCALE;
        stage.align = StageAlign.TOP_LEFT;

        if (!stage)
            isStageRoot = false;

        root.loaderInfo.addEventListener(Event.INIT, initHandler);
        
        if(root.loaderInfo != null && root.loaderInfo.parameters != null)
		{
			for (var ix:String in root.loaderInfo.parameters) 
			{
				if(ix == "port") 
				{
					portNumber = Number(root.loaderInfo.parameters[ix]);	
				}
			}
		}        
    }

    /**
     *  The Loader used to load the application SWF.
     */
    private var loader:Loader;

    /**
     *  @private
     *  Whether we are the stage root or not.
     *  We are only the stage root if we were the root
     *  of the first SWF that got loaded by the player.
     *  Otherwise we could be top level but not stage root
     *  if we are loaded by some other non-Flex shell
     *  or are sandboxed.
     */
    private var isStageRoot:Boolean = true;
    
	/**
	 *  @private
	 *  Whether the content is loaded
	 */
	private var contentLoaded:Boolean;    

    /**
     *  Called when BootstrapLoader.swf has been loaded.
     *  Starts loading the application SWF
     *  specified by applicationURL.
     */
    private function initHandler(event:Event):void
    {
        loader = new Loader();
        addChild(loader);
        loader.contentLoaderInfo.addEventListener(
            Event.COMPLETE, completeHandler);
        loader.load(new URLRequest(applicationURL));
        loader.addEventListener("mx.managers.SystemManager.isBootstrapRoot", bootstrapRootHandler);
        loader.addEventListener("mx.managers.SystemManager.isStageRoot", stageRootHandler);

        stage.addEventListener(Event.RESIZE, resizeHandler);
    }

    private function completeHandler(event:Event):void
    {
        contentLoaded = true;
    }

    private function bootstrapRootHandler(event:Event):void
    {
        // cancel event to indicate that the message was heard
        event.preventDefault();
    }

    private function stageRootHandler(event:Event):void
    {
        // cancel event to indicate that the message was heard
        if (!isStageRoot)
            event.preventDefault();
    }

    private function resizeHandler(event:Event):void
    {
		if (!contentLoaded)
			return;
			
        loader.width = stage.width;
        loader.height = stage.height;
        Object(loader.content).setActualSize(stage.width, stage.height);
    }
}

}

 

Posted by 1010