Flex中检测CheckBox是否被选中并允许用户继续与否的例子

By Minidxer | September 19, 2008

接下来的例子演示了Flex中如何检测CheckBox是否被选中并允许用户继续与否。

让我们先来看一下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.  
  7.     <mx:Script>
  8.         <![CDATA[
  9.             import mx.controls.Alert;
  10.  
  11.             private function isChecked():void {
  12.                 if (!checkBox.selected) {
  13.                     Alert.show("You must agree to the EULA before continuing.");
  14.                 } else {
  15.                     Alert.show("Continuing...");
  16.                 }
  17.             }
  18.         ]]>
  19.     </mx:Script>
  20.  
  21.     <mx:CheckBox id="checkBox"
  22.             label="I have read and agree with the EULA..." />
  23.  
  24.     <mx:Button label="Continue"
  25.             click="isChecked();" />
  26.  
  27. </mx:Application>
代码:Peter deHaan 翻译/整理/编译:中文Flex例子

Topics: Flex | Tags: , , ,

Related Post

Leave a Comment

Name(*):

E-Mail(*) :

Website :

Comments :

Search Posts

Archives

Sponsored Ads