Category Archives: Macromedia Flex

We need flexibile crossdomain.xml on Google properties

Ali Mills posted about his experience of Google Developer Day. Where, Ali got to know about Google’s plan to host a flexible crossdomain.xml on their servers, which would allow third-party flex-flash-web-applications to access Google APIs.
As we know, Youtube also changed it’s crossdomain.xml, which broke many third-party flex-flash-applications consuming YouTube’s API. I understand, it was more of security reasons; Lesson to be learnt: Never host a crossdomain.xml (which allows all domains) on your main application server.
Similarly, Gdata, Picasa, Google-Calendar etc don’t allow all domains, only Google related properties.
I hope, Google guys hear us (Flash/Flex developers) and host a crossdomain.xml (as promised in Google Developer Day) asap.
Yahoo! has a good team of flash/flex developers, that could be the reason, Yahoo! has always been trying their best to satisfy the needs of developers. The most recent update, sure you all have heard of, Flickr now hosts a flexible crossdomain.xml, you can read more on these places:-

Technorati tags: , , , , , , ,

Adobe Flash Player’s Security-Sandbox is very restrictive

Adobe Flash Player Security-Sandbox is very good and we have not heard any major security vulnerabilities so far. However, I think, it can be made more intelligent, I have some use-cases where I can’t do anything.

XMLSocket API is cool, since it’s inception, developers could create cool applications (multi-player games, chat-apps, presence-apps etc). XMLSocket servers (unity, swocket etc) is needed to comply with a specification in order to work with Flash Player (as a client). Since developers are using/creating custom-servers, they could control various things on server-side, f.ex: configuring right security-permissions, serving right policy-file (crossdomain.xml) etc.

With Binary Socket API, in Adobe Flash runtimes, things have changed a lot. Applications (for Adobe Flash runtimes) can now connect to servers using standard protocols (POP3, SMTP, Databases, HTTP etc). Totally cool feature which allows creation of kick-ass applications (Yahoo! Web Messenger, mySql driver etc). But Adobe Flash Player’s security-sandbox is limiting Binary Socket’s capabilities.

I have been working on a library (as3httpclient) to do more things (http-status-messages, http-authentication over GET request, support for more http-methods etc) which are not supported by URLLoader API. This library (as3httpclient) doesn’t work in deployed web-application because Adobe Flash Player’s Security-Sandbox restricts it to.

I have following questions/concerns:-

  • When URLLoader (or other such native APIs) can connect on any port, why can’t custom APIs (as3httpclient and others) connect?
  • Why can’t Flash Player be little more intelligent to check, if connection is made to a HTTP server? Rules could be:- If connection is requested to same domain and destination-port is assigned to HTTP server, let communication happen. If destination server:port is in different domain, check for valid crossdomain.xml and allow the connection?
  • Why doesn’t Flash Player consider to-ports attributes, if policy-file is served over HTTP?

With standards, we expect flexibility. We can’t expect a HTTP server to push policy-file to Flash clients? That’s not standard.

Technorati tags: , , , ,

DataGridDataExporter: Export DataGrid data as CSV

A friend of mine, who is new to Adobe Flex, asked how can Datagrid-data be exported as CSV. I wrote a simple class, with one static-method, to do that. This is very basic implementation of CSV format.

Check out the example or download the code (with example).

DataGridDataExporter is a util-class to export DataGrid's data into different format.
@class DataGridDataExporter (public)
@author Abdul Qabiz (mail at abdulqabiz dot com)
@version 0.01 (2/8/2007)
@availability 9.0+
@usage<code>DataGridDataExporter.<staticMethod> (dataGridReference)</code>
var csvData:String = DataGridDataExporter.exportCSV (dg);
package com.abdulqabiz.utils
import mx.controls.DataGrid;
import mx.controls.dataGridClasses.DataGridColumn;
import mx.collections.ArrayCollection;
import mx.collections.XMLListCollection;
import mx.collections.IList;
import mx.collections.IViewCursor;
import mx.collections.CursorBookmark;
public class DataGridDataExporter
public static function exportCSV(dg:DataGrid, csvSeparator:String="\t", lineSeparator:String="\n"):String
var data:String = "";
var columns:Array = dg.columns;
var columnCount:int = columns.length;
var column:DataGridColumn;
var header:String = "";
var headerGenerated:Boolean = false;
var dataProvider:Object = dg.dataProvider;
var rowCount:int = dataProvider.length;
var dp:Object = null;
var cursor:IViewCursor = dataProvider.createCursor ();
var j:int = 0;
//loop through rows
			while (!cursor.afterLast)
var obj:Object = null;
obj = cursor.current;
//loop through all columns for the row
				for(var k:int = 0; k < columnCount; k++)
column = columns[k];
//Exclude column data which is invisible (hidden)
data += "\""+ column.itemToLabel(obj)+ "\"";
if(k < (columnCount -1))
data += csvSeparator;
//generate header of CSV, only if it's not genereted yet
					if (!headerGenerated)
header += "\"" + column.headerText + "\"";
if (k < columnCount - 1)
header += csvSeparator;
headerGenerated = true;
if (j < (rowCount - 1))
data += lineSeparator;
cursor.moveNext ();
//set references to null:
			dataProvider = null;
