Sunday, November 15, 2009

Twitter's new Retweet feature (BETA)


Twitter has added a new feature. I'm not sure if this is just the ability to identify a retweet with an icon or if it goes further than that by giving us back a portion of our precious character count when retweeting. I guess we'll see. If it's the former I'm not sure it's an added benefit to me. The latter absolutely is.

Thursday, November 12, 2009

SWFAddress 2.4 and SWFObject 2.2 Static with Flex 3

SWFAddress 2.4 is fairly new and most people who want to implement SWFObject under it seem to like the dynamic version so I had a little bit of trouble finding good info on these specific versions. The general info did seem to work out all right but it would have been nice to have seen a more specific example, so here it is:

There are plenty of examples implementing either one of SWFObject or SWFAddress alone but together there are a few issues to be aware of.


<script type="text/javascript" src="assets/js/swfobject.js"></script>
<script type="text/javascript" src="assets/js/swfaddress.js"></script>
<script type="text/javascript">
function outputStatus(e)
{
alert("e.success = " + e.success +"\ne.id = "+ e.id +"\ne.ref = "+ e.ref);
}
swfobject.registerObject("${application}", "9.0.0", "assets/swf/expressInstall.swf", outputStatus);
</script>

<div>
<object id="${application}" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="${width}" height="${height}">
<param name="movie" value="${swf}.swf" />
<param name="bgcolor" value="${bgcolor}" />
<param name="flashVars" value="test=true&test2=false" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="${swf}.swf" width="${width}" height="${height}">
<!--<![endif]-->
<div>
<h1>Alternative content</h1>
<p><a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>
</div>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>


The main thing to keep in mind here is the order in which the JavaScript is invoked.
  1. The script reference to SWFObject first
  2. then SWFaddress
  3. finally the method call to registerObject
If you use the code above and implement the Flex code correctly (you can use the sample SWF that comes with the SWFAddress download to test) You will have successfully merged SWFAddress and SWFObject with a static implementation for your Flex application!

Thursday, April 02, 2009

Loading a Flex SWF from a Flash SWF

Using either pure ActionScript or the Flash IDE, there is a trick to loading a SWF generated from a Flex Application from within a Flash/AS SWF. When loading a Flash SWF any developer can use the following code:


var loader:Loader = new Loader();
var request:URLRequest = new URLRequest("http://www.anyurl.com/test.swf");

loader.load(request);
addChild(loader);

If the test.swf has public functions (i.e. public function hello(name:String):String) you could call them like so:

loader.content.hello("Phillip");

Or you could cast the content and use it as an object like so:

var testObject:TestObject = TestObject(loader.content);

This works as long as the SWF was generated from the Flash SDK. The Flex SDK wraps the application in a SystemManager. Since the SystemManager handles (pre)loading the application we cannot guarantee that at load time of the SWF that the application has been instantiated. The good news is that the SystemManager's application property does not get assigned until the application is instantiated so we can setup a timer and test the application property until the application is ready.

WARNING: Blog code has been copied, pasted, and modified. It may not work as is but the approach still stands.

private var loader:Loader = new Loader();
private var timer:Timer = new Timer(10);

public function init():void
{

loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderCompleteHandler);
timer.addEventListener(TimerEvent.TIMER, checkTimerHandler);

loader.load(request)
}

private function onLoaderCompleteHandler(event:Event):void
{
trace("Application - onLoaderCompleteHandler");
timer.start();
}

private function checkTimerHandler(event:TimerEvent):void
{
trace("Application - checkTimerHandler");
var flexSWF:* = loader.content;
if(flexSWF != null && flexSWF.application != null)
{
timer.stop();
flexApplication = flexSWF.application;
}
}

There are a few other things I'd like to try but this works.

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.