ActionStep Alpha 1 Released!

ActionStep crew released the first alpha release of ActionStep component framework.
It’s been a while since I’m looking at this project and I must admit they’re doing a great and hard work.
What is ActionStep?
ActionStep is an Actionscript 2.0 implementation of a subset of the OpenStep Application Kit and aim to be a valid alternative to Flash V2 Components.
The alpha 1 release comes with an example (through buildExample.bat, which compile using MTASC). See the example here
Links
ActionStep on OSFlash: http://osflash.org/doku.php?id=actionstep
ActionStep components’ list: http://osflash.org/actionstep_components_list
Download
It can be downloaded from: actionstep_alpha_1.zip
http://actionstep.org/

ActionScript 3.0, first attempt

Finally I found the time (not so much) to play a little with Flex 2 alpha and ActionScript 3.0.
In particular I falled in love with the so long awaited ByteArray class, which let us to do bytes operations 🙂
So I’ve created a porting of the GNU gettext class for ActionScript. I’ve got this wish since a long long time, but it was always impossible without the new ByteArray class.
For the complete article read here, also for an explanation of gettext.

The project is hosted on google code here.

and this is the code I’ve used in flex:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml" xmlns="*" creationComplete="main()">
<mx:Script>
<![CDATA[
import flash.events.*;
import flash.utils.trace;
import i18n.gettext;
import flash.net.*;
import mx.controls.*;
import mx.controls.gridclasses.DataGridColumn
var ln:gettext;
var alert:Alert;
var added:Boolean;
/**
* init gettext
*/
public function init_gettext()
{
ln = new gettext();
ln.addEventListener("complete", this.handleEvent);
ln.addEventListener("ioError",  this.handleEvent);
ln.addEventListener("error",    this.handleError);
set_locale("it");
}
public function set_locale(lang:String)
{
alert = Alert.show("Please wait while loading locale dictionary file", "Loading...", Alert.NONMODAL, this, null, null);
ln.translation("SEPY", "http://www.sephiroth.it/_temp/flex/gettext/locale/", lang);
ln.install();
log("innstall('" + lang + "')");
}
/**
* items for the combobox component
*/
public function get_avail_languages():Array
{
var data:Array = new Array();
data.push({label: _(gettext.FindLanguageInfo("it")), data:"it"});
data.push({label: _(gettext.FindLanguageInfo("en")), data:"en"});
data.push({label: _(gettext.FindLanguageInfo("de")), data:"de"});
data.push({label: _(gettext.FindLanguageInfo("zh_cn")), data:"zh_cn"});
data.push({label: _(gettext.FindLanguageInfo("zh_tw")), data:"zh_tw"});
data.push({label: _(gettext.FindLanguageInfo("nl")), data:"nl"});
data.push({label: _(gettext.FindLanguageInfo("fr")), data:"fr"});
data.push({label: _(gettext.FindLanguageInfo("pt")), data:"pt"});
return data;
}
/**
* items for the datagrid component
*/
public function get_dataprovider():Array
{
var data:Array = new Array();
data.push({label:"Add new folder", data:_("Add new folder")})
data.push({label:"An Error occurred, or the package need to be recompiled first", data:_("An Error occurred, or the package need to be recompiled first")})
data.push({label:"Are you sure?", data:_("Are you sure?")})
data.push({label:"Add @see if extended class (must be listed in the tags list)", data:_("Add @see if extended class (must be listed in the tags list)")})
data.push({label:"Browse new package", data:_("Browse new package")})
data.push({label:"Capture output", data:_("Capture output")})
data.push({label:"Cannot wrote to filesystem", data:_("Cannot wrote to filesystem")})
data.push({label:"Cannot read file, invalid zip file", data:_("Cannot read file, invalid zip file")})
data.push({label:"Cannot modify read-only document", data:_("Cannot modify read-only document")})
data.push({label:"Choose application", data:_("Choose application")})
return data;
}
/**
* main HandleEvent Responder
* handle all the event dispatched
*/
public function handleEvent(event:Event){
this.log("event: " + event.type);
switch(event.type)
{
case "click":
if(event.target.name == "button_1")
{
var mc:ComboBox = ComboBox(this.h_box_1.getChildByName("combo_languages"));
this.set_locale(mc.selectedItem.data);
} else {
this.callLater(init_gettext);
}
break;
case EventType.COMPLETE:
alert.visible = false;
if(!this.added)
{
var combo:ComboBox = new ComboBox();
var label:Label    = new Label();
var button:Button  = new Button();
var dp:DataGrid = new DataGrid();
var col_1:DataGridColumn = new DataGridColumn();
var col_2:DataGridColumn = new DataGridColumn();
var label_2:Label = new Label();
var hrule:HRule = new HRule()
button.name = "button_1"
button.addEventListener("click", this.handleEvent);
combo.name = "combo_languages";
label.name = "label_1";
this.h_box_1.addChild(label);
this.h_box_1.addChild(combo);
this.h_box_1.addChild(button);
dp.name = "datagrid_1";
dp.width = 560;
col_1.columnName = "label";
dp.addColumn(col_1);
col_2.columnName = "data";
col_2.headerText = _("Translation")
dp.addColumn(col_2);
label_2.name = "label_2";
hrule.width = 560;
this.v_box_1.addChild(label_2);
this.v_box_1.addChild(hrule)
this.v_box_1.addChild(dp);
this.added = true;
}
Button(this.h_box_1.getChildByName("button_1")).label = _("Change to");
Label(this.h_box_1.getChildByName("label_1")).text    = _("Language") + ": ";
Label(this.v_box_1.getChildByName("label_2")).text    = _("Test project");
ComboBox(this.h_box_1.getChildByName("combo_languages")).dataProvider = this.get_avail_languages();
DataGrid(this.v_box_1.getChildByName("datagrid_1")).dataProvider = this.get_dataprovider();
DataGrid(this.v_box_1.getChildByName("datagrid_1")).getColumnAt(0).headerText = _("Select items");
break;
default:
break;
}
}
/**
* Application init()
*/
public function main(){
var mc:Alert = Alert.show("Demo application using gettext for internationalization (i18n) puropose. Press the 'OK' button to load the English default language, then use the combo for switch between languages", "Flash and gettext", Alert.OK, this, null, null, Alert.OK);
mc.addEventListener("click", this.handleEvent);
}
/**
* shortcut usually used for
* gettext applications
*/
public function _(name:String):String
{
return gettext.translate(name);
}
public function log(text:String)
{
logger.text += text + "\n"
logger.vPosition = logger.maxVPosition
}
public function handleError(event:ErrorEvent)
{
log(event.text);
}
public function get_url()
{
navigateToURL(new URLRequest('http://www.gnu.org/software/gettext/'));
}
public function init_app():Void
{
Alert.show("Titolo", "testo", Alert.OK, this, null, null, Alert.OK);
}
]]>
</mx:Script>
<mx:Canvas width="100%" height="100%">
<mx:Label x="29" y="20" text="Gettext application demo" fontFamily="Georgia" fontWeight="bold" fontSize="18"/>
<mx:HRule x="33" y="39" width="560" height="20" themeColor="haloBlue"/>
<mx:HRule x="33" y="195" width="560" height="20" themeColor="haloBlue"/>
<mx:HRule x="33" y="89" width="560" height="20" themeColor="haloBlue"/>
<mx:Label x="32" y="111" text="log:" width="133"/>
<mx:Link x="369" y="26" label="http://www.gnu.org/software/gettext/" width="226" themeColor="haloBlue" textAlign="right" click="get_url()" toolTip="{_('Visit the GNU gettext project')}"/>
<mx:TextArea x="32" y="137" width="560" height="59" id="logger" editable="false" wordWrap="true"/>
<mx:HBox x="35" y="54" width="560" height="38" id="h_box_1" horizontalAlign="left" verticalAlign="middle" label="combo box languages">
</mx:HBox>
<mx:VBox id="v_box_1" horizontalAlign="left" verticalAlign="top" height="362" y="217">
<mx:layoutConstraints>
<mx:EdgeAnchor right="243" left="33"/>
</mx:layoutConstraints>
</mx:VBox>
</mx:Canvas>
</mx:Application>

