Archive for April, 2009

Using with htmlText to display XML

April 30, 2009

This is a little something thing that I found this morning in Flex. Not sure it would be of much use but I think it’s kinda cool:

<mx:Text htmlText="{}"/>

Then you can see all the text nodes (the mx:Text component traverses through all the nested nodes) in the targeted XML object.

elibXML is an XML object:

<mx:XML id="elibXML" source="data/eLibrary.xml" format="e4x"/>

and the eLibraray.xml looks something like this:

<music type="album" thumb="img/e336076c29f9162186b8ce463aa93a8c.jpg">
<title>Que Du Bonheur</title>
<name>Que Du Bonheur</name>

“Unexpected end of token stream when parsing XML”

April 29, 2009

When I tried to load an external xml file using an XML tag, I got something like this from Flex Builder:

“Problem parsing external XML. Unexpected end of token stream. The last token was: 360.”

The file was built in Nodepad++ and was displayed fine in Firefox as well as in Eclipse/FB. When I got the error message, I then tried to load it in IE, which also gave me an error. What I did to fix it was going back to Nodepad++ and  “Format>Encode in UTF-8“, which basically changed the encode from ANSI (the default one for Notepad++) to Unicode. I got several “special” unicode characters such as 360° in my orignial XML file.

Code snippet: clamp value into a range

April 24, 2009

var myVal:Number = Math.max(USER_MIN,  Math.min(USER_MAX, calculateMyDesiredValue());

Inspired by Ely Greenfield. (Note: “Inspired” is an elegent way of saying “copy”.)

force rebuild of flex projects

April 22, 2009

I am experiencing some bugs(?) in Flex Builder 3. The symptom is Flex launches the _existing_ application .swf in the “debug-bin” folder when I hit either “debug” or “run”  instead of compiling a new one even if I made changes in the source files. Same thing after the project is “Clean”. I am using TortoiseSVN to do the version control (not Subclipse since it’s not working a. under our office firewall; b. giving me “old client” errors when I updated my TortoiseSVN to 1.4 (now I am using TortoiseSVN 1.6.1).

So this might be an issue of TortoiseSVN, or Flex Builder alone; or maybe it’s because the Tortoise doesn’t get along well with Flex.

Anyhow, my current fix is to change the mxmlc setting for “HTML wrapper” to the new setting and then change it back before the new build. The setting is project> “Properties” > “Flex Compiler” > “HTML wrapper” > “Generate HTML wrapper file”.

Keyboard Keys and Key Code Values in ActionScript 3

April 21, 2009


datagrid local pagination in flex

April 18, 2009


We use a local data provider (a collection) which is a reference to the real/remote data filtered by filterFunction (clamped by the index range of the requested page).

Background image using CSS in Flex 3

April 10, 2009

background-image: Embed(source="img/contactbkg.png",
scaleGridTop="10", scaleGridBottom="101",
scaleGridLeft="11", scaleGridRight="154");
background-size: "100%";
padding-left: 18;
padding-top: 16;
color: #FFFFFF;

Default values in AS3

April 7, 2009

ActionScript 3
Data type                    default value

int                                         0

uint                                       0

Number                               NaN

Boolean                                false

String                                   null

Object                                   null

All other types/classes     null

untyped or *                        undefined

dictionary[keyObj]                   undefined

The default value for a key in a Dictionary object is undefined, before the key value was assigned or after the key in the dictionary is deleted and even _before_ the key object in the dictionary was created. Flash Player won’t throw out a runtime error, instead, it returns undefined, since Dictionary defines a dynamic collection of properties.


Adobe says “TBD” for “Constant and variable declarations” in their Flex SDK Coding Conventions and Best Practices. I normally assign a default value when declaring a variable/constant of a primitive data type.

Here and Here.

scoping in flex/AIR components

April 1, 2009