Categories
Actionscript

Recognize DisplayObject Transform Matrix Change Event in Flash AS3

If another object changes the transformation matrix of a DisplayObject, the DisplayObject has no means to recognize that it has been transformed, as it is transformed automatically. E.g., there is no kind of TRANSFORMATION_MATRIX_CHANGED event that is dispatched on the DisplayObject. If your DisplayObject still should react on a change of its transformation matrix, a workaround is necessary, which is described in the following approach. I show a short solution at first and will explain the actual problem and solution approach in more detail afterwards.

Categories
Adobe Air

Remove ‘View Source’ from Adobe Air Debug Context Menu in Flash Builder

Recently I wondered how I can get rid of that “View Source” entry in the context menu of Adobe Air as I wanted to add my own context menu there.

It turned out that I had to remove all the source folder entries in the project’s run configuration (see in the image above).

Categories
Actionscript Adobe Air Flash flex

Flex Does Not Find Resource Bundles

LocalizationProblem

Recently I had the problem that my Flex code, which used the ResourceManager, would not find the resource bundle, which contained all resources for my application. However, the application compiled but it would always crash whenever the first time a resource should be loaded. I checked my compiler arguments a 1000 times but everything was correct and did work well in another Flex application. The problem was that my resource bundle was not present in the ResourceManager, it just did not load it.

Categories
Actionscript Flash flex

How to get smooth image scaling in Flex

Great article from Ben Longoria about how to get smooth image scaling in Flex.

Categories
Actionscript Adobe Air Flash flex

Draw Image Reflection in Adobe Flex

Recently, I needed an image reflection effect in Flex. This would not be complicated to achieve for a Loader image object in Flash Actionscript 3 but the more for Flex as everything needs to be a bit more complicated in Flex when it comes to customizing.

Flex Image Reflection

Categories
Actionscript flex Uncategorized

Setting the Width and Height of an Object in Flex to 100% with Actionscript

Today I had the problem that i needed to create a Flex element by hand and apply to it a width of 100%.

This goes as easy with MXML as this
<mx:VBox id="wrapperBox"><mx:UIComponent width="100%" height="100%" id="elementXYZ"></mx:VBox>

But you cannot code this to achieve the adding programatically with Actionscript:
var elementXYZ:UIComponent = new UIComponent();
elementXYZ.width = "100%";
elementXYZ.height = "100%";
wrapperBox.addChild(elementXYZ);

Instead, you have to use this:
var elementXYZ:UIComponent = new UIComponent();
elementXYZ.percentWidth = 100;
elementXYZ.percentHeight = 100;
wrapperBox.addChild(elementXYZ);

Categories
Actionscript Adobe Air Flash flex

Calculate and Set Bounds (Bounding Box) from Points in Google Maps Flash [Update]

I’ve got a list of points in my database, which I want to show neatly in a Google Maps Flash Map.

Thus, I …

  1. calculate the bounding box around these points
  2. calculate the center of this bounding box
  3. set the zoom level of the map in a way that the zoomed cutout contains all points
  4. set the center of the map
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//1.
var bounds:LatLngBounds = new LatLngBounds();
for each(var mapObject in tripMessages){
    var currentLatLon:LatLng = new LatLng(mapObject.latitude, 
	                                       mapObject.longitude);
    bounds.extend(currentLatLon);
}
 
//2.
var center:LatLng = bounds.getCenter();
 
//3.
map.setZoom(map.getBoundsZoomLevel(bounds));
 
//4.
map.setCenter(center);
Categories
Actionscript Flash

Save XML and text files from Flash to your HD with AS3 and PHP

In this post I’ll show how to save a file from AS3 to your local HD. In another post I’ve explained how to load a file from HD to Flash.

For a project I’ve been looking around for a decent solution to the problem of saving a text file (to be more precise XML file) from Actionscript 3 to my local harddisc but i couldn’t find a solution for this (what not necessarily means that there is none).

Saving and loading can be smoothly achieved with Adobe Air but not with Flash because Flash has been designed to run on the web. However, it is possible to download and upload files via AS3 on and from your HD to and from a webserver. Think of an Flash MP3 shop: You can click on an MP3 in Flash and you will be asked where to save the file and afterwards the file is being downloaded to the chosen location on your HD. So it must be somehow possible.

Additionally, it is possible to create XML or other text in Flash and store it on a webserver and vice versa.

Thus I came upon following solution:

Howto save and load text files with AS3
Figure 1: Howto save and load text files with AS3

Categories
Actionscript Flash flex Multi-Touch

Google Maps Multi-touch Actionscript Code [Update_3]

Google Maps multi-touch image

After I published my youtube video on the Google Maps multi-touch app I have had some demands for the source code of this Google Maps multi-touch Flash application. Hence, I have decided to make the source code of it publicly available on Google Code. You will find the sources on the mapstouch Google Code download page.

To be able to use it you need to generate your own Google Maps Api key. Use this explanation on how to tweak the code and choose the appropriate URL for your API key in order to prevent the red DEBUG strings (you can still see those strings on the screen in the image on the top of this post):

Put your own Google Maps API key in the variable map.key in the class GoogleMapsPureAS. Use the qualified name of your computer in the URL e.g.

http://johannes.local/googleMapsMultitouch

and not

http://localhost/googleMapsMultitouch

to get rid of the red DEBUG strings on the screen. Additionally, opening the SWF file in the Flash Player is not possible if you don’t want to see the DEBUG string. Open it in your browser under the appropriate URL where your Google Maps API key has been registered for.

If you have got more questions just ask them in the comments.

Update: You need the Google Maps for Flash API that you can download here. You have to include the swc file from the folder lib of the uncompressed sdk.zip file either in your Flash GUI or put it into the libs folder of your Flex Builder project.

Update 2: Please beware that executing Google Maps on a local computer or in the intranet seems to be not committed according to Google’s license agreements (see comments).

Update 3: I’ve posted another (even more detailed) explanation how to remove the DEBUG strings in the forum of the nuigroup.. Additionally, i’ve updated the Downloads on the mapstouch Google code page.

Categories
Actionscript Flash Multi-Touch

Digital Volvelles application video

Quite some time since the actual private view at the Mall Galleris in London I have managed to put a little video about our Digital Volvelles application online. A more detailed video is going to come but until then watch this video please: