Category Archives: Actionscript 3.0

“You uploaded an APK with Invalid or Missing Signing Information for Some of Its files” Google Play, Adobe Air Error


“You uploaded an APK with invalid or missing signing information for some of its files. You need to create a valid signed APK”

while trying to publish your Adobe Air Android app to Google Play?

It’s due to a bug in Air 3.6 (and 3.7 for me). For future reference, you can find out what the error in the signing of an app are by using a tool called jarsigner. This exists in your JDK.

On windows it’s in your JDK path/bin folder. Just open up command prompt/terminal and run:

jarsigner -verify "[PATH TO YOUR APK]"

Here is the error I was getting

jarsigner: java.lang.SecurityException: SHA1 digest error for res/drawable-xhdpi

Here’s how I fixed it. I opened up the APK in 7zip (remember, APK is collection of files zipped together. You can actually open it up) and navigated to that res/rawable-xhdpi folder. What do you know… looks like there are TWO icon.pngs. It’s a bug in Adobe’s latest Air which packages the APK incorrectly by creating duplicated icon.png files. Probably will be fixed in later versions.

If you want to avoid upgrading your Air SDK, all you need to do is delete one of those two icon.png files from the zip file.

Command line way to do it (will delete both):
zip -d [YOUR APK.APK] res/drawable-xhdpi/icon.png

Now, if you tried uploading this APK you might get an error about the APK not being zipaligned. Due to us deleting files the APK is no longer zip aligned. Which means we have to re align the file.

Navigate to your Android Developer Tools (ADT) folder. Under the SDK’s /tools you’ll see that zipalign. You’ll need to do

zipalign -f -v -c 4 “Your APK” “Your APK 2”

Reupload the new APK (remember if you don’t put an absolute path it’ll be in the same directory as where zipalign is) and it should be accepted.

Oh the joys of Adobe Air for mobile development.

Simple Circle Packing

I am working on a new game which is was in need of an algorithm to pack characters as close together without touching. Here is a demo of my algorithm:

Get Adobe Flash player

And the code (uses TweenLite)

import flash.display.MovieClip;
import flash.geom.Point;
import flash.utils.Timer;
import com.greensock.TweenLite;

var mcs:Array = [];
var radius:Number = 5;
var c:Point = new Point(stage.stageWidth / 2,stage.stageHeight / 2);
var animationTime:Number = .5;

function addMC(e:Event= null)
	var mc:MovieClip = new MovieClip();
	mc.x = c.x;
	mc.y = c.y;
