msgbartop
Just a little about development! Think before you write!
msgbarbottom

31 Oct 08 Solving the Alzheimer of your PopUpButton

As you can see here, Adobe created a big problem (at least for me) after solving a memory leak problem.
But thanks to Scott Melby at this post, now I have a medicine to the Alzheimer of the PopUpButtons in mu Applications, and I called this medicine “PopUpMenuGuardian”.
The problem is that the PupUpButton stops poping up after a screen resize for example.
The exact proposed solution was not good enough for me because I have many PopUpButtons, so, I created this helper class:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
	import flash.events.Event;
 
	import mx.controls.Menu;
	import mx.controls.PopUpButton;
 
	public class PopUpMenuGuardian
	{
		private var rbtn : PopUpButton;
		private var mnu : Menu;
 
		public function PopUpMenuGuardian(rbtn : PopUpButton)
		{
			this.mnu = rbtn.popUp as Menu;
			this.rbtn = rbtn;
			rbtn.addEventListener(Event.ADDED_TO_STAGE,restoreMenu);
		}
 
		public function restoreMenu(evt:Event):void{
			rbtn.popUp = mnu;
		}
	}

And now I just need to create one of this objects after I create each popupbutton :D

I think Adobe should fix this ASAP, but at least I have a workaround now.

PS.: I know I’m a looooong time without posting, but I just finished writing my RoR book, I’ll probably post more often now.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Tags: , ,