Intro To haXe Development With FDT

From FDT Documentation

(Difference between revisions)
Jump to: navigation, search
(Wrap Up)
 
(102 intermediate revisions not shown)
Line 1: Line 1:
-
Supported by [http://www.influxis.com Influxis]
+
= About FDT HaXe  Support=
-
[[Image:010 015.png|center|010 015.png]] 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].  
+
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. 
-
<br>
+
= <center>Video</center> =
-
 
+
{{#widget:Vimeo|id=42348465|width=600|height=400}}
-
= HaXe Programming Language  =
+
-
 
+
-
<br>
+
-
 
+
-
= <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 [[Image:Img preview.png|Img preview.png]], 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 [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
When the installer is complete [[Image:Img preview.png|Img preview.png]], confirm that the installation of haXe was successful by opening your console and executing the command ''haXe'':
+
-
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">haxe</pre></div></div>
+
-
<br> If installed correctly, the console should print out haXe info:
+
-
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">OSXs-MacBook:~ OSX$ haxe
+
-
haXe Compiler 2.07 - (c)2005-2011 Motion-Twin
+
-
Usage : haxe -main &lt;class&gt; [-swf|-js|-neko|-php|-cpp|-as3] &lt;output&gt; [options]
+
-
Options :
+
-
  -cp &lt;path&gt; : add a directory to find source files
+
-
  -js &lt;file&gt; : compile code to JavaScript file
+
-
  -swf &lt;file&gt; : compile code to Flash SWF file
+
-
  -as3 &lt;directory&gt; : generate AS3 code into target directory
+
-
  -neko &lt;file&gt; : compile code to Neko Binary
+
-
  -php &lt;directory&gt; : generate PHP code into target directory
+
-
  -cpp &lt;directory&gt; : generate C++ code into target directory
+
-
  -xml &lt;file&gt; : generate XML types description
+
-
  -main &lt;class&gt; : select startup class
+
-
  -lib &lt;library[:version]&gt; : use a haxelib library
+
-
  -D &lt;var&gt; : 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
+
-
 
+
-
</pre></div></div>
+
-
If it doesn't - try restarting your computer or reinstalling it again.
+
-
 
+
-
== Install FDT's haXe Plugin <br>  ==
+
-
 
+
-
*Before you install the plugin you will need the latest copy of FDT (currently 4.3.1), so you not got it please either update or download, install, setup licence, etc...<br>
+
-
 
+
-
*Start up FDT 4 and select ''Help&gt;Install new Software''&nbsp; *Select the ''FDT Plugins Site'' update site (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)
+
-
 
+
-
<br>When you install the plugin if drill down into the FDT Plugin you will see two options now
+
-
 
+
-
*FDT haXe Plugin
+
-
*FDT haXe SDK Feature (Optional)<br>
+
-
 
+
-
If you have the following error raised during installation, then repeat the install and un-tick the "FDT haXe SDK Feature (Optional)" tick box.<br>
+
-
<pre>An error occurred while installing the items
+
-
 
+
-
session context was:(profile=epp.package.jee,
+
-
phase=org.eclipse.equinox.internal.provisional.p2.engine.phases.Install,
+
-
operand=null --&gt; [R]com.powerflasher.fdt.haxe.sdk_win 2.7.0,
+
-
action=org.eclipse.equinox.internal.p2.touchpoint.natives.actions.UnzipAction).</pre>
+
-
<br><br>[[Image:Haxe plugin install new software.png|center|600px|Haxe plugin install new software.png]] *Select "FDT haXe Plugin" from the plugin list, 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&gt;SDK'' [[Image:Img preview.png|Img preview.png]] and input the installation directory of haXe. If you're not sure where haXe is installed, the installation window will clue you in [[Image:Img preview.png|Img preview.png]]. 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'' [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
= <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'' [[Image:Img preview.png|Img preview.png]] and then create a new HaXe class by right clicking on ''src'' and choosing ''Other'' [[Image:Img preview.png|Img preview.png]]. When the wizard pops up choose HaXe Class [[Image:Img preview.png|Img preview.png]] and give the class the name ''Main'' and hit ''Finish'' [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
== <center>Convert Project To A haXe Project</center>  ==
+
-
 
+
-
With your first class created, right click on the project and select ''Add HaXe Project Nature'' [[Image:Img preview.png|Img preview.png]]. When this happens, FDT will ask you to input some project variables. We already have configured our ''HaXe SDK Location'' so just hit ''Next'' [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
Let's leave the haXe configuration file to the default location but modify the ''Output Path'' to ''bin/Main.swf'' [[Image:Img preview.png|Img preview.png]]. 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 [[Image:Img preview.png|Img preview.png]]. We can also see that FDT has begun to parse our project for syntax errors [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
== <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 [[Image:Img preview.png|Img preview.png]] and then add this argument to the bottom:
+
-
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="bash source-bash"><pre class="de1">&lt;span class="re5"&gt;-swf-header&lt;/span&gt; &lt;span class="nu0"&gt;550&lt;/span&gt;:&lt;span class="nu0"&gt;400&lt;/span&gt;:&lt;span class="nu0"&gt;40&lt;/span&gt;:FFFFFFF</pre></div></div>
+
-
Here we are setting the ''Width'' and ''Height'' properties to 500 x 400 [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
= <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 [[Image:Img preview.png|Img preview.png]]. Or type in the the code yourself to begin exploring the syntax auto completion FDT provides [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
<br>
+
-
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="actionscript source-actionscript"><pre class="de1">package&nbsp;;
+
-
&lt;span class="kw3"&gt;import&lt;/span&gt; flash.&lt;span class="me1"&gt;display&lt;/span&gt;.&lt;span class="me1"&gt;Sprite&lt;/span&gt;; &lt;span class="kw3"&gt;import&lt;/span&gt; flash.&lt;span class="me1"&gt;events&lt;/span&gt;.&lt;span class="me1"&gt;Event&lt;/span&gt;; &nbsp; &lt;span class="kw2"&gt;class&lt;/span&gt; Main&lt;span class="br0"&gt;{&lt;/span&gt; &lt;span class="kw3"&gt;static&lt;/span&gt; &lt;span class="kw2"&gt;var&lt;/span&gt; view:Sprite; &lt;span class="kw3"&gt;static&lt;/span&gt; &lt;span class="kw2"&gt;var&lt;/span&gt; x: Float = &lt;span class="nu0"&gt;0&lt;/span&gt;; &lt;span class="kw3"&gt;static&lt;/span&gt; &lt;span class="kw2"&gt;var&lt;/span&gt; y: Float = &lt;span class="nu0"&gt;200&lt;/span&gt;; &lt;span class="kw3"&gt;static&lt;/span&gt; &lt;span class="kw2"&gt;var&lt;/span&gt; speed&nbsp;:Float = &lt;span class="nu0"&gt;20&lt;/span&gt;; &lt;span class="kw3"&gt;static&lt;/span&gt; &lt;span class="kw2"&gt;var&lt;/span&gt; max_x&nbsp;: Float = &lt;span class="nu0"&gt;550&lt;/span&gt;; &nbsp; &lt;span class="kw3"&gt;static&lt;/span&gt; &lt;span class="kw2"&gt;function&lt;/span&gt; main&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; &lt;span class="br0"&gt;{&lt;/span&gt; &lt;span class="kw2"&gt;new&lt;/span&gt; Main&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;; &lt;span class="br0"&gt;}&lt;/span&gt; &nbsp; &lt;span class="kw2"&gt;function&lt;/span&gt; &lt;span class="kw2"&gt;new&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;{&lt;/span&gt; view = &lt;span class="kw2"&gt;new&lt;/span&gt; Sprite&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;; flash.&lt;span class="me1"&gt;Lib&lt;/span&gt;.&lt;span class="me1"&gt;current&lt;/span&gt;.&lt;span class="me1"&gt;addChild&lt;/span&gt; &lt;span class="br0"&gt;(&lt;/span&gt;view&lt;span class="br0"&gt;)&lt;/span&gt;; flash.&lt;span class="me1"&gt;Lib&lt;/span&gt;.&lt;span class="me1"&gt;current&lt;/span&gt;.&lt;span class="kw3"&gt;stage&lt;/span&gt;.&lt;span class="me1"&gt;addEventListener&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;Event.&lt;span class="me1"&gt;ENTER_FRAME&lt;/span&gt;, update_view&lt;span class="br0"&gt;)&lt;/span&gt;; &lt;span class="br0"&gt;}&lt;/span&gt; &nbsp; &lt;span class="kw2"&gt;function&lt;/span&gt; update_view &lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="kw3"&gt;e&lt;/span&gt;: &lt;span class="kw3"&gt;Dynamic&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;{&lt;/span&gt; view.&lt;span class="me1"&gt;graphics&lt;/span&gt;.&lt;span class="kw3"&gt;clear&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;; view.&lt;span class="me1"&gt;graphics&lt;/span&gt;.&lt;span class="kw3"&gt;beginFill&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;0xff0000, &lt;span class="nu0"&gt;1&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;; view.&lt;span class="me1"&gt;graphics&lt;/span&gt;.&lt;span class="me1"&gt;drawCircle&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;x, y, &lt;span class="nu0"&gt;50&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;; &nbsp; &lt;span class="kw1"&gt;if&lt;/span&gt;&lt;span class="br0"&gt;(&lt;/span&gt;is_invalid_x&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt; speed = speed &lt;span class="sy0"&gt;*&lt;/span&gt; -&lt;span class="nu0"&gt;1&lt;/span&gt;; x+= speed; &lt;span class="br0"&gt;}&lt;/span&gt; &nbsp; &lt;span class="kw2"&gt;function&lt;/span&gt; is_invalid_x&lt;span class="br0"&gt;(&lt;/span&gt;&lt;span class="br0"&gt;)&lt;/span&gt;&nbsp;: Bool &lt;span class="br0"&gt;{&lt;/span&gt; &lt;span class="kw1"&gt;return&lt;/span&gt; x &lt;span class="sy0"&gt;&gt;&lt;/span&gt; max_x &lt;span class="sy0"&gt;||&lt;/span&gt; x &lt;span class="sy0"&gt;&lt;&lt;/span&gt; &lt;span class="nu0"&gt;0&lt;/span&gt;; &lt;span class="br0"&gt;}&lt;/span&gt; &lt;span class="br0"&gt;}&lt;/span&gt;</pre></div></div>
+
-
== <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 [[Image:Img preview.png|Img preview.png]]. If it doesn't appear, try refreshing your project [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
== <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&gt;other'' [[Image:Img preview.png|Img preview.png]] and then select an XML file to create [[Image:Img preview.png|Img preview.png]] and hit ''Finish''. Give the script any name you like, this one is called ''view_swf.xml'' and hit ''Finish'' [[Image:Img preview.png|Img preview.png]].
+
-
 
+
-
Next, copy the code below to have FDT launch the external .SWF viewer [[Image:Img preview.png|Img preview.png]]:
+
-
<div dir="ltr" class="mw-geshi" style="text-align: left;"><div class="xml source-xml"><pre class="de1">&lt;span class="sc3"&gt;&lt;span class="re1"&gt;&lt;project&lt;span class="re2"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&lt;target&lt;/span&gt; &lt;span class="re0"&gt;name&lt;/span&gt;=&lt;span class="st0"&gt;"view.swf"&lt;/span&gt;&lt;span class="re2"&gt;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&lt;fdt.extSWFViewer.startSWF&lt;/span&gt; &lt;span class="re0"&gt;width&lt;/span&gt;=&lt;span class="st0"&gt;"550"&lt;/span&gt; &lt;span class="re0"&gt;height&lt;/span&gt;=&lt;span class="st0"&gt;"400"&lt;/span&gt;&lt;/span&gt; &lt;span class="sc3"&gt;                    &lt;span class="re0"&gt;file&lt;/span&gt;=&lt;span class="st0"&gt;"${basedir}/bin/Main.swf"&lt;/span&gt;&lt;span class="re2"&gt;/&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&lt;/target&lt;span class="re2"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class="sc3"&gt;&lt;span class="re1"&gt;&lt;/project&lt;span class="re2"&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</pre></div></div>
+
-
<br> Then, drag your .XML file to the Ant view [[Image:Img preview.png|Img preview.png]] and double click the target to launch [[Image:Img preview.png|Img preview.png]]. 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 [http://lists.motion-twin.com/mailman/listinfo/haxe 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