var t:Timer = new Timer(animationTime*1000,1500);
function arrange()
	var curDistanceAwayFromCenter:Number = radius * 2;
	var numMoved = 0;
	var n:Number = mcs.length;
	// Place the very first circle in the center, as the algorithm won't work for n==1
	mcs[0].x = c.x;
	mcs[0].y = c.y;
	while (numMoved < n)
		/*R*SIN(180/n) = r
		SIN(180/n) = r/R;
		ARCSIN(r/R) = 180/n
		n = 180/ARCSIN(r/R)
		var numberToFit:int = Math.PI/Math.asin(radius/curDistanceAwayFromCenter);
		if (numberToFit > mcs.length-numMoved)
			numberToFit = mcs.length - numMoved;
		for (var j:int = 0; j < numberToFit; j++)
			var cur:MovieClip = mcs[numMoved];
			// ang to center
			var ang:Number = Math.PI * 2 * j / numberToFit;
			var np:Point = new Point();
			np.x = c.x + Math.cos(ang) * curDistanceAwayFromCenter;
			np.y = c.y + Math.sin(ang) * curDistanceAwayFromCenter;
			// this if improves performance a tiny bit, would probably be way more performant if we detected if this was in the "last" circle, if not then we don't need to loop through it anymore
			if (np.x !== cur.x || np.y !== cur.y),animationTime,{x:np.x,y:np.y})
		curDistanceAwayFromCenter +=  radius * 2;


Note that this doesn’t pack circles optimally in a space. That is a much harder problem. I was looking for a solution that would “cluster” the characters.

Auto create polygon AS3

Made a Flash on Wonderfl the other day.

My friend studying for his PhD at Georgia Tech in architecture called me regarding a problem. He said,

“I need to program something to create a polygon from points. Right now, the points are not being drawn in the right order so lines are being overlapped. How do I have the program draw them in the right order?”

So I came up with a theory of how to do it. The idea is that you find the average point between the points, and from that point you find the arc tangent to each of the points and order the points based on their angle to the center. This idea would only work in 2D, but I’m sure there is a general way to do it for all dimensions.

Here is the code written in actionscript. You can click to add a point and ctrl+click to delete a point. I put it on wonderfl because I am thinking some people could fork some more interesting things from it.

Auto create Polygon – wonderfl build flash online

JavaScript Function declaration cautions!

Just found Kontagent‘s JavaScript library has a issue. When you declare functions in JavaScript as so below, the behavior isn’t as expected!

a = 5;

if (a == 5)
    function yo()
else if (a == 6)
    function yo()


Be sure to declare your dynamic functions like so:

a = 5;
var yo;
if (a == 5)
    yo = function()
else if (a == 6)
    yo = function()

As in Actionscript (also ECMAScript based), declaring functions the first way will be global scope. And the last function defined will be the one that is used.

We were trying to debug why Kontagent‘s library wasn’t pinging the right events (in our case Invite Sent notifications). When we investigated the code we saw they wrapped function calls inside ifs as above… Hopefully they will read this blog post and implement a fix as suggested :-).
So be careful developers!

*Edit: We sent a Pull request to their github with our fix

LocalConnection Bug in Flash Player

So I’ve had this problem for ages, and couldn’t find anyone online writing about it.

LocalConnection in AS3 is used to send messages between Flash SWFs in a browser window. It’s also used as a hack to invoke garbage collection in the Flash Player.

I’ve been using it in some recently applications to ensure only one instance of a SWF is loaded at a time on a computer and to display a message to a user if a window with the application is already open.

It’s usually be pretty straight forward.

var LocalConn:LocalConnection = new LocalConnection();

Declares it

			try {
			} catch(error : ArgumentError) {
trace("Uh oh... Looks like it's already running");

Only one connection string can be used at a time, and if another SWF in the another browser window (or another tab… or another browser for that matter) tries to connect that ArgumentError will be thrown.

Unfortunately, there is a annoying bug where sometimes, even if no other instances are open, the LocalConnection thinks someone is still running on the same connection string…

I’ve experienced it happening when simply testing in Flash Builder and FDT… Sometimes I am working on another part of my application when one test the application says it’s already running… I’m confused at this point because I know nothing else is running…

I think I’ve narrowed down WHY it happens. It seems to happen when Flash is closed unexpectedly. For example, on Google Chrome, if you run the SWF and then for some reason Flash crashes (you know… the “uh oh Flash crashed” bar that appears at the top of Chrome), it seems that the LocalConnection is never officially closed.

What sucks is that you either have to change the connection string or reboot your computer (restarting browsers don’t work).

If anyone else has experienced this or knows any fixes, please let me know in the comments. I’ve been experiencing this problem since at least Flash Player 9. I’ve reported it on Adobe’s ticketing system… unfortunately they don’t allow anyone to read the ticket because they restricted viewing deeming it a possible “security” flaw – but maybe if other people are experiencing the issue they will put in a fix for it.

Update 5/10/2011
Qingyan Zhu from Adobe replied to my bug report:

Hi Danny,

Thanks for clarifying the issue.

But this is actually as designed.

So when there’s only one browser, if it crashes, then the segment gets reset, and the dangling LC endpoints get cleared.

But if there are two browser processes (depending, say on how IE is launched), or two processes that use LocalConnection (including any AIR app, Flash Projector, AIM, Y!IM, etc etc), then the corrupt memory segment will stick around.


AS3 Matrix Library

I don’t know if I ever posted this, but here is an Actionscript 3.0 Matrix math library I made in college. Check out AS3 Matrix on Google Code (

Some of the features it uses is caching Matrices for their operations. Does LU, QR, and SVD decompositions. Not sure how it compares to speed of other libraries (maybe someone can make a benchmark), but it is pretty robust (from my recollection) and is built pretty modular.

Let me know if you ever decide to use this library – and what you used it for :-).

Flash Artistic Experiment: is feeling good #1

Throughout the semester I developed this Flash art/simulation/game. It was originally supposed to be a game… maybe it is I don’t know it all depends on your definition. The title is called Is Feeling Good. I reserved the name a few months ago and thought for a while of what could possibly be on the site. )I have a basic idea of what the site will have and will post more about it later).

Anyway, the following idea stems (literally) from procedurally created experiences. The basic instructions are:

1) Click and hold to collect particles to form a rain cloud.

2) Release to rain and grow plant on right.

If you give plants enough water they will finish growing and move to the left. If you don’t water the actively ungrown plant the plant will wither. If you collect too much water then your cloud will begin to leak. Hold even more and your cloud will turn to lightning and shoot down the active plant. There are also a bunch of other subtle things that I included that I’ll let you guess how works.

The particles come from the left in tune to the music (I use Flash 10’s sound extract() function to procedurally check the sound volume change). The trees are procedurally created and I’m happy to say that the code is highly optimized with a bunch of tricks that I used to ensure that the tree grows quickly despite a bunch of things going on screen at the same time. While creating procedurally generated trees ended up being much easier than I thought, refining the trees ended up being extremely difficult. Making a tree look like a tree is difficult to do, and I spent more time messing with the variables than actually coding it. The flash uses nearly all bitmap graphics (that’s why so many things are on the screen at the same time).

Remember, you need Flash 10 to view.

Click here to view.

Hope you enjoy!


For my experimental digital art class at Georgia Tech, I created this toy I call SoundPen. It’s a very basic version obviously (although I think some cool things could come from this idea).

The basic idea is to create music by clicking your mouse and placing balls that will bounce of the screen. There are 3 different types of balls (click and press either A, S, or D).

I used Jeff Swartz’s algorithm to change pitch of the sounds from the vertical balls. The more left the ball is on the screen the lower the pitch while the more right on the screen the higher the pitch.

Please be careful when using. If you place too many balls your computer might slow down rapidly. If you want to remove the last ball just press the backspace.

There are probably ways I could have fixed that problem (for example, using lower level PixelBender capabilities to process the sound); however, I don’t think it matters too much. You don’t want to put too many balls anyway because you’ll just hear noise.

(Be sure you have Flash 10!)

Picture of Pictures

For my Experimental Digital Media class at Georgia Tech.

Click here to view
(Must have Flash Player 10)

The Internet has provided a new means of data expression. I decided to play with the idea of machine aesthetics by developing an application that creates images of images.

I first saw this effect a long time ago on a poster advertisement for the Truman show. I always wondered how they made the effect of compiling images together to form, when looked at a certain distance, an image.  The program I made this week creates the effect by downloading Flickr images.

The algorithm is very straightforward (I also mention some ideas for expansion on the Flash). Basically the program downloads Flickr images either by the most recent, based on a search term, or from a username’s public photos via the as3flickrlib. While downloading, the application calculates and caches each photos average RGB color average (the main reason why my algorithm is fast). The program, based on the user’s supplied number of rows and columns, calculates the average RGB color of each divided cell and finds the image with the average color that has the closest 3D distance to the cell’s average color. The effect is pretty cool. I offer the ability to have a very high resolution (which basically expands the original image before running the algorithm to near the max of Flash Player 10’s bitmapData’s limit). The picture effect is  best seen with the highest resolution.

Lastly, thanks to Flash Player 10, saving images is added. I use the JPGEncoder from as3corelib. Unfortunately, the JPGEncoder was too slow as its algorithm is synchronous. Upon Googling “Asynchronous JPG Encoder,” I found a cool Asynchrnous JPG Encoder class by While I have crtiticisms on the class’s asynchronous technique choice, the class does what it says it does.

Anyway, if there is enough support, I may release the class as open source on Google Code. I think there are a lot of ways to alter the algorithm to produce different kinds of image results.