@tweenOut

Developing Web Daily

By

Issue With Exporting Flex Mobile App

Well I have learned a lot recently with building a mobile app using Flex 4.6, don’t panic Flex will be around for a long time. The most recent issue I have found when exporting my app was using the new, “Export application with captive runtime” feature. This is a nice idea and I wish it worked better.

Captive Runtime

Captive Runtime

The idea here is that you can export AIR along with your application so the user doesn’t have to install it, but the issue is that it increases your file size about 25 mb, yes that is right 25mb. That is a lot when you’re talking about a mobile app.

So the lesson learned is until it is fixed don’t use this feature if you are trying to keep your application small. I went from 25.9 mb to just 900 kb after changing this setting.

Hope this helps you and if you have any ideas how to fix this please let me know.

Todd

By

Flex 4.6 Mobile Issues with Home & Back Key Press

I have been working on a mobile application using Flex 4.6 and ran into a few issues when pressing the Home and Back keys on an Android device. I researched the issue and everyone says that you should be able to use,

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
addEventListener("keyDown", backKeyPressedHandler, false, 1);
 
private function backKeyPressedHandler(e:KeyboardEvent):void
	{
		if (e.keyCode == Keyboard.BACK)
		{
			e.preventDefault();
		}
 
		if (e.keyCode == Keyboard.HOME)
		{
			e.preventDefault();
			NativeApplication.nativeApplication.exit();
		}
	}

but that doesn’t always work. The Back button listener worked sometimes but not all the time. So this is what I had to do to get both to work. The listener stays the same.

1
addEventListener("keyDown", backKeyPressedHandler, false, 1);

but I had to change what the keyboard event.keycode compared too. Here is what I created and works like a charm

1
2
3
4
5
6
7
8
9
10
11
12
13
private function backKeyPressedHandler(e:KeyboardEvent):void
{
	if (e.keyCode == 16777234)
	{
	     e.preventDefault();
	}
 
	if (e.keyCode == 16777238)
	{
	     e.preventDefault();
	     NativeApplication.nativeApplication.exit();
	}
}

I hope this helps someone else that is having the same issue. Oh course you would probably want to create a global variable for the numbers to make it easier to understand. This is only for display purposes.

Todd