其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
FlexStore Analysis

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

纯标记语言

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



相关文章

相关软件