http://code.google.com/p/sepy-gettext/

Draggable Controller

After reading all the comments added on the Drag n’ Drop Tree component made some time ago I spent some time to make a small component which is capable to manage drag and drop between almost all the Macromedia builtins component (such as List, DrataGrid, Tree…).
It requires Flash 8 to work because I’m using BitmapData for clone the dragged item (wow, this is incredible easy to do now 🙂 )
You can see a demo here: DraggableController.html
This is the code used in the .fla, in order to manage the component events:

/**
Setting up the list of relationship between components
**/
dc.AddReference(this._datagrid_1, this._list_1)
dc.AddReference(this._datagrid_1, this._datagrid_2)
dc.AddReference(this._datagrid_1, this._tree_1)
dc.AddReference(this._datagrid_1, this._datagrid_1)
dc.AddReference(this._list_1, this._list_2)
dc.AddReference(this._list_1, this._text_ctrl_1)
dc.AddReference(this._text_ctrl_2, this._list_2)
dc.AddReference(this._tree_1, this._list_2)
dc.AddReference(this._tree_1, this._text_ctrl_2)
dc.AddReference(this._tree_1, this._text_area_1)
dc.AddReference(this._list_2, this._text_area_1)
/** drag complete listener **/
dc.addEventListener("drag_complete", this)
/**
evt:
- target_component = drop destination component
- source_component = drag n' drop source component
- source_item      = item dragged
- source_index     = selectedIndex of the source component
- target_item      = drop destination item inside target_component
- target_index     = drop destination index
IMPORTANT: once received evt you must Veto() or Skip() the evt itself.
evt.Skip() will simply remove the dragging movieclip
evt.Veto() will move back the dragging item to its source
*/
function drag_complete(evt:Object):Void{
if(evt.target_component == _list_1){
evt.Veto()
} else if(evt.target_component == _datagrid_2 or evt.target_component == _datagrid_1){
evt.source_component.removeItemAt(evt.source_index)
evt.target_component.addItemAt(evt.target_index, evt.source_item)
Selection.setFocus(null)
evt.target_component.selectRow(evt.target_index, false, false)
evt.Skip()
} else if(evt.target_component == _tree_1){
evt.source_component.removeItemAt(evt.source_index)
var node:XMLNode = new XMLNode(1, "node")
node.attributes.label = evt.source_item.title +  "(Cloned)"
node.attributes.data = evt.source_item
evt.target_item.appendChild(node)
evt.Skip()
} else if(evt.target_component == _text_ctrl_1){
evt.source_component.removeItemAt(evt.source_index)
evt.target_component.text = evt.source_item.label
evt.Skip()
} else if(evt.target_component == _list_2 && evt.source_component == _tree_1){
evt.source_item.removeNode()
evt.source_component.dataProvider = evt.source_component.getDataProvider()
evt.target_component.addItemAt(evt.target_index, evt.source_item.attributes.label)
evt.Skip()
} else if(evt.target_component == _text_area_1 && evt.source_component == _list_2){
evt.source_component.removeItemAt(evt.source_index)
evt.target_component.text = evt.source_item.label
evt.Skip()
} else if(evt.target_component == _text_area_1 && evt.source_component == _tree_1){
evt.source_item.removeNode()
evt.source_component.dataProvider = evt.source_component.getDataProvider()
evt.target_component.text = evt.source_item
evt.Skip()
} else {
evt.Veto()
}
}

