Grant Skinner has rehashed some of the content from his site into 2 articles on Adobe’s devnet. I think most of the content is the same, just better organized and presented:
http://www.adobe.com/devnet/flashplayer/articles/resource_management.html
http://www.adobe.com/devnet/flashplayer/articles/garbage_collection.html
No Comments »
E4X is a very powerful and easy way to manipulate xml data in Flex.
Of course something so p[powerful can sometimes be confusing when it produces unexpected results.
<mx:XML format="e4x" id="myXML">
<order>
<item id=‘1′>
<menuName>burger</menuName>
<price>3.95</price>
</item>
<item id=‘2′>
<menuName>fries</menuName>
<price>1.45</price>
</item>
</order>
</mx:XML>
If you wanted to retrieve the price of the burger menuitem above, it is easily done with the e4x expression:
<mx:XML format="e4x" id="myXML">
<order>
<item id=’1′>
<menuName>burger</menuName>
<menuName>burger</menuName>
<price>3.95</price>
</item>
<item id=’2′>
<menuName>fries</menuName>
<price>1.45</price>
</item>
</order>
</mx:XML>
Then if you used the same expression, you actually would not get a value returned.
It is not obvious as to why this happens, but of course there is more than one way to skin a cat…
Here is an expression that will work:
myXML.item.menuName.(text()=="burger").parent().price;
Here is a link to a Flex Builder 2.0.1 project (compiled with SDK hotfix1) containing a sample demonstrating the solution described above.
No Comments »
If in the dataGrid control you set showHeader = false and if the dataProvider has no items in it, then the vertical column lines don’t show up.
The vertical column separator lines only appear when the dataProvider has items populating the grid (or if there is no data and showHeader=true).
In the Datagrid code, drawing the vertical column separator lines is keyed off of the listData, which would have a “row 0” containing the header row if the headers where to be visible.
The solution to this is to extend the datagrid and override the drawLinesAndColumnBackgrounds method in which you can iterate over the column array rather than the listItems to draw the vertical lines.
Read the rest of this post»
No Comments »
Here is an example demonstrating how to use project references to refer to source files in other projects as well as swcs in other projects.
If you take a look at this zip file, you will find that it contains 3 projects.
The first project is a normal Flex project called globalIncludes which contains an actionscript file, vars.as.
A second project, Expando, is a library project, which contains an mxml component.
- In the properties/Project References dialogue for this project there is a checked refererence to the globalIncludes project.
- In the properties/sourcepath for this project, I have added the root folder from the globalIncludes project. (Just click the add Folder… button and navigate to the folder.) This folder is added as ${DOCUMENTS}\globalIncludes.
Now in your Expando project you can see a “virtual directory” from the globalIncludes project labeled - [source path] globalIncludes.
In my mxml component in the Expando project, I refer to the actionscript file from the globalIncludes project by doing an include:
include "../globalincludes/vars.as";
Then in my component I use a variable defined in that vars,as actionscript file to expose a version number tooltip in my component.
Note:
In the Expando project, I have right clicked on the ExpandoComboBox.mxml and selected – “Include class in library”. That way, whenever I make changes to this component, the swc will be recompiled.
My third project, Sample, is a normal project that just has an application in it.
- In the properties/Project References dialogue for this project there is a checked refererence to the Expando project.
- In the properties/Flex Build Path/Library Path dialogue for this project, I have added the Expando Project (click Add Project… and you will be able to select the Expando project since it is in the list of Project references.)
Now you can launch the Sample.mxml application and see that the tooltip for the ExpandoComboBox is 1.0 which has come from the vars.as actionscript file in the globalIncludes project.
2 Comments »
Someone was asking how to set the focus indicator into the TextInput rather than just setting focus to a TextInput.
Here is a simple code snippet that demonstrates how to do this using the TextIput’s setSelection() method:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:TextInput id="ti"/>
<mx:Button label="Set Focus into TextInput" click="ti.setFocus();ti.setSelection(0,0)"/>
</mx:Application>
No Comments »
Recent Comments