利用者向け情報

開発者向け情報

[sandbox.akabana]/trunk/yui/yui-air-flex4/src/main/flex/org/seasar/akabana/yui/air/YuiWindowedApplication.as

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1232 - (show annotations)
Wed Aug 4 16:28:32 2010 JST (2 years, 9 months ago) by e1arkw
File size: 2751 byte(s)


1 /*
2 * Copyright 2004-2010 the Seasar Foundation and the Others.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13 * either express or implied. See the License for the specific language
14 * governing permissions and limitations under the License.
15 */
16 package org.seasar.akabana.yui.air
17 {
18 import flash.events.Event;
19
20 import mx.core.UIComponent;
21 import mx.events.AIREvent;
22
23 import org.seasar.akabana.yui.framework.core.YuiFrameworkContainer;
24 import org.seasar.akabana.yui.framework.core.YuiFrameworkSettings;
25 import org.seasar.akabana.yui.framework.error.YuiFrameworkContainerError;
26
27 import spark.components.WindowedApplication;
28
29 [Style(name="rootViewClass", type="Class")]
30 public class YuiWindowedApplication extends WindowedApplication
31 {
32 private var _setting:YuiFrameworkSettings;
33
34 public function get setting():YuiFrameworkSettings{
35 return _setting;
36 }
37
38 private var _rootView:UIComponent;
39
40 public function get rootView():UIComponent{
41 return _rootView;
42 }
43
44 public function YuiWindowedApplication()
45 {
46 super();
47 _setting = new YuiFrameworkSettings();
48 addEventListener(AIREvent.WINDOW_COMPLETE,onWindowCompleteHandler);
49 }
50
51 private function onWindowCompleteHandler(event:AIREvent):void{
52 _rootView.visible = true;
53 addEventListener(Event.CLOSE,onCloseHandler);
54 addEventListener(Event.CLOSING,onClosingHandler);
55 }
56
57 private function onCloseHandler(event:Event):void{
58 var e:Event = new Event(event.type, false, false);
59 _rootView.dispatchEvent(e);
60 YuiFrameworkContainer.yuicontainer.removeExternalSystemManager(systemManager);
61 }
62
63 private function onClosingHandler(event:Event):void{
64 var e:Event = new Event(event.type, false, true);
65 _rootView.dispatchEvent(e);
66 if( e.isDefaultPrevented() ){
67 event.preventDefault();
68 }
69 }
70
71 protected override function createChildren():void{
72 super.createChildren();
73
74 createRootView();
75 }
76
77 protected function createRootView():void{
78 var viewClass:Class = getStyle("rootViewClass") as Class;
79
80 if( viewClass == null ){
81 throw new YuiFrameworkContainerError("rootViewClass style is needed.");
82 } else {
83 _rootView = new viewClass();
84 _rootView.name = "rootView";
85 _rootView.setVisible(false,true);
86 addElement(_rootView);
87 }
88 }
89 }
90 }

Repository Top
ViewVC Help  
ViewVC logotype
Powered by ViewVC