Flex Mobile Alert实现

好久没有写博客了,昨天生日也快了,现在也老了一岁了,博客也有一年多多了,想想还是应该坚持更新文章。

Flex mobile

flexAir app转Android,ios,blackberry

出自Adobe的大手,现在已基本实现了全平台支持,从desktop到mobile都可以用一套代码,基本上实现了跨平台的支持。http://flex.org

Flex Alert

这里还提供段代码实现Flex mobile alert,在spark包里面已经没有提供alert这个类了,这样为了实现这个alert功能就必须自己去实现了,下面就送上一段代码。

效果实现

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<s:SkinnablePopUpContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
                           xmlns:s="library://ns.adobe.com/flex/spark"
                           xmlns:itemrenderer="com.adobe.mobilecrud.view.itemrenderer.*"
                           backgroundAlpha="0" creationComplete="CenterPopUp()">
   
    <fx:Script>
        <![CDATA[
           
            import mx.core.FlexGlobals;
            import mx.events.CloseEvent;
           
            import spark.events.PopUpEvent;
            import kr.co.kgi.mapservice.maps.Storage;
           
            // Flash import
            import flash.events.Event;
            import flash.events.MouseEvent;
            import flash.filesystem.File;
            import flash.filesystem.FileMode;
            import flash.filesystem.FileStream;
           
            import kr.co.kgi.mapservice.maps.Storage;
            import kr.co.kgi.mapservice.ui.SymbolSelectView;
            import kr.co.kgi.mapservice.ui.SymbolSelect;
            import kr.co.kgi.net.socket.Temporary;
            import kr.co.kgi.mapservice.control.AlertBox;
           
           
            private static var YES:String = 'yes';
            private static var NO:String = 'no';
           
            //for dialog box
            private var mFile:File;                                             // 로컬파일 접근시 사용되는 변수
            private var mType:String;                                           // "Load" & "Save" 구별하기 위한 변수
           
           
            public function get Yes():String{
                return YES;
            }
           
            public function get No():String{
                return NO;
            }
            //isShowCancelBtn:Boolean = false,
            public function showMessage(text:String = '',title:String = '', closeHandler:Function = null):void{
                this.open(FlexGlobals.topLevelApplication as DisplayObjectContainer,true);
                if(closeHandler != null){              
                    btnOk.addEventListener(MouseEvent.CLICK,btnClose_clickHandler);
                    btnCancel.visible = true;
                    btnCancel.includeInLayout = true;
                    btnOk.label = "YES";
                    btnCancel.label = "NO";
                    this.addEventListener(PopUpEvent.CLOSE,closeHandler);
                }else{
                    btnOk.addEventListener(MouseEvent.CLICK,btnClose_clickHandler);
                }
                this.title.text = title;
                text_main.text = editMessage(text);
                   
            }
            private function editMessage(aMsg:String):String                    // 매개변수 : aMsg - 문단화 하기위한 메시지 / 반 환 값 : 문단화 된 메시지
            {                                                                   // 메시지 내용을 문단화 하기 위한 Function
                var tmp:String = "";
                var cnt:Number = 35;
                for(var i:Number = 0; i < aMsg.length; i++)
                {
                    tmp += aMsg.substring(i, cnt) + "\n";
                    i = cnt - 1;
                    cnt += 35;             
                }
                return tmp;
            }
           
            private function CenterPopUp():void{
                this.x = FlexGlobals.topLevelApplication.width / 2 - this.width / 2;
                this.y = FlexGlobals.topLevelApplication.height / 2 - this.height / 2;
               
            }
            protected function btnClose_clickHandler(event:MouseEvent):void
            {
                // TODO Auto-generated method stub
                if(event.currentTarget.id == 'btnOk'){
                    this.close(true,YES);
                    Storage.INSTANCE.btnYESOrNO = "YES";
                }else{
                    this.close(true,NO);
                    Storage.INSTANCE.btnYESOrNO = "NO";
                }
            }
           
            //for dialog box
           
            public function dialogType(aType:String = "Load"):void              // 매개변수 : aType - Flie 의 Parameter
            {                                                                   // Flie을 이용하여 Load 할지 Save할지 결정
                mType = aType;         
            }
           
            public function dialogSet(text:String = '',title:String = ''):void      // 매개변수 : aTitle - 대화상자 Title / aMessage - 대화상자 메시지
            {                                                                   // 대화상자에서 사용될 Title 및 메시지를 설정
//              mMainPanel.title = aTitle;
//              mMessageBox.text = aMessage;
               
                this.open(FlexGlobals.topLevelApplication as DisplayObjectContainer,true);
               
               
                btnCancel.visible = true;
                btnCancel.includeInLayout = true;
                btnOk.addEventListener(MouseEvent.CLICK,onOKClick);
                btnCancel.addEventListener(MouseEvent.CLICK,onCancelClick);
               
                this.title.text = text;
                text_main.text = editMessage(title);
               
            }
           
            private function symbolArrayinit():void                             // 사용자 정의값을 Load시 저장하기 위해 Array초기화
            {
                for(var i:Number = 0; i < Temporary.INSTANCE.userSymbolNo.length; i++)
                {
                    Temporary.INSTANCE.userSymbolNo[i] = new Array();
                }
            }      
           
            //////// EVENT ////////
            private function onOKClick(event:MouseEvent):void                   // Flie Class을 이용하여 사용자정의값 로컬에 Load 또는 Save 및 대화상자remove
            {
                var stream:FileStream = new FileStream();
//              switch(Storage.INSTANCE.systemPlatform)
//              {
//                  case Storage.DESKTOP_WINDOWS:
//                      mFile = new File("C:/kgi/userSymbolSetting.kgi");
//                      break
//                 
//                  case Storage.MOBILE_ANDROID:
//                      mFile = new File(File.separator + "sdcard" + File.separator + "kgi" + File.separator + "userSymbolSetting.kgi");
//                      break
//                 
//                  case Storage.MOBILE_IOS: //for iOS
//                  case Storage.DESKTOP_MAC:
//                      mFile = File.applicationStorageDirectory.resolvePath("userSymbolSetting.kgi");
//                      break;
//                 
//                  case Storage.MOBILE_QNS: //for blackberry-tablet
//                      break;
//                  default :
//              }
                mFile = File.applicationStorageDirectory.resolvePath("userSymbolSetting.kgi");
                if(mType == "Load"){
                    if(mFile.exists)
                    {
                        stream.open(mFile, FileMode.READ);
                        onLoadComplete(stream.readUTFBytes(stream.bytesAvailable));
                    }else{
                        var alertObj:AlertBox = new AlertBox();
                        alertObj.showMessage("사용자 정의파일이 존재하지 않습니다. \n 새로 선택하여 저장해주세요!!");
                    }              
                }else{
                    var tmptext:String="";
                   
                    for(var i:Number = 0; i < Temporary.INSTANCE.userSymbolNo.length-1; i++)
                    {
                        tmptext += Temporary.INSTANCE.userSymbolNo[i]+"/";
                    }
                    tmptext += Temporary.INSTANCE.userSymbolNo[Temporary.INSTANCE.userSymbolNo.length-1];
                    stream.open(mFile, FileMode.WRITE);
                    stream.writeUTFBytes(tmptext);
                    stream.close();
                }          
                //this.removeAllChildren();
                this.close(true,YES);
            }
           
            private function onCancelClick(event:MouseEvent):void               // 대화상자 remove
            {
                //this.removeAllChildren();
                this.close(true,YES);
            }
           
            private function onLoadComplete(aUserSet:String):void               // 매개변수 : aUserSet - 로드된 사용자정의 파일의 정보
            {                                                                   // Load된 사용자정의파일을 변수에 저장후 심볼 재설정
                symbolArrayinit();
                var tmpTotalArr:Array = aUserSet.split("/");
               
                for(var i:Number = 0; i < tmpTotalArr.length; i++)
                {
                    var tmpString:String = tmpTotalArr[i];
                    var tmpArr:Array = tmpString.split(",");
                   
                    for(var j:Number = 0; j < tmpArr.length; j++)
                    {
                        Temporary.INSTANCE.userSymbolNo[i][j] = tmpArr[j];
                    }
                }
                SymbolSelect.FILE_EVENT.onReload();
            }
           
            private function onSaveComplete(event:Event):void                   // 사용자 정의 파일 저장 후 심볼 재설정
            {
                SymbolSelect.FILE_EVENT.onReload();
            }
           
        ]]>
    </fx:Script>
   
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <s:Rect width="100%" height="100%" radiusX="10" radiusY="10">
        <s:stroke>
            <s:SolidColorStroke color="haloBlue" weight="2"/>
        </s:stroke>
        <s:fill>
            <s:SolidColor color="white" />
        </s:fill>
    </s:Rect>
    <s:VGroup width="100%" height="100%" bottom="10" right="1" gap="0">
        <s:Group width="100%">
            <s:Rect width="100%" height="50" left="1" right="1" top="1">
                <s:fill>
                    <s:LinearGradient>
                        <s:entries>
                            <s:GradientEntry color="0xf6f6f6" ratio="0.00" alpha="0.5" />
                            <s:GradientEntry color="0x04b6f1" ratio="0.50" alpha="0.5"/>
                        </s:entries>
                    </s:LinearGradient>
                </s:fill>
            </s:Rect>
            <s:Label id="title" text="" verticalCenter="0" horizontalCenter="0"/>
        </s:Group>
        <s:Line width="100%">
            <s:stroke>
                <s:LinearGradientStroke caps="round" weight="1">
                    <s:entries>
                        <s:GradientEntry color="red" ratio="0.5" alpha="0.5"/>
                        <s:GradientEntry color="black" ratio="0.5" alpha="0.5"/>
                    </s:entries>
                </s:LinearGradientStroke>
            </s:stroke>
        </s:Line>
        <s:TextArea id="text_main" width="100%" maxHeight="300" textAlign="center" editable="false"
                    fontSize="16" contentBackgroundAlpha="0" borderVisible="false" />
        <s:HGroup width="100%" horizontalAlign="center">
            <s:Button id="btnOk" label="OK" width="80" height="34" fontSize="18" skinClass="spark.skins.spark.ButtonSkin"/>
            <s:Button id="btnCancel" label="Cancel" width="80" height="34" fontSize="18"
                      visible="false" includeInLayout="false" click="btnClose_clickHandler(event)" skinClass="spark.skins.spark.ButtonSkin"/>
        </s:HGroup>
    </s:VGroup>
</s:SkinnablePopUpContainer>

调用方式

将上面代码保存为AlertBox.mxml

1
2
var alertObj = new AlertBox();
alertObj.showMessage("Adobe® Flex® is a highly productive, free");

无觅相关文章插件,快速提升流量


发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*


您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Bad Behavior has blocked 1450 access attempts in the last 7 days.

site tracking with Asynchronous Google Analytics plugin for Multisite by WordPress Expert at Web Design Jakarta.

serial corel draw 11

serial corel draw 11 serials

free corel photoshop download

free corel photoshop download keygen

adobe free

adobe free

key office 2010

office 2010 key

download photo shop free

photo shop serial

free winrar download for xp

download winrar for xp for free

windows 7 free

windows 7 crack

cs5 serialz

cs5 serialz free

free corel downloads

free corel downloads cracked

office 2010 free

office 2010 key

winrar password cracker serial

wirar password cracker

serial winzip 11

serial winzip 11 key

photoshop key

photoshop key

windows key

windows key

corel dvd moviefactory 6

corel dvd moviefactory 6 downloads

office 2010 professional key

office 2010 key

photo shop key

photo shop key

winrar 3 download

winrar 3 download freedownload

windows 7 key

windows 7 key