FlexStore Analysis

纯标记语言

Module
<mx:Model id="shippingModel" source="data/shipping.xml" />

自定义的Module

    <mx:Model id="order">

        <name>{name.text}</name>

        <address>{address.text}</address>

        <city>{city.text}</city>

        <state>{state.selectedItem.data}</state>

        <zip>{zip.text}</zip>

        <email>{email.text}</email>

        <creditCard>

            <cardType>{cardType.selectedItem.data}</cardType>

            <cardNumber>{cardNumber.text}</cardNumber>

            <cardHolder>{cardHolder.text}</cardHolder>

            <cardExpMonth>{cardExpMonth.text}</cardExpMonth>

            <cardExpYear>{cardExpYear.text}</cardExpYear>

        </creditCard>

    </mx:Model>

 

界面上各个控件数据的一致性,控件数据和Model的一致性,无需用户写代码维护

内置的验证控件: <mx:EmailValidator field="order.email"/>

 

可对一个控件进行扩展:自定义的属性、方法、事件,非常强大

<mx:VBox xmlns:mx="http://www.macromedia.com/2003/mxml" verticalGap="0" width="100%" height="100%">

 

    <mx:Metadata>

        [Event("change")]

    </mx:Metadata>

 

    <mx:Script>

        var dataObject;

        var selectedItem;

              function setValue(str: String, item: Object) {

            if (dataObject == item) return;

            if (item==undefined) {

                visible = false;

                return;

            } else {

                dataObject=item;

                visible=true;

            }

        }

    </mx:Script>

 

 

</mx:VBox>

 

 

引入CSS Script

<!-- The ActionScript code for this class is externalized in a separate .as file for better readability -->

    <mx:Script source="flexstore_script.as"/>

 

    <!-- Style sheet used in this application -->

    <mx:Style source="flexstore.css"/>

 

Script中定义的类,变量可以在mxml中直接引用

 

 

Dynamic Class:

In some cases, however, you might want to add and access properties or methods of a class at runtime that aren’t defined in the original class definition. The dynamic class modifier lets you do just that. For example, the following code adds the dynamic modifier to the Person class discussed previously:

dynamic class Person2 {
   
   
        var name:String;
   
   
        var age:Number;
   
   
}
   
   

Now, instances of the Person class can add and access properties and methods that aren’t defined in the original class, as shown in the following example:

var a_person:Person2 = new Person2();
   
   
a_person.hairColor = "blue";   //no compiler error because class is dynamic
   
   
trace(a_person.hairColor);
   
   

Subclasses of dynamic classes are also dynamic, with one exception. Subclasses of the built-in MovieClip class are not dynamic by default, even though the MovieClip class itself is dynamic. This implementation provides you with more control over subclasses of the MovieClip class, because you can choose to make your subclasses dynamic or not:

class A extends MovieClip {}        // A is not dynamic
   
   
dynamic class B extends A {}        // B is dynamic
   
   
class C extends B {}                // C is dynamic
   
   
class D extends A {}                // D is not dynamic
   
   
dynamic class E extends MovieClip{} // E is dynamic
   
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值