Archive | tutorial RSS feed for this section

Distort with drawTriangles()

29 Jun

There are a growing number of posts about the technique to distort an image with the drawTriangles() function. But most of those examples create a lot of extra vertices that aren’t needed for displaying the image and more calculation means more CPU consumption. I explain here how to work with verticals and show some basic examples.

Basics

Look at this example:

(more…)

LineChart datatip with degrafa skin

20 Aug

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

LineChart datatip with degrafa skin

Source

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

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?

Preformance tips Away3D

31 Mar

While I was building my ImageViewer3D I noticed a few things that can make everything just a little bit faster. And for the challenge and for fun I made a sort of testing application. I build it with Flex and Away3D

You can change the a few things such as the amount of 3d objects, type of filter, zoom of the camera and you can see how much this effects the framerate. After every change I reset the average FPS (frames per second) to give the best indication what the effect of the new options will have on the average FPS.
Probably this test is not really reflecting how much faces Away3D can render. A lot of things I do can be done more efficient. The source is enabled

preformance tester

preformance test

Some other preformance tips

I couldn’t build everything in because of the lack of time and also this project would be to big to be fun. Some other things that you can do to get the preformance up.

  • No precision on materials
  • No smoothing for materials or turn the smoothing on when it is needed
  • Niels Bruin told me this one: Set the application framerate to 60
  • Make sure that now 3D objects are in each other
  • This trick is from Maikel Sibbal: Only render if there is really something changed
  • 3D Objects close to the camera slows down the fps

Flash in Flex tutorial installation guide

27 Feb

My internship guide Maikel asked me to find out what you have to do to get Flash in Flex. I started to search for a nice tutorial about this but I have to say that there isn’t a step by step tutorial that is explaining this. Opportunity for me to help people.

If you already installed flexComponentKit and patched Flex builder 2.0.1 you can skip this installation guide and start building my WeatherComponent tutorial

Why use Flash in Flex?

  • It is very easy to make animations in Flash
  • Flash is easier to control movement from animations

to use Flash in Flex you need the next 3 programs:

  • Flash CS3
  • Flex Builder 2.0.1 (I used that one don’t know if my tutorial works for other versions)
  • Adobe Extention Manager

(more…)

Page 1 of 11