Intro To haXe Development With FDT

From FDT Documentation

(Difference between revisions)
Jump to: navigation, search
(Wrap Up)
(Wrap Up)
 
(113 intermediate revisions not shown)
Line 1: Line 1:
-
Supported by [http://www.influxis.com Influxis]
+
= About FDT HaXe Support=
-
[[File:010_015.png|center]]
+
HaXe is an open source and multiplatform programming language. Developed in collaboration with [http://www.powerflasher.com/ Powerflasher] and supported by [http://www.influxis.com/ Influxis], the FDT haXe plugin provides developers a powerful tool for authoring the haXe multi-platform language. Our goal is to provide the best haXe coding experience and that it feels like coding in the AS2, AS3 or MXML editor of [http://fdt.powerflasher.com/ FDT]: same shortcuts, same syntax coloring, same coding comfort. 
-
haXe is an open source and multiplatform programming language. To learn more and get the latest info on using haXe and the platforms it targets, check out the [http://haxe.org/doc/intro haXe's Introduciton].
+
-
 
+
= <center>Video</center> =
-
= <center>Source Files</center> =
+
{{#widget:Vimeo|id=42348465|width=600|height=400}}
-
[[File:Download_soruce_files.png|center|link=http://github.com/downloads/Powerflasher/FDT-Resources/haXe_finish.zip]]
+
-
 
+
-
=<center>Installation</center>=
+
-
To get started with haXe, you'll need to download a few extra add-ons.
+
-
 
+
-
==<center>Download haXe</center>==
+
-
 
+
-
Visit haXe's download page [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_001.gif]], and download one of the automatic installers for your platform.  For this example, we'll be installing haXe for OSX.
+
-
 
+
-
While installing, the installer may ask you to install ''Neko''. Neko is a language / Virtual Machine platform that comes with the installer. Even if you've never use Neko and haXe together, it may come in handy in the future so go ahead and install that as well [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_002.gif]].
+
-
+
-
When the installer is complete [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_003.gif]], confirm that the installation of haXe was successful by opening your console and executing the command ''haXe'':
+
-
 
+
-
<syntaxhighlight lang="bash">
+
-
haxe
+
-
</syntaxhighlight>
+
-
 
+
-
 
+
-
If installed correctly, the console should print out haXe info:
+
-
 
+
-
<syntaxhighlight lang="bash">
+
-
OSXs-MacBook:~ OSX$ haxe
+
-
haXe Compiler 2.06 - (c)2005-2010 Motion-Twin
+
-
Usage : haxe -main <class> [-swf9|-swf|-js|-neko|-php|-cpp|-as3] <output> [options]
+
-
Options :
+
-
  -cp <path> : add a directory to find source files
+
-
  -js <file> : compile code to JavaScript file
+
-
  -swf <file> : compile code to Flash SWF file
+
-
  -swf9 <file> : compile code to Flash9 SWF file
+
-
  -as3 <directory> : generate AS3 code into target directory
+
-
  -neko <file> : compile code to Neko Binary
+
-
  -php <directory> : generate PHP code into target directory
+
-
  -cpp <directory> : generate C++ code into target directory
+
-
  -xml <file> : generate XML types description
+
-
  -main <class> : select startup class
+
-
  -lib <library[:version]> : use a haxelib library
+
-
  -D <var> : define a conditional compilation flag
+
-
  -v : turn on verbose mode
+
-
  -debug : add debug informations to the compiled code
+
-
  -help  Display this list of options
+
-
  --help  Display this list of options
+
-
</syntaxhighlight>
+
-
 
+
-
 
+
-
If it doesn't - try restarting your computer or reinstalling it again.
+
-
 
+
-
==<center>Install FDT's haXe Plugin</center>==
+
-
*Start up FDT 4 and select ''Help>Install new Software'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_0001.png]].
+
-
*Select the ''FDT Plugins Site'' update site [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_0002.png]] (If it is not included in your drop down menu, enter: http://fdt.powerflasher.com/plugins in the ''Work with'' text input and hit return).
+
-
*Select "FDT haXe Plugin" from the plugin list [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_0003.png]], hit ''Finish'' and follow the final installation steps.
+
-
 
+
-
=<center>Setting up the haXe Plugin</center>=
+
-
Before authoring and compiling haXe, you'll need to define the haXe SDK location for FDT to reference. Open FDT's preference widow and navigate to ''HaXe>SDK'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_005.gif]] and input the installation directory of haXe. If you're not sure where haXe is installed, the installation window will clue you in [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_006.gif]]. Here we can see that the installer is moving files and creating links to ''/usr/lib/haxe'' - this is the default location for OSX. After inputing the sdk location, hit ''OK'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_007.gif]].
+
-
 
+
-
=<center>Create Your First haXe Project</center>=
+
-
 
+
-
All haXe projects begin with a Flash Project base and then are converted to a haXe project. Begin by creating an ''Empty AS3 Project'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_008.gif]] and then create a new HaXe class by right clicking on ''src'' and choosing ''Other'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_010.gif]]. When the wizard pops up choose HaXe Class [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_011.gif]] and give the class the name ''Main'' and hit ''Finish'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_012.gif]].
+
-
 
+
-
==<center>Convert Project To A haXe Project</center>==
+
-
With your first class created, right click on the project and select ''Add HaXe Project Nature'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_013.gif]]. When this happens, FDT will ask you to input some project variables. We already have configured our ''HaXe SDK Location'' so just hit ''Next'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_014.gif]].
+
-
 
