ข้ามไปที่เนื้อหาหลัก

HelloWorld ( Flex 3 on ubuntu linux tutorial )

1. Download Flex SDK ( ไม่ใช่ Flex Builder นะ Flex Builder มันไม่ฟรี )
2. Windows : set Environment Variable ชี้ไปที่ bin
Mac : แก้ บน linux .profile
Linux : export PATH=PATH:[พาธที่ลง flex]/bin
หรือ ถ้าจะเซตถาวร ให้ไปเซต DefaultPath ใน /etc/gdm/gdm.conf

dsin@dsin-laptop:~/Desktop/flex_sdk_3/bin$ ./mxmlc --version
Version 3.0.0 build 477

3. HelloWorld.mxml
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Panel title="My Application">
<mx:Label text="Hello World">
</mx:Label>
</mx:Panel>
</mx:Application>
tag หลัก คือ Application
โดยเราใส่ Panel เข้าไป
ดู reference ของคำสั่งได้ที่นี่

4. compile
$ mxmlc --show-actionscript-warnings=true --strict=true ./HelloWorld.mxml
Loading configuration file /media/disk/flex_sdk_3/frameworks/flex-config.xml
/media/disk/flex/HelloWorld.swf (158502 bytes)


พอรันเสร็จจะได้พาธของ swf

--show-actionscript-warnings=true : แสดง warning ของ actionscript
--strict=true : ให้เข้มงวดเกี่ยวกับ error checking ของ AS3

หรือ หรือ หรือ

ลอง hello world จาก HelloWorld.as ( ชื่อไฟล์ต้องตรงกับ ชื่อคลาส )
   package {
import flash.text.TextField;
import flash.display.Sprite;

public class HelloWorld extends Sprite {
public function HelloWorld() {
var txtHello:TextField = new TextField();
txtHello.text = "Hello World";
addChild(txtHello);
}
}
}


$ mxmlc HelloWorld.as


จะให้ดี โหลด Download "the Flash Player 10 Linux debugger and standalone players" จาก ที่นี่ มาด้วย ชีวิตจะง่ายขึ้นเยอะ


วิธีเซต Source Path ( Build Path ) ของ Flex บน linux

ก็อบ flex-config.xml จาก ${flex_sdk_home}/frameworks ไป
ยัง โฟลเดอร์ของเรา แก้มันซะ

แล้วเอาคอมเมนท์บรรทัดนี้ออกไป

<source-path>
<path-element>/mnt/disk/AIT/Thesis/pathfinding/away3dlite_1_0_0/away3dlite_1_0_0</path-element>
</source-path>


วิธีคอมไพล์

$ mxmlc -load-config flex-config.xml


มันจะเจ๊งประมาณว่า

Error: unable to open 'libs/player/9/playerglobal.swc'


โอ๊ย หาไม่เจอ

ให้ใส่ ${flexlib} ซึ่งเป็นพาธไปที่ sdk_source ของเราลงไป
ดังนั้นใส่ไปตามนี้

<path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}/playerglobal.swc</path-element>


ใส่ไปทุกๆ path-element เพื่อชี้ path ให้ถูกต้อง อ้อ ใส่ใน manifest ด้วย

<manifest>${flexlib}/mxml-manifest.xml</manifest>



ref : asantoso

ความคิดเห็น