Oct15th

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:

?View Code ACTIONSCRIPT
dataGrid.height = measureHeightOfItems(-1, dataGrid.rowCount) + dataGrid.headerHeight;
Sep4th

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

This movie requires Flash Player 9

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

Aug20th

LineChart datatip with degrafa skin

Here is an example how you skin a DataTip from a LineChart with the help of Degrafa.

This movie requires Flash Player 9

Source

Aug17th

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

TimeDateAxisfor the source you can click right mouse button

Aug11th

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:

?View Code ACTIONSCRIPT
                       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.

?View Code ACTIONSCRIPT3
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>
Jul9th

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):

Read the rest of this entry »

May26th

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?

May12th

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.

Read the rest of this entry »

Apr24th

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:

?View Code ACTIONSCRIPT
                        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 &lt; 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

Apr23rd

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 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:

Read the rest of this entry »

Feed



Calendar

  • February 2010
    M T W T F S S
    « Oct    
    1234567
    891011121314
    15161718192021
    22232425262728

Categories

Monthly Archives



  • links




  • Pages

    Recent Comments

    Flickr Photos

    Castle ReinhardsteinEagleEagleEagleEagleEagleDSEagleEagleEagleEagleEagleWhite wolf