The .zip with all the file is available here, if anyone want to test and improve it.

[attachments docid=691 force_saveas=”1″ logged_users=”0″]

Which documentator for AS2?

I was searching for a valid AS documentation tool…
I have tested the AS2Doc trial but it doesn’t parse correctly my classes.
Also ZenDoc seems to be a valid alternative, also because it’s written in PHP, but it skip all the uncommented methods 🙁
NaturalDocs probably is the best choice, for me, but it doesn’t support standard javadoc comments
Acid gives me python errors while parsing the packages and the python code is quite unreadable.
BLDoc is really promising, but it’s still in beta
Probably the best program I found is as2api, which creates a standard javadoc html output. The only thing is that it doesn’t seem to have an option to allow documentation for private methods
Did you have experience with some of these tools, or someone else I didn’t tested?
Which one do you currently use?

mtascGUI

mtascGUI Reading today the MTASC mailing list I’ve read that a new Windows GUI for MTASC has been just release.
Quoting the author words: “after setting all the options (e.g. all mtasc paramters) you can switch to a small window, called ‘launch bar’, that will always stay on top of other applications, so that compiling with mtasc is only one click away, no matter where you are in your editor. This launch bar also lets you choose in which FlashPlayer version you would like to open your swf-file (options are 6, 7 and 8, provided that you install the standalone players that come with the flash ide’s)…”
What is MTASC?
MTASC is the first ActionScript 2 Open Source free compiler
http://www.kugelfunk.de/as/english/

Flash 9’s codename ? Blaze !

We just had the most successful launch of Flash in history and we’re already working on the next version. It’s too early to give away much information on the release but I do have a few things to tell you.

With these words Mike Donway announce that Macromedia is already working on Flash 9!
Obviuosly there aren’t news about new features or similar things…but it’s sure that Flash 9 will support Actionscript 3 (that will be introduced by Flex 2 and Flash Player 8.5), and it seems that – also for give to developers the opportunity to “meet” As3 as soon as possibile – in Spring 2006 (when Player 8.5 will be released) Macromedia will release a public alpha for Flash Professional 8 or Studio 8 registered users!
You can find more news here

Actionscript 3 ?

Recently Macromedia release some news about Flex 2…and what we can find in one page (you can see it here) ?
“With ActionScript 3.0, we have achieved more than simple compliance with the ECMAScript standard; Macromedia now chairs the ECMAScript committee and helps drive its evolution. ActionScript 3.0 features a compilation mode for stronger compile-time type checking that provides the benefits of languages such as Java or C#. It supports new features to streamline data manipulation, including the E4X (ECMAScript for XML) standard, which extends the language and adds XML as a native data type allowing developers to more naturally interact with and manipulate XML. It adds regular expressions support for better text parsing and processing. It sheds some of the ad hoc event handling schemes in the old virtual machine in favor of a unified model based on the W3C DOM Events standard. And it has significantly updated APIs aimed at the application developer audience.
For a complete overview of the new capabilities, stay tuned as we release an overview of ActionScript 3.0 and the Flash Player 8.5 alpha.”

It seems that on 17th October we’ll have a public preview of Flash Player 8.5…I’m curious a lot!
http://www.macromedia.com/devnet/…/flex2_intro.html