Flex/Air在手机中弹出提示框

在AIR中弹出一个提示框,需要操作如下。

1.在你建立的MXML组件中找到如下代码模块。。

 

[html]   view plain copy print ?
  1. <fx:Declarations>  
  2.     <!-- 将非可视元素(例如服务、值对象)放在此处 -->  
  3. </fx:Declarations>  


2.在里面添加一个用来显示的提示框。。

 

 

[html]   view plain copy print ?
  1. <s:SkinnablePopUpContainer id="popupwindow" backgroundAlpha="0.5" backgroundColor="0x000000"  
  2.                                    cachePolicy="on">  
  3.             <s:Panel id="panel_pop" width="80%" horizontalCenter="0" title="提示!" verticalCenter="0">  
  4.                 <s:VGroup width="100%" height="100%" horizontalAlign="center">  
  5.                     <s:Label id="lab_pop" color="#FF0000" paddingBottom="5" paddingTop="5"  
  6.                              text="提示内容"/>  
  7.                     <s:Button width="80" height="45" label="确定" click="popupwindow.close()"  
  8.                               styleName="dialogDefaultButton"/>  
  9.                 </s:VGroup>  
  10.             </s:Panel>  
  11.         </s:SkinnablePopUpContainer>  


SkinnablePopUpContainer 类是一个 SkinnableContainer,它用作弹出窗口。在这个弹出窗口中加入一个panel,设置标题。并在里面加入Vgroup(一个lable和button)给button加上点击事件">click="popupwindow.close()"点击按钮,关闭弹窗

[html]   view plain copy print ?
  1. 3.将弹窗显示在界面上  
[html]   view plain copy print ?
  1. <pre name="code" class="html">private function showTimeLog(str:String):void  
  2.             {  
  3.                 popupwindow.open(this,false);//打开弹窗  
  4.                 lab_pop.text = str;//设置label内容  
  5.                 updateAlertPosition();//设置弹窗的大小  
  6.                 stage.addEventListener(ResizeEvent.RESIZE, updateAlertPosition);//设置界面监听,当flex中组件大小改变时的监听  
  7.             }  
  8.             private function updateAlertPosition(event:ResizeEvent=null):void  
  9.             {  
  10.                 if (popupwindow.isOpen)//设置弹窗大小一直随着屏幕大小变更。  
  11.                 {  
  12.                     popupwindow.width = systemManager.screen.width;  
  13.                     popupwindow.height = systemManager.screen.height;  
  14.                 }  
  15.             }  

你可能感兴趣的:(Flex)