Wednesday, April 8, 2009

How to insert a character & also about the static constants

1.STATIC CONSTANT:
In MXML, we can either use the static constant to set the property value, or use the value of the static constant.
Examples:
Set the property using the static constant.
horizontalScrollPolicy="{ScrollPolicy.OFF}

Set the property using the value of the static constant.
horizontalScrollPolicy="off"

Advantage:

The advantage of using the static constant is that the Flex compiler recognizes incorrect property values, and issues an error
message at compile time.


2.NEWLINE CHARACTER:

To insert a newline character, create an ActionScript variable, and then use data binding to set the property in MXML,
as the following example shows:

Example:


[Bindable]
public var myText:String = "Display" + "\n" + "Content";
]]>



EXPLANATION:

* This example includes the [Bindable] metadata tag before the property definition.
* This metadata tag specifies that the myText property can be used as the source of a data binding expression.
* Data binding automatically copies the value of a source property of one object to the destination property of another object at run time when the source property changes.
* If you omit this metadata tag, the compiler issues a warning message specifying that the property cannot be used as the source for data binding.

No comments:

Post a Comment