Tuesday, March 31, 2009

Making an Array out of XML with E4X

Today one of my colleagues asked me how to make an array out of attributes from nodes in an XML object in ActionScript 3. After some discussion and searching on E4x he found the solution in many places across the web. The key is the following line of code:

xml.nodelist.@attribute.toXMLString().split("\n")

The split string function does exactly as you might think; takes a string and splits it on every occurrence of the provided parameter and returns those bits in an array. As if split wasn't self explanatory enough there's toXMLString(). Prior to that we have xml.nodelist.@attribute which returns a XML set of nodes of the attributes.

XML:

<xml>
   <trunk>
      <leaf attr="1">
      <leaf attr="2">
      <leaf attr="3">
   </trunk>
</xml>

ActionScript:

var temp:Array = xml.trunk.leaf.@attr.toXMLString().split("\n");

temp = {1, 2, 3};

Seems like a bit of a hack but pretty cool.

Wednesday, March 18, 2009

IBM in talks to purchase Sun

IBM is in talks to buy Sun Microsystems as early as the end of this week. Current information puts IBM's bid over Sun's market cap at $6.5B.

http://online.wsj.com/article/SB123735970806267921.html

I'm interested to know how this could impact the RIA world as we know it. IBM currently has it's hand in the Dojo toolkit as well as a recent acquisition of ILOG and their Adobe Flex data visualizations, Elixir.

Research done by Gartner (MarketScope for AJAX Technology and RIA Platforms) and popular opinion shows, Adobe Flash/Flex as the front runner with Microsoft Silverlight and others in a positive position and Sun's JavaFX positioned showing promise.

Side note: RIAs are more important than they have been in the past; illustrated when Forrester published information on RIAs going mainstream as a first-Class application development option (Inquiry Spotlight: Rich Internet Applications, Q3 2008). There's more of a focus on AJAX libraries and platforms as well as Browser plug-ins as suitable technologies for web applications. If the technology is more suitable the question then becomes how costly is it to develop? Take into consideration the efficiency gained from tooling, the efficiency developing the technology, and availability of developers for each platform and go from there.

Thursday, March 12, 2009

The end of Flash!?!

Everyone who is a die-hard Flash/Flex fan needs to check this out...

http://stairwellblog.com/2009/03/is-canvas-the-end-of-flash/

Sunday, March 01, 2009

FlexBuilder ActionScript Project's Stage Dimension Width and Height

I spent a good day or so trying to figure out why my stage dimensions were so out of whack when I compiled my Flash AS3 project out of FlexBuilder 3. I tried specifying the width and height in the HTML, I tried setting the stage dimensions via this.width and this.height, I tried combinations of various width and height settings all to no avail.

I searched with a plethora of keywords "actionscript" "project" "scale" "dimensions" "programmatically" "setting" "stage" "width" "height" "huge" "large" "SWF" "SDK" "flexbuilder" "3" "3.3" "3.2" but the combination that finally got me what I was looking for was "flash actionscript setting swf width height"

The solution that fixed my problem is in bold below:

package
{
[SWF(width=1024,height=768)]
public class Master extends Sprite
{
public function Master(){}
}
}

It's really very simple, although something I had never come across before. I made the jump from Flash directly to Flex without ever working with pure ActionScript projects until now.