第5课 Spark组件、Halo组件和Flex命名空间

来源:互联网 发布:如何查看淘宝宝贝分类 编辑:程序博客网 时间:2024/05/22 14:28

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
 </fx:Declarations>
 <fx:Script>
  <![CDATA[
   import com.pomodo.model.Task;
   
   import mx.collections.ArrayCollection;
   
   [Bindable]
   private var _tasks:ArrayCollection = new ArrayCollection();
   
   private function createTask():void {
    _tasks.addItem(new Task(newTaskTI.text));
   }
   
   private function deleteSelectedTask():void {
    _tasks.removeItemAt(taskList.selectedIndex);
   }
  ]]>
 </fx:Script>
 <s:Panel title="Todo List" width="100%" height="100%">
  <s:VGroup width="100%" height="100%">
   <s:HGroup width="100%" verticalAlign="middle">
    <s:Label text="new Task" />
    <s:TextInput id="newTaskTI" width="100%"
        enter="createTask()"/>
    <s:Button label="Create" click="createTask()" />
   </s:HGroup> 
   <s:List id="taskList" width="100%" height="100%"
     labelField="name"
     dataProvider="{_tasks}" />
   <s:HGroup width="100%">
    <s:Button label="Delete" width="100%" height="30"
        enabled="{taskList.selectedItem != null}"
        click="deleteSelectedTask()" />
   </s:HGroup> 
  </s:VGroup>
  
  
  
 </s:Panel>
</s:Application>

原创粉丝点击