XML di Flex
Published Jumat, 06 Februari 2009 by TB Saepul Anwar in flexAkhirnya saya bisa meluangkan waktu untuk menulis blogs lagi, banyak sekali kegiatan yang saya lakukan setelah lulus kuliah...senang rasanya bisa menulis kembali di blogs FlexIndonesia. Btw, sudah lebih dari 6 bulan blogs ini tidak saya update..Padahal sekarang Perkembangan FLEX dan AIR semakin canggih..tadinya cman belajar amfPHP dan WebORB, eh skrang sudah ada BLazeDS buat backbone Java...Eh terus skrang udah ada Flex 4....oke sekian dulu ceritanya...
XML di Flex mengikuti aturan ECMAScript for XML (E4X) di helpnya sech dibahas bahwa tujuan menggunakan format E4X, yaitu:
- Simplicity--Where possible, E4X makes it easier to write and understand code for working with XML data.
- Consistency--The methods and reasoning behind E4X are internally consistent and consistent with other parts of ActionScript.
- Familiarity--You manipulate XML data with well-known operators, such as the dot (.) operator.
contoh penggunaan XML pada Flex
var ids:Array = [121, 122, 123];
var names:Array = [["Murphy","Pat"], ["Thibaut","Jean"], ["Smith","Vijay"]]
var x:XML = new XML("<employeeList></employeeList>");
for (var i:int = 0; i < 3; i++)
{
var newnode:XML = new XML();
newnode =
<employee id={ids[i]}>
<last>{names[i][0]}</last>
<first>{names[i][1]}</first>
</employee>;
x = x.appendChild(newnode)
}
Mungkin contoh diatas masih simpel, coba lihat code berikut
[Bindable]
private var MenuList:XML=new XML("" +
"<root>" +
"<menuitem label='File' id='file'>" +
<menuitem label='Exit' id='Exit'/>"+
</menuitem>" +
"</root>);
Pertanyaan???
1. Bagaimana menambah menuitem setelah label exit?? supaya hasilnya menjadi...
<root>
<menuitem label="File" id="file">
<menuitem label="Exit" id="Exit"'/>
<menuitem label="Open" id="Open"/>
</menuitem>
</root>)
Jawab:
untuk bisa menambahkan child setelah label exit kita bisa menggunakan XML method insertChildAfter()
.....
var newNode:XML = new XML("<menuitem label='Open' id='Open'/>");
var contentNode:XML = MenuList.menuitem.menuitem[0];
var parentNode:XML = MenuList.menuitem[0];
parentNode.insertChildAfter(contentNode, newNode[0] );
....
The following methods allow you to work with the hierarchical structure of XML objects: The following methods allow you to work with XML object attributes: The following methods allow you to you work with XML object properties: The following methods are for working with qualified names and namespaces: The following methods are for working with and determining certain types of XML content: The following methods are for conversion to strings and for formatting XML objects: There are a few additional methods: XML methods
My Profil
- TB Saepul Anwar
- I'm Flex and AIR Fan's also Entrepreneur, I like Flex and AIR because i like make code with MXML and AS 3.0 and enjoy the Flash Output. My backgroud is Multimedia, I Like design, Video, 3D, and animation.
Arsip Blog
-
▼
2009
(16)
-
▼
Februari
(14)
- IDE untuk pengembangan FLEX dan AIR
- Framework MVC di Flex dan AIR
- Mengenal File properties pada .XML pada Project AIR
- Adobe AIR 1.5.1 telah di Rilis
- Mendebug code di Flex dan AIR, Tool tambahan Debug
- Menghubungkan 2 Aplikasi AIR,Tapi Kok Error #2044
- Latihan Membuat Native Window di AIR
- Garbage Collection, Flex Performance, Memory Manag...
- Kumpulan Aplikasi AIR yang keren (2)
- Kumpulan Aplikasi AIR yang Keren
- Create Skinnable Application Using Flex + AIR
- 25 OpenSource PHP Framework
- Membuat add button pada TabNavigator
- XML di Flex
-
▼
Februari
(14)
Label
- AIR (18)
- Android (2)
- BlazeDS (1)
- flex (20)
- my Activities (4)
- php (1)
- Playbook (1)
- Project (1)
- Tutorial AIR (2)
- Tutorial Flex (2)
0 komentar:
Posting Komentar