Calculate DataGrid height
I have a dataset with more than 200 items. If I use that as dataprovider of a datagrid and set the rowcount to 10 the datagrid is not alway resizing to the right size. Sometimes I see 10.5 rows. This is a nice solution for that problem:
dataGrid.height = measureHeightOfItems(-1, dataGrid.rowCount) + dataGrid.headerHeight; |
AdvancedDataGrid GroupingCollection and sort
Here an example of the advancedDataGrid. I’m using a groupingcollection to get all the data from one searchengine in one group
One problem that I encounter in the advancedDataGrid is sorting a column on application start. I try to sort the “number of visits” field and it is working for the known visit data the sort is working but for the calculated total visits of the groups it isn’t working. If someone knows the solution please let me know
LineChart datatip with degrafa skin
Here is an example how you skin a DataTip from a LineChart with the help of Degrafa.
TimeDateAxis
I’m going to try to shift the focus of my blog a little bit more to examples and away from the “I have this problem bla bla”. Well I just try to blog more because it a bit quiet here. I’m going to post some things that is useful for myself to archive and maybe I can help someone else with it.
DateTimeAxis
What is the deal with application.parameters?
I send a userId to my application to display a linechart with the application.parameter object. I get the userId parameter inside my application and can trace or alert it and I see the userId on my screen. Ok everything is working fine for now. Then I want to use the userId to call php function. And there is where it breaks. Somehow the userId parameter is empty.
example:
private var userId:int = 1234; private function init():void{ this.userId = Application.application.parameters.userId; } |
for this example I set a default value of 1234 and on creationComplete the userId is set with the real userId value, lets say that the userId in parameters is 1. If I trace the userId inside the application after the init() it returns 1. That is normal. But if I now call the remoteObject:
<mx:RemoteObject endpoint="test/test.php" id="phpCall" source="myFunction" destination="amfphp" showBusyCursor="true"> <mx:method name="getUser" fault="onFaultResult(event)" result="onResult(event)"> <mx:arguments><userId>{this.userId}</userId> </mx:method> </mx:RemoteObject> |
With this call the php function receives a userId with 1234. Very strange because we already set that with an other number.
solution for me
I tried a lot of different ways to fix this problem and now I finally found a solution. I set the value of the userId parameter inside a invisible label. And use that label to send the userId back to php.
this.userIdLabel.text =(this.userId).toString(); |
and in the remoteObject:
<mx:RemoteObject endpoint="test/test.php" id="phpCall" source="myFunction" destination="amfphp" showBusyCursor="true"> <mx:method name="getUser" fault="onFaultResult(event)" result="onResult(event)"> <mx:arguments><userId>{int(this.userIdLabel.text)}</userId> </mx:method> </mx:RemoteObject> |
DataGrid doesn’t update rowCount correctly
I have an Bindable ArrayCollection with values and DataGrid that should show all the values (or rows) without the ugly scrollbars (I hate scrollbars). This is working correct by setting the rowCount property in DataGrid like this: rowCount = "this.ArrayCollection.length"
the tricky part is when you add items to that ArrayCollection on application run. Somehow the rowCount is only updated once in the 2 times. I Made a example that is making it clear where it goes wrong (and rightclick –> source view gives you the opportunity to see the source):
Get the dataprovider of another Line in lineChart?
In some cases you have 2 different XML files to show 2 different lines in a lineChart. For example you want to compare a companies incomming with another month and each month is in a different XML. In a dataTipRenderer I show the styled data but I can only access data from 1 line. My goal is to create something like this in my dataTip:
April 2009
$29,000
May 2009
$30,000
+3%
Is there a way to get a dataProvider from the other line that is in the lineChart? Or is there a way to work around this?
Strange behaviour of Tree component
I’m making a tree like menu structure. It is already a hacky business but now I encountered another problem. And I have no clue where it is happening and if I do something wrong or Flex is messing it up.
I have a Tree component that uses a tree renderer to render the items. In this tree renderer I determine if it has children and style it by setting the left position and adding an icon.
How to save files from Flex to your server with PHP
For my AMDawing I searched a lot for . And all the solutions that I found are too complex in my opinion. I saw all the examples with remote objects and AMFphp or ZendAMF.
Finally I found the solution at thinkerlog.com. I think it is the most straight forward solution. This are the basics:
First you make the URLrequest that requests the php file url. And then you use URLvariables to send all the variables to the php file. This is the code:
var request:URLRequest = new URLRequest("upload.php"); var vars:URLVariables = new URLVariables(); vars.name = this.creatorName.text; vars.bindata = Base64.encodeByteArray(imageData); request.method = "POST"; var loader:URLLoader = new URLLoader(); loader.addEventListener(Event.COMPLETE, uploadPhotoHandler); request.data = vars; loader.load(request); |
That is everything at the Flex side. Now the PHP file “upload.php”:
if ($_REQUEST["bindata"] === NULL) { echo "missing parameter."; }else { $img_data = base64_decode($_REQUEST["bindata"]); $name = $_REQUEST["name"] === NULL ? "anonymousn" : $_REQUEST["name"]; $name = strip_tags($name); $img_size = strlen($img_data); if ($img_size < 1000000) { $date = date("U"); $img_filename = "data/$name.$date.png"; unlink($img_filename); $img_file = fopen($img_filename, "w") or die("can't open file"); fwrite($img_file, $img_data); fclose($img_file); echo "$date"; echo "$img_size bytes uploaded."; }else { echo "image too big."; } } |
If you want an extended tutorial you have to go to thinkerlog.com
Augmented Reality
A few weeks ago I was busy finding a graduate project. And during that time augmented reality looked very interesting. Most of you know what it means, for the others here a small explaining line from wikipedia: Augmented reality (AR) is a field of computer research which deals with the combination of real-world and computer-generated data (virtual reality), where computer graphics objects are blended into real footage in real time.

"it's amazing, it's the new Lego"
I’m not going deeper into this subject I only made this post to show some of the cool examples:
Feed
Calendar
March 2010 M T W T F S S « Oct 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
Categories
- actionscript 3 (25)
- Adobe AIR (5)
- API (4)
- Away3D (8)
- component (5)
- database (5)
- Degrafa (1)
- example (1)
- Flash (11)
- Flex (31)
- game (2)
- General (37)
- Google Maps (3)
- ImageViewer3D (2)
- installation (1)
- Javascript (2)
- Programming (16)
- Ruby on Rails (9)
- Search (2)
- tutorial (6)
- Usability (4)
- web 2.0 (28)
- WebORB (5)
Monthly Archives
- October 2009 (1)
- September 2009 (1)
- August 2009 (3)
- July 2009 (1)
- May 2009 (2)
- April 2009 (3)
- March 2009 (1)
- June 2008 (1)
- May 2008 (2)
- April 2008 (4)
- March 2008 (5)
- February 2008 (2)












