Archive | actionscript 3 RSS feed for this section

Strange behaviour of Tree component

12 May

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.

(more…)

How to save files from Flex to your server with PHP

24 Apr

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

23 Apr

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:

(more…)

Draw on 3D object

22 Apr

Here in Holland you have free news papers that you can read when you consume any kind of  public transportation.  In my childhood when I was bored I took a newspaper and draw all sorts of objects on  photo’s of famous people,  like: glasses, moustaches, beards and acme. I think this is also cool in flash

My original idea was to do it different than the newspaper and use 3D for it. Put a famous head as texture on a 3D model and draw on it. I’m not that far yet because it is hard to find an 3D model of a head. I now have an 3D plane with a texture on it. It is already possible to do the same things as in the newspaper and something more… You can save it to a server! So I encourage you to upload your creation to a server.

For now I have a photo from Berlusconi (Italian prime minister). Why? Because I love his quote on the recent earthquake victims that lost there home

“They have everything they need, they have medical care, hot food . . . Of course, their current lodgings are a bit temporary, but they should see it like a weekend of camping.”

berlusconi

Please upload those drawings and I will show them on my blog!!!!

start drawing

I hope I don’t get problems with the mafia

Known problems: Slow and you see some grey dots if you move the mouse (don’t know the solution)

Why has AIR file.browseForSave no FileFilter option

3 Jun

I try to create my own extension with a saved AIR file. The point in doing this is that the user knows what files are created by what program and a file without an extension is just plain ugly.

When you save a file in other programs you can choose to overwrite a file (that is created before or has a known extension) or create a new file. I tried to find a way in AIR to do this same thing. I found one article on an Adobe blog that uses a FileFilter in combination with a file.browseForSave but he is using it in a way that it has no effect and is pretty useless. He is creating a FileFilter but he is never using it:

save:function(){
var fileFilter = new air.FileFilter("To Do Lists", "*.todo");
ToDo.currentDirectory.addEventListener(air.Event.SELECT, ToDo.fileSaved.bind(ToDo) );
ToDo.currentDirectory.browseForSave("Save To-do List");
}

I hear you think “who cares about the FileFilter” because it sounds like a minor problem and maybe it is. But for me it seems easy to build because browse(), browseForOpen() and browseForOpenMultiple() are using it.

I wonder if there is a way to work around this problem. It is maybe a little detail but it are the little details that make things great.

How to find an address with Google maps Flash API

19 May

After the Flash Google maps API release I spend some time to see what is possible. I started with the documentation from Google. In there documentation they are using the latitude and longitude coordinates to set the center of your map. This is not really a human readable way to do it and personally I never used the latitude and longitude coordinates to find a city or street in Google Maps. That is why I started searching for a way to center the map with an address.

Google Maps Application

I build a small application with source-code available in Flex that is using this technique. In the left upper corner you can search your own address. I use ClientGeocoder to search for the address but the problem i’m running in to is that you can’t run it local because he returns this error.

Warning: Domain maps.googleapis.com does not explicitly specify a
meta-policy, but Content-Type of policy file
http://maps.googleapis.com/mapsapi/crossdomain.xml is
'text/x-cross-domain-policy'.  Applying meta-policy 'by-content-type'.

You can’t use ClientGeocoder crossdomain. You should call it from a domain that has a registered Google Maps API key in my case “http://blog.arnomanders.nl”.

Air file.nativePath Vs. file.url

8 May

Is it me or is file.url a lot easier to use than file.nativePath in Adobe AIR. Maybe I’m missing something because every tutorial or code snippet I can find uses file.nativePath.

I’m busy building an AIR application that can be used on Windows and Mac OS. I have to take care of the file structure of both systems. After I test my application on a Mac I couldn’t load anything from it. The reason of this problem is that Mac needs “file://” in front of the file URL to load the file correct.

When I had this problem I searched the internet for a solution. I found very complex solutions at EverythingFlex and Snipplr. But then I start to examine the File object and found just the right file url (on the Mac it adds “file://” in front of the url) just accessible with File.url. Then I tested it on Windows and it worked perfect.

I see no reason why I shouldn’t use this simple version of all the long code solutions that are available on the web. But like I said maybe I’m missing something?

Direction of the TileList behaves strange

18 Apr

I stumbled into an incorrect working function of the TileList in Flex. It looks like they swopped a few variables around.

If you set the direction of the TileList to horizontal it looks like Flex doesn’t care about the option and just scolls vertical. After that I checked an Adobe quickstart guide to know sure that I wasn’t doing anything wrong. But I couldn’t find anything that I missed.

Because I hate it if things don’t work I try everything to get it working. So I tried to set the direction to vertical just to see if something was happening and now the TileList scolled horizontal… very strange.

here is a example with source code (right click)

TileList problem example

Maybe I’m doing something wrong? Do other people have the same problem?

More playing with 3D and 3D physics engine

15 Apr

I extended the Flex 3D example of my previous post some more. Now you can drag (left mousebutton) the objects and bounce them into each other.

away3d tile dragging

I think the smart visiters will see that it look a little like TileUI from Doug McCune or TileUI copy of Bill White. I tried to make something like that but I used Away3D and the WOW physics engine.

(more…)

Playing around with 3D and WOW

3 Apr

Watch the Away3D and WOW demo. Sometimes they stand like a tower and sometimes it almost look like they explode. Click on the onderground to reset the cubes to a random position

away3d with wow

(more…)

Page 2 of 3123