columns = null;
column = null;
return (header + "\r\n" + data);


<?xml version="1.0"?>
<!-- DataGrid control example. -->
<mx:Application xmlns:mx="">
import com.abdulqabiz.utils.DataGridDataExporter;
private function exportCSV ():void
console.text = DataGridDataExporter.exportCSV (dg);
<mx:XMLList id="employees">
<name>Christina Coenraets</name>
<email>[email protected]</email>
<name>Joanne Wall</name>
<email>[email protected]</email>
<name>Maurice Smith</name>
<email>[email protected]</email>
<name>Mary Jones</name>
<email>[email protected]</email>
<mx:Panel title="DataGrid Control Example" height="100%" width="100%"
paddingTop="10" paddingLeft="10" paddingRight="10">
<mx:Label width="100%" color="blue"
text="Select a row in the DataGrid control."/>
<mx:DataGrid id="dg" width="100%" height="100%" rowCount="5" dataProvider="{employees}">
<mx:DataGridColumn dataField="name" headerText="Name"/>
<mx:DataGridColumn dataField="phone" headerText="Phone"/>
<mx:DataGridColumn dataField="email" headerText="Email"/>
<mx:Button label="Export CSV" click="exportCSV ()"/>
<mx:TextArea id="console" width="100%" height="100%" />

Technorati tags: , , , ,

as3httpclient project update

Sometimes back, I posted about as3httpclient project which is an open-source http-protocol-library written in ActionScript 3, not yet completely done. Library has been updated recently by Erik, who has recently joined the project. It’s great to have him in the team.

Things that have changed:-

  • package name has been changed to* from*;
  • HTTPURLLoader class has been renamed to SocketURLLoader
  • Some more classes added.
  • ASDocs has been added.

Now as3httpclient can be used for:-

  • HTTP Basic Authentication without browser’s dialogue box
  • Adding custom or standard HTTP headers
  • Uploading files to server that requires http-authentication [new]
  • Copying bytes (of images/files downloaded using this library).

Two important features planned for future release:-

  • Support for more HTTP verbs (PUT, DELETE, OPTIONS, HEAD etc) – would be there soon.
  • Support for SSL or Secure HTTP – This feature might take sometime because it needs some investigation.

Please check out the project. I would love to hear your feedback/bug-reports/suggestions.

Please get back in touch with me [mail at abdulqabiz dot com], if you want to contribute to the project.

Technorati tags: , ,

AIR(Adobe Integrated Runtime) and Flex 3

Apollo, which was the code name for Adobe desktop runtime, would be known as Adobe Integrated Runtime (AIR). Adobe Flex 3 framework would be cached by Adobe Flash Player for better performance (download wise). Latest beta build of Adobe Flash Player 9 has loads of enhancements.

In short, all these bits are available on labs. Download ’em and give your feedback to Adobe.

Opensource Flex

This is old news by now but I couldn’t stop myself writing about it. I am so happy and excited after this announcement. I told to couple of friends, who are total FOSS guys, in my office and I could see a positive smile on their faces.
I can imagine a brighter future of Flex and Flash Platform. I can imagine the kind of tools we would see once Flex/AS compiler code is out.
After MAX 2005, I (and some other folks) had some feeling (intuition) that Adobe might release the flex-framework under open-source license but I had not thought about tools/compilers.
Well done Adobe, keep it up.

ActionScript 3 HTTPClient Google Project

I have created a Google Project called as3httpclient. The project would host different actionscript-3 classes to extend Adobe Flash Player’s capabilities for HTTP/HTTPS related stuff.

I have committed the HTTPURLLoader class . If you are doing something similar or have done any changes to HTTPURLLoader, it would be great if you can merge changes or add new classes related to HTTP/HTTPS.

All the classes in as3httpclient would be licensed under New BSD License.

Adobe Flex/ActionScript posters are huge

I received Adobe Flex 2 framework and Flash Player 9 API posters. Those are huge but it’s easier to read.

Thanks to Adobe for sending it. You can also get one set, link the from your blog and keep an eye on this page and apply (whenever you can).

Meanwhile, you can download the Flex, ActionScript and Apollo cheatsheats.

Adobe Media Player – Why Media RSS is cool?

I posted about Media RSS sometimes back and now it seems like Adobe Media Player (AMP) would consume RSS 2.0 feeds (with Media RSS extension/module) and do cool things.

I also posted about how something like Democracy Player can be built for Adobe Apollo platform, seems like Adobe Media Player is the answer.

AMP would be cool, I can feel it. It’s another platforms for content-distribution. I don’t have to think much about integration, just follow the standards (RSS, ATOM, microformats etc) and I am cool. That’s the beauty of standards, that’s why I love them.

Constructing YouTube FLV URL on client-side without any server-side script

It seems, there is a easier way of constructing YouTube! FLV URL on client-side without using any server-side script.

We need get the YouTube video_id from any of following places:-

Then, construct a URL like this:

Above URL is used in YouTube embed-code. It is basically a server-side redirection that points to YouTube Player (.swf). Above redirects (server-side) to following URL:-

As you can see in above URL, it contains “t” param (in red), which is what we need along with video_id to construct YouTube video (FLV) URL, YouTube FLV URL would look like this:-

You can check out code below to figure out things your own. You can also check out the example-app.

Flex 2.0/ActionScript 3.0 example:-

<mx:Application xmlns:mx=""
creationComplete="onAppCreationComplete ()"
import flash.display.*;
private var loader:Loader;
private var abortId:uint;
private function onAppCreationComplete ():void
loader = new Loader ();
private function startLoading ():void
var req:URLRequest = new URLRequest ("");
loader.contentLoaderInfo.addEventListener(Event.INIT, handlerLoaderInit);
logMessage ("Loading YouTube URL..");
private function handlerLoaderInit (event:Event):void
logMessage ("Loaded, processing: " + loader.contentLoaderInfo.url);
var urlVars:URLVariables = new URLVariables ();
urlVars.decode (loader.contentLoaderInfo.url.split("?")[1]);
logMessage ("Processed:-");
logMessage ("\t\t video_id:" + urlVars.video_id);
logMessage ("\t\t t param:" + urlVars.t);
logMessage ("\t\t thumbnail-url:" + urlVars.iurl);
var flvURL:String = constructFLVURL (urlVars.video_id, urlVars.t);
logMessage ("YouTube FLV URL: " + flvURL);
playVideo (flvURL);
logMessage ("Started Playing Video...");
private function constructFLVURL (video_id:String, t:String):String
var str:String = "";
str += "video_id=" + video_id;
str += "&t=" + t;
return str;
private function playVideo (url:String):void
player.source = url;;
private function logMessage (message:String):void
outputText.text += message + "\n";
trace (message);
<mx:HBox width="100%">
<mx:Label text="YouTube Video URL:"/>
<mx:TextInput id="urlText" width="300"/>
<mx:Button label="Submit" click="startLoading ()" id="submitButton"/>
<mx:HBox width="100%">
<mx:VBox height="100%">
<mx:Label text="VideoDisplay:"/>
<mx:VideoDisplay width="320" height="240" id="player"/>
<mx:VBox height="100%" width="100%">
<mx:Label text="Output:-"/>
<mx:TextArea id="outputText" width="100%" height="100%"/>

ActionScript 2.0 code-snippet:-

createEmptyMovieClip ("mc", getNextHighestDepth ());
var _mcl:MovieClipLoader = new MovieClipLoader ();
_mclListener = new Object ();
_mclListener.onLoadStart = function (target:MovieClip)
trace ("The URL is: " + target._url);
var _lv:LoadVars = new LoadVars ();
_lv.decode (target._url.split ("?")[1]);
trace ("t param: " + _lv.t);
trace ("video_id: " + _lv.video_id);
trace ("thumbnail: " + _lv.iurl);
trace ("flv url: " + constructFLVURL (_lv.video_id, _lv.t));
_mcl.unloadClip (target);
function constructFLVURL (videoId:String, t:String):String
var str:String = "";
str += "video_id=" + videoId;
str += "&t=" + t;
return str;
_mcl.addListener (_mclListener);
_mcl.loadClip ("", mc);

 [1] Flash clients would require server-side proxy because YouTube changed crossdomain.xml sometimes back.

Apollo: Use-case analysis

I have been thinking about different use-case for Adobe Apollo platform.
I analysed Democracy Player, which I use a lot for watching and saving videos from web(internet). I can imagine, how much effort would have gone in making it cross-platform (MacOSX/Windows/Linux)?
With Apollo platform, making such things are lot easier, I can develop once and run it on different platforms (Windows, MacOSX, Linux-in-future) in consistent manner. Ok, I am not just repeating which was said for Java-client-applications, it’s totally doable, possible and feasible to do that. There are some cool examples FineTune Desktop, YourMinis Desktop etc. Adobe Flash Player has gained the status of true cross-platform, Apollo would also do. I am confident about that.
Though, there are a few things that I would need in Apollo to implement all features of Democracy Player. Things I can’t implement as of today (for Apollo Alpha runtime) are:-

  • Play-back different media formats (mov, mpeg, wmv, divx, xvid, mp4 etc)
  • Open ports or listen on ports or P2P capabilities. For example, to take complete advantage of Bittorrent protocol, client needs to open ports. Why?.

I am very hopeful, later releases of Apollo would solve these problems.

Mac OSX tools for performance/memory profiling

You can use following commands to check the memory/performance/memory-leaks of your applications during development.

  • /usr/bin/top or top
  • /usr/bin/vmmap or vmmap
  • /usr/bin/leaks or leaks

If you have XCode and Apple developer tools installed (you get in CD), you can find more tools in /Developer/Applications/Performance Tools
It takes sometime to understand tools, but it’s really useful while development. One of the reasons, I started using Mac OSX because it’s on top of *nix and there are good free tools that comes with it (in CD/DVD).
You can get lots of Open-Source/FSF tools ported for Mac OSX (and Darwin) using Fink or Darwin Port package management tools.