WEB开发网
开发学院图形图像Flash Understanding AS3 and XML 阅读

Understanding AS3 and XML

 2009-10-26 00:00:00 来源:WEB开发网   
核心提示:When you are about to design a Flash application using dynamic content, such as an image gallery or a tile based game, XML is one of the best ways to handle ext

When you are about to design a Flash application using dynamic content, such as an image gallery or a tile based game, XML is one of the best ways to handle external content because it’s very easy to create, understand, read, and update.

AS3 now uses a system called ECMAScript for XML (E4X) that will do most of the dirty job, allowing us to focus on the application we are goingo to write.

From Wikipedia: ECMAScript for XML (E4X) is a programming language extension that adds native XML support to ECMAScript (which includes ActionScript, DMDScript, JavaScript, JScript). The goal is to provide an alternative to DOM interfaces that uses a simpler syntax for accessing XML documents. It also offers a new way of making XML visible. Before the release of E4X, XML was always accessed at an object level. E4X instead treats XML as a primitive (like characters, integers, and booleans). This implies faster access, better support, and acceptance as a building block (data structure) of a program.

So let’s start playing with it, and let me show you the one of the worst XML you can find… a collection of Sokoban levels (guess why?)

<?xml version="1.0" encoding="ISO-8859-1"?>
<SokobanLevels xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="SokobanLev.xsd">
  <Title>Fly</Title>
  <Description>Simple Microban-style levels.</Description>
  <Email>bsimpson_910@hotmail.com</Email>
  <LevelCollection Copyright="Tim LeFevre" MaxWidth="15" MaxHeight="11">
    <Level Id="The Fly_1" Width="11" Height="11">
      <L>   ####</L>
      <L>   #  #</L>
      <L>  ##  ####</L>
      <L>###.$.$. #</L>
      <L>#  $.$.$ ##</L>
      <L>#  .$@$.  #</L>
      <L>## $.$.{$selection}nbsp; #</L>
      <L> # .$.$.###</L>
      <L> ####  ##</L>
      <L>    #  #</L>
      <L>    ####</L>
    </Level>
    <Level Id="The Fly_2" Width="13" Height="11">
      <L>    ####</L>
      <L>    #  #</L>
      <L>  ###  ####</L>
      <L>### .$.$. #</L>
      <L>#   $.$.$ ###</L>
      <L>#   .$#$.   #</L>
      <L>### $.$.{$selection}nbsp;  #</L>
      <L>  # .$.$. ###</L>
      <L>  ####  ###</L>
      <L>     # @#</L>
      <L>     ####</L>
    </Level>
    <Level Id="The Fly_3" Width="15" Height="11" Copyright="1106 1087 Jordi Doménech">
      <L>     ####</L>
      <L>    ##  ##</L>
      <L>    #    ###</L>
      <L>#####$.$.$ ###</L>
      <L>#   $.#.#.{$selection}nbsp; ##</L>
      <L>#    $.@.{$selection}nbsp;   #</L>
      <L>##  $.#.#.{$selection}nbsp;  #</L>
      <L> ### $.$.$#####</L>
      <L>   ###    #</L>
      <L>     ##  ##</L>
      <L>      ####</L>
    </Level>
  </LevelCollection>
</SokobanLevels>

1 2 3 4 5 6  下一页

Tags:Understanding AS and

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接