+
-
Let's leave the haXe configuration file to the default location but modify the ''Output Path'' to ''bin/Main.swf'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_015.gif]].  When completed, FDT will have created a few extra files and folders for us.  We don't need to worry about ''.hxtypes'' but we use ''project.hxml'' to set configurations to our project [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_016.gif]]. We can also see that FDT has begun to parse our project for syntax errors [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_017.gif]].
+
-
 
+
-
==<center>Adjust Compiler Settings</center>==
+
-
Before writing some code, let's alter some compiler options - this is done via the ''project.hxml'' file. Open us the file by double clicking on it [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_018.gif]] and then add this argument to the bottom:
+
-
 
+
-
<syntaxhighlight lang="bash">
+
-
-swf-header 550:400:40:FFFFFFF
+
-
</syntaxhighlight>
+
-
+
-
Here we are setting the ''Width'' and ''Height'' properties to 500 x 400 [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_020.gif]].
+
-
 
+
-
= <center>Compiling and Viewing your .SWF</center> =
+
-
 
+
-
==<center>Adding haXe Code</center>==
+
-
The syntax of haXe is a bit beyond the scope of this tutorial - but that doesn't mean we have to code something boring! Copy and paste the code below to make a simple animation [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_021.gif]]. Or type in the the code yourself to begin exploring the syntax auto completion FDT provides [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_022.gif]].
+
-
 
+
-
 
+
-
<syntaxhighlight lang="actionscript">
+
-
package ;
+
-
import flash.display.Sprite;
+
-
import flash.events.Event;
+
-
 
+
-
class Main{
+
-
static var view:Sprite;
+
-
static var x: Float = 0;
+
-
static var y: Float = 200;
+
-
static var speed :Float = 20;
+
-
static var max_x : Float = 550;
+
-
+
-
    static function main() {
+
-
new Main();   
+
-
    }
+
-
   
+
-
    function new(){
+
-
    view = new Sprite();
+
-
    flash.Lib.current.addChild (view);
+
-
    flash.Lib.current.stage.addEventListener(Event.ENTER_FRAME, update_view);
+
-
    }
+
-
   
+
-
    function update_view (e: Dynamic){
+
-
    view.graphics.clear();
+
-
    view.graphics.beginFill(0xff0000, 1);
+
-
    view.graphics.drawCircle(x, y, 50);
+
-
   
+
-
    if(is_invalid_x()) speed  = speed * -1;
+
-
    x+= speed;
+
-
    }
+
-
   
+
-
    function  is_invalid_x() : Bool {
+
-
    return x > max_x || x < 0;
+
-
    }
+
-
}
+
-
</syntaxhighlight>
+
-
 
+
-
==<center>Compiling haXe</center>==
+
-
 
+
-
For the time being, FDT will automatically attempt to compile your .SWF every time you save it. If there are no errors in your project, your .SWF will appear in your ''bin'' folder [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_023.gif]]. If it doesn't appear, try refreshing your project [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_024.gif]].
+
-
 
+
-
==<center>View Your SWF</center>==
+
-
 
+
-
As this FDT plugin is still in it's early stages, there are no launch configurations to automatically view your .SWF - but we can make a simple Ant script to view our .SWF! We'll quickly go over a simple script to view our .SWF but for more in depth know-how on using Ant, check out the [[FDT and Ant Tutorial]].
+
-
 
+
-
Create a new Ant script by beginning with a simple XML file by right clicking on the project and choosing ''new>other'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_025.gif]] and then select an XML file to create [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_026.gif]] and hit ''Finish''. Give the script any name you like, this one is called ''view_swf.xml'' and hit ''Finish'' [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_027.gif]].
+
-
 
+
-
Next, copy the code below to have FDT launch the external .SWF viewer [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_028.gif]]:
+
-
 
+
-
<syntaxhighlight lang="xml">
+
-
<project>
+
-
<target name="view.swf">
+
-
<fdt.extSWFViewer.startSWF width="550" height="400"
+
-
                    file="${basedir}/bin/Main.swf"/>
+
-
</target>
+
-
</project>
+
-
</syntaxhighlight>
+
-
 
+
-
 
+
-
Then, drag your .XML file to the Ant view [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_029.gif]] and double click the target to launch [[File:Img_preview.png | link=http://fdt.powerflasher.com/docs/File:010_030.gif]]. You will then see a red ball moving back and forth on the screen.
+
-
 
+
-
*note: ''If you get an error while tying to run the Ant file, it's probably a JRE error, check out the [[FDT and Ant Tutorial]] to learn how to correct it.''
+
-
 
+
-
=<center>Wrap Up</center>=
+
-
That's it, you've successfully set up your first FDT haXe Flash project!
+
-
 
+
-
As this plugin is still an Alpha release, please bare with us! For any feedback, feature requests, improvements, bugs and other issues we encourage you to use [http://bugs.powerflasher.com/jira/browse/FTDHXPLIN Jira], our community driven tracking website, to make the haXe support in FDT the greatest ever. We also suggest anyone anyone interested in haXe developement to subscribe to the haXe mailing list. It's a very active group with smart people and interesting topics.
+
-
 
+
-
On the behalf of the FDT Team and [http://www.influxis.com Influxis], we hope you are as excited as we are and enjoy the FDT haXe plugin.
+

Latest revision as of 16:33, 17 May 2012

About FDT HaXe Support

HaXe is an open source and multiplatform programming language. Developed in collaboration with Powerflasher and supported by Influxis, the FDT haXe plugin provides developers a powerful tool for authoring the haXe multi-platform language. Our goal is to provide the best haXe coding experience and that it feels like coding in the AS2, AS3 or MXML editor of FDT: same shortcuts, same syntax coloring, same coding comfort. 

Video

Get FDT5