Jul 21

接下来的例子演示了Flex中如何通过selectable属性,创建一个文本不可选中Alert。特别注意的是本例中用到了mx_internal,这在后继版本中有可能会有无法使用的情况。

让我们先来看一下Demo可以右键View Source或点击这里察看源代码):


下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  3.         layout="vertical"
  4.         verticalAlign="middle"
  5.         backgroundColor="white"
  6.         creationComplete="init()">
  7.  
  8.     <mx:Script>
  9.         <![CDATA[
  10.             import mx.controls.Alert;
  11.  
  12.             private var a:Alert;
  13.  
  14.             private function init():void {
  15.                 Alert.buttonWidth = 100;
  16.                 Alert.okLabel = "You rule!";
  17.                 Alert.cancelLabel = "I hate you!";
  18.                 a = Alert.show("This is some text, but you cant select it.", "An Alert control with unselectable text", Alert.OK | Alert.CANCEL);
  19.                 a.mx_internal::alertForm.mx_internal::textField.selectable = false;
  20.             }
  21.         ]]>
  22.     </mx:Script>
  23.  
  24.     <mx:Button label="Launch Alert" click="init()" />
  25.  
  26. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:minidxer

written by Minidxer  |  tags: , ,

Related Post

One Response to “Flex中如何通过selectable属性创建一个文本不可选中Alert的例子”

Trackbacks

Leave a Reply