Flex in Meta tags and use

Source: Internet
Author: User
Tags deprecated xmlns

A metadata label is a special kind of tag that is useful in code to provide the compiler with information on how to compile the program.
In fact, these tags are not compiled into the generated SWF file, but simply tell the compiler how to generate the SWF file.

The list of META tags in Flex is as follows:

label Description
[Arrayelementtype ("ElementType")] All allowed data types are defined in the array.
[Bindable]
[Bindable (event= "EventName")]
Declaring a property can use a data-binding expression in your code, and bindable can be used to bind simple data types, classes, complex data types, and functions.
[Defaultproperty ("PropertyName")] Defines the name of the default property when the component is used in Mxml.
[Deprecated] It is deprecated to identify an element of a class or class so that the compiler can recognize him and give a warning message when it is called.
[Effect] Defines the name of the effect attribute for Mxml.
[Embed] Import the Jped,png,svg or SWF file at compile time. Picture resources for SWC files are also imported. His function is equivalent to the @Embed syntax in Mxml.
[Event] Defines the name and type of the event property for Mxml.
[Exclude] Causes the Flex Builder label Checker to ignore class elements. syntax similar to [Exclude (name= "label", kind= "property")]
[Excludeclass] The Flex Builder tag Checker ignores classes. This is equivalent to the @private tag in Asdoc.
[IconFile] Define an icon file so that the component appears in Adobe Flex Builder's insert panel with that icon.
[Inspectable] Defines a list of properties that are used by the component consumer in the property hints and label checks of Flex Builder. The available values for the attribute are also defined.
[Instancetype] Specifies the data type that the property accepts in Ideferredinstance.
[Noncommittingchangeevent] Defines an event transition trigger.
[Remoteclass] Maps an ActionScript object to a Java object.
[Style] Defines an mxml tag property for the component's style properties.
[Transient] When an ActionScript object is mapped to a Java object, the attribute identified by the tag is ignored from the data sent to the server.

[Arrayelementtype]

Using the Arrayelementtype metadata tag allows you to define the data type of an array element.

[Arrayelementtype ("number")]
public Var Arr:array;

In fact, the Mxml compiler only makes a reasonable check for the usage of the Arrayelementtype metadata label in the Mxml code. The use of ActionScript code does not make a reasonable check, through the experiment can know that the arrayelementtype tag is not valid at this time.

In other words, the above declaration is invalid ~, only in Mxml can be checked correctly, you can test:

Arr.push (1);
Arr.push ("name"); and no error.

bindable Example of binding data

After declaring that the variable txt can be bound, the contents of the label displayed by the TXT will be changed when the TXT value changes.

<?xml version= "1.0" encoding= "Utf-8"?> <mx:application
xmlns:mx= "Http://www.adobe.com/2006/mxml"
layout= "Absolute" creationcomplete= "init ()" >
	<mx:Script>
		<![ cdata[
			[Bindable]
			private var txt:string = "Hello World";

			Private Function init (): void
			{
                            changebtn.addeventlistener (Mouseevent.click,
                             function (): void{txt= " Hello World,hello World "}";
			}
		]] >
	</mx:Script>
	<mx:label x= "Ten" y= "text=" {txt} "/>
	<mx:button x=" y= "36" label= "Update Data" id= "changebtn"/>
</mx:Application>

[Defaultproperty ("PropertyName")]

The Defaultproperty metadata label is used to set a single property to the default property of a class. It allows you to set properties within a container tag without having to define the name of the property.

Package mycomponents
{
    import Mx.controls.TextArea;

    Define a default property DefaultText, and the following example, hello will be the value of DefaultText.
    [Defaultproperty ("DefaultText")] public

    class Textareadefaultprop extends TextArea {public

        function Textareadefaultprop ()
        {
            super ();
        }       

        Define a setter method to set the "Text property"//to the value of the
        "default property."
        Public function set DefaultText (value:string): void {
            if (value!=null)
            text=value;
        }

        Public function Get DefaultText (): String {
            return text;}}
}

Use this component in Mxml:

<?xml version= "1.0"?>
<mx:application xmlns:mx= "Http://www.adobe.com/2006/mxml"
    xmlns:mycomp= "Mycomponents.*" >
    <MyComp:TextAreaDefaultProp>Hello</MyComp:TextAreaDefaultProp>
< /mx:application>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.