JSFLInterface (library)
Overview
Overview
The JSFL library is mainly used by the AS3 Module Framework in order to pass data back and forth from ActionScript to JSFL, whilst retaining data types between the two environments, as MMExecute calls and returns are String-based.
Contents
Concept
Values are serialized on the JSFL side into an XML format which retains type information, and is then deserialized on the ActionScript side.
The following data types are supported:
- Number
- String
- Boolean
- Date
- Object
- Array
- undefined
- null
Usage
Usually, you won't directly serialize values and send them to ActionScript, as the round-trip is initiated and controlled on the ActionScript side. A tutorial will be available shortly to explain how the AS3 Module Framework works its magic.
The actual conversion code on both the JSFL and ActionScript side is a direct port from the excellent JSFLInterface class by Matthew Tretter.
API
serialize(value)
Serializes values to XML so they can be passed to Flash and be deserialized to values again
The following serialises an example object with all the supported data types:
var data = { a:1, b:'Hello', c:true, d:new Date(), e:[1,2,3], f:undefined, g:null } var xml = JSFL.serialize(data); trace(new XML(xml).toXMLString());
<object> <property id="a"> <number>1</number> </property> <property id="b"> <string>Hello</string> </property> <property id="c"> <true/> </property> <property id="d"> <date>1311427124754</date> </property> <property id="e"> <array> <property id="0"> <number>1</number> </property> <property id="1"> <number>2</number> </property> <property id="2"> <number>3</number> </property> </array> </property> <property id="f"> <undefined/> </property> <property id="g"> <null/> </property> </object>
Comments are closed.