You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by ca...@apache.org on 2019/12/20 20:05:30 UTC

[royale-docs] branch master updated: Add Metadata info. still not finished

This is an automated email from the ASF dual-hosted git repository.

carlosrovira pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/royale-docs.git


The following commit(s) were added to refs/heads/master by this push:
     new e94aace  Add Metadata info. still not finished
e94aace is described below

commit e94aacefffb15c8eb27828ab7988e4094e348ac1
Author: Carlos Rovira <ca...@apache.org>
AuthorDate: Fri Dec 20 21:05:20 2019 +0100

    Add Metadata info. still not finished
---
 features/actionscript/metadata.md | 115 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 114 insertions(+), 1 deletion(-)

diff --git a/features/actionscript/metadata.md b/features/actionscript/metadata.md
index 1476324..499285c 100644
--- a/features/actionscript/metadata.md
+++ b/features/actionscript/metadata.md
@@ -22,4 +22,117 @@ permalink: /features/as3/metadata
 
 # Metadata
 
-Metadata
+Decorate classes, properties and methods with extra information that can be used at compile or run time
+
+Metadata decorate classes, properties and methods to give extra data to the compiler that can be used to generate code at compile time that depends on that metadata values, or can be used at runtime for code that can interpret that data to perform some specific functionality. You can use it in [AS3](features/as3) & [MXML](features/mxml).
+
+An example in **AS3** of a `Bindable` Metadata declaration decorating a variable is the following:
+
+```as3
+[Bindable]
+public var someVariable:Boolean = true;
+```
+
+In **MXML* and example of an `Event` Metadata declared for that MXML file will be the following. Notice that you need to add to the special `fx:Metadata` tag:
+
+```mxml
+<fx:Metadata>
+	[Event(name="someEvent", type="org.apache.royale.events.Event")]
+</fx:Metadata>
+```
+
+## Available Metadata
+
+Here you can find the list of all possible Royale Metadata available:
+
+### Bindable
+
+Bindable
+
+### Event
+
+Event
+
+### DefaultProperty
+
+DefaultProperty
+
+### RemoteObject
+
+DefaultProperty
+
+### Managed
+
+Managed
+
+### ChangeEvent
+
+ChangeEvent
+
+### NonCommittingChangeEvent
+
+NonCommittingChangeEvent
+
+### Transient
+
+Transient
+
+### SWFOverride
+
+SWFOverride
+
+### Inspectable
+
+Inspectable
+
+### PercentProxy
+
+PercentProxy
+
+## Example of use
+
+For example, you may create an **MXML** component that defines a new event. To make that event known to the Royale compiler that you can reference it in MXML, you insert the `[Event]` metadata tag into your component, as the following example shows:
+
+```mxml
+<fx:Metadata>
+	[Event(name="someEvent")]
+</fx:Metadata>
+```
+
+In this example, you use metadata to make the `someEvent` event available to the MXML compiler.
+
+In an MXML file, you insert the metadata tags either in an <fx:Script> block along with your ActionScript code, or in an <fx:Metadata> block, as the following example shows:
+
+```mxml
+<j:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
+	xmlns:j="library://ns.apache.org/royale/jewel">
+
+    <fx:Metadata>
+        [Event("enableChange")]
+    </fx:Metadata>
+
+    <fx:Script>
+    <![CDATA[
+        private var _enable:Boolean;
+
+        // Add the [Inspectable] metadata tag before the individual property.
+        [Inspectable(defaultValue="false")]
+        public function set enable(val:Boolean):void {
+            _enable = val;
+            this.enabled = val;
+
+            // Define event object, initialize it, then dispatch it. 
+            var eventObj:Event = new Event("enableChange");
+            dispatchEvent(eventObj);
+        }
+    ]]>
+    </fx:Script>
+</j:Group>
+```
+
+When using metadata tags in ActionScript class files, you insert the metadata tag directly into the class definition; you do not use the <fx:Metadata> tag.
+In AS3 you can use metadata as well in methods and properties of the class.
+
+## Custom Metadata
+
+You can create your own custom metadata. This info will come soon...
\ No newline at end of file