about outputing xml file

8 views
Skip to first unread message

janet e

unread,
Oct 27, 2009, 2:57:42 AM10/27/09
to 台灣 Adobe 使用者俱樂部
I'm doing a project on AS3 and i use xml as my database. As the
project restricts that we can only use AS3 and xml. So i wonder if
there is any method for AS3 to produce an xml file without using both
php and AIR?

Ben Chang

unread,
Oct 27, 2009, 8:50:34 PM10/27/09
to au...@googlegroups.com
請說明你的環境,

是 Web 應用?還是 AIR 應用?

你的 XML 資料要存在哪裡?Server 端?Client 端?




2009/10/27 janet e <jane...@gmail.com>

janet e

unread,
Oct 28, 2009, 2:28:39 AM10/28/09
to 台灣 Adobe 使用者俱樂部
Project 題目限制不能用web。 而AIR方面, 我不知道能否把AIR code放置於class內(因為有一些data 須要由AS3
pass過去的); 我的xml資料要存在於與.as (class)同一個folder內。 以下為load xml data into
AS3, 但我還須要generate/update xml file.

package {
import flash.events.*;
import flash.net.*;
import flash.xml.*;

public class xmlLoader extends EventDispatcher{
private var url:String;
private var loader:URLLoader;

public function xmlLoader(url:String) {
this.url = url;
loader = new URLLoader();

var request:URLRequest = new URLRequest(url);
loader.load(request);
loader.addEventListener(Event.COMPLETE, onComplete);

function onComplete(evt:Event) {
var myxml:XML=new XML(loader.data);
trace(myxml);
}



}

private function onComplete(event:Event):void {
dispatchEvent(new Event("XMLLoaded"));
}

private function createXML():void
{ //<---- 這部份
var url:String = "xxx.xml";
var request:URLRequest = new URLRequest(url);
trace("XML Loaded URL is"+url);
var variables:URLVariables = new URLVariables();
variables.viewid ="abcd";
//request.method=URLRequestMethod.POST;
trace("variables.viewidvariables.viewid:"+variables.viewid);
request.data = variables;
sendToURL(request); //<--
create xml file??
}
}
}

On 10月28日, 上午8時50分, Ben Chang <ben.rb.ch...@gmail.com> wrote:
> 請說明你的環境,
>
> 是 Web 應用?還是 AIR 應用?
>
> 你的 XML 資料要存在哪裡?Server 端?Client 端?
>
> 2009/10/27 janet e <janet...@gmail.com>
>
>
>
> > I'm doing a project on AS3 and i use xml as my database. As the
> > project restricts that we can only use AS3 and xml. So i wonder if
> > there is any method for AS3 to produce an xml file without using both
> > php and AIR?- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

Ben Chang

unread,
Oct 28, 2009, 4:41:17 AM10/28/09
to au...@googlegroups.com
若是 AIR,那其實可以考慮存取 SQLLite 資料庫,

若仍希望以 XML 當作存放資料的方式,那要考量到你的資料量會擴增到甚麼程度?
是個人通訊錄的應用?或許一兩百筆資料,
還是個人行事曆?若不清歷史紀錄,那就是幾百幾千筆的資料,而且可能包含大量的文字記錄,
資料量越大,存取 XML 文字檔越不經濟,

若只是學校作業,不用考慮現實面的部分,那就沒關係了


至於,建立、修改 XML 資料檔案的部分,
AIR 有 File IO 的類別可以作,
而 Flash Player 10 的 FileReference 也有 save() 的新功能,
這些還是要取決你的專案將要以哪種 flash player / platform 呈現~




2009/10/28 janet e <jane...@gmail.com>

janet e

unread,
Oct 29, 2009, 1:13:36 PM10/29/09
to 台灣 Adobe 使用者俱樂部
首先要多謝您的回答, 您回答得非常仔細!!

因為這是學校作業, 我打算製作一個遊戲, 並用xml 來儲存玩家的少量資料, 最後可能用.exe 表達出來。
除了AIR的File IO 和 Flash Player的FileReferenceny 外, 還有其他方法嗎?
Flash Player的FileReferenceny的save() 功能能建立 XML , 但會出現dialog box。
我能在玩家不察覺的情況下自動修改 XML 資料檔案嗎?

URLRequestMethod.POST 或 sendToURL(URLRequest) 能進行自動修改XML 嗎?


On 10月28日, 下午4時41分, Ben Chang <ben.rb.ch...@gmail.com> wrote:
> 若是 AIR,那其實可以考慮存取 SQLLite 資料庫,
>
> 若仍希望以 XML 當作存放資料的方式,那要考量到你的資料量會擴增到甚麼程度?
> 是個人通訊錄的應用?或許一兩百筆資料,
> 還是個人行事曆?若不清歷史紀錄,那就是幾百幾千筆的資料,而且可能包含大量的文字記錄,
> 資料量越大,存取 XML 文字檔越不經濟,
>
> 若只是學校作業,不用考慮現實面的部分,那就沒關係了
>
> 至於,建立、修改 XML 資料檔案的部分,
> AIR 有 File IO 的類別可以作,
> 而 Flash Player 10 的 FileReference 也有 save() 的新功能,
> 這些還是要取決你的專案將要以哪種 flash player / platform 呈現~
>

> 2009/10/28 janet e <janet...@gmail.com>


>
>
>
>
>
> > Project 題目限制不能用web。 而AIR方面, 我不知道能否把AIR code放置於class內(因為有一些data 須要由AS3

> > pass過去的); 我的xml資料要存在於與.as <http://xn--3ds50h88kcep26l9mjtrf.as>(class)同一個folder內。 以下為load xml data into

> > > - 顯示被引用文字 -- 隱藏被引用文字 -
>
> - 顯示被引用文字 -

Ben Chang

unread,
Oct 29, 2009, 1:29:31 PM10/29/09
to au...@googlegroups.com
在  Adobe AIR 還沒出現之前,有許多 swf2exe 的工具,
可以將你作的 swf 打包成 exe,與 flash projector 的 exe 不同的是,
你可以透過 fscommand 來與這些工具作些溝通,
這層 wrapper 可以作的事情還挺多的,除了 File IO 外,甚至連資料庫、讀寫登錄檔,

若不是由 exe 直接存取檔案的做法,還有更複雜一點的方法,設計 local server,
自己開發 socket server,你的安裝軟體會將 swf/exe 與 socket server 一起安裝到 client 端電腦,
然後 flash 程式透過 XMLSocket 來與 socket server 溝通,由 local socket server 負責存取檔案



2009/10/30 janet e <jane...@gmail.com>
Reply all
Reply to author
Forward
0 new messages