Unexplainable bug with ContextMenus in AIR

 

I came across this freakish bug yesterday in DestroyTwitter. As mentioned in a previous post, the next release takes great advantage of ContextMenus. In doing so, I managed to crash ADL without any report to the console or debug views. The problem lies in the data property of the NativeMenuItem class. Setting it to a particular Number will shutdown the app, as if you forgot to press 4 8 15 16 23 42 (LOST reference).

It gets weirder. When I set the property to the Twitter ID of my @destroytwitter account, it busts, which is how I found the issue. BUT! If I set the property to the Twitter ID of either my @destroytoday or @jonniehallman accounts, it works as expected. On top of that, if you convert the Number to a String, it works. If you place the Number within an Object like {id: $id}, it works. Below is the source code, give it a shot. I’m running Flash Builder 4 on Mac OS X 10.6.1. The bug has been submitted to Adobe—I’m dying to find out what causes it.

[note] @jonniehallman is my private test account, not my private personal account. It consists of thousands of tweets like “test”, “test test test”, “yet another test”, and so on.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package app.test {
	import flash.display.NativeMenu;
	import flash.display.NativeMenuItem;
	import flash.display.Sprite;
	import flash.utils.setTimeout;
 
	public class Test extends Sprite {
		public var _menu:NativeMenu;
 
		public function Test () {
			_menu = new NativeMenu ();
 
			_menu.addItem (new NativeMenuItem ("Open Link"));
 
			setTimeout (__init, 1000);;
		}
 
		private function __init ():void {
			// 14837781 works
			// 14839458 works
			// 2389723 doesn't work
			// 75443589 doesn't work
			_menu.getItemAt (0).data = 75443589;
 
			_menu.display (stage, mouseX, mouseY);
		}
	}
}

2 replies

  1. Wierd indeed. I’d be interested in seeing the reason why.

    I myself came uppon a wierd bug regarding Flash’s ability to convert strings to numbers and floating points.

  2. Same behavior with Flash Builder 4.0 (253292) on Windows Vista…
    And strings work OK, too.

Reply