Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
New Contributor
adrianyoung
Posts: 5
Registered: ‎03-11-2011
My Device: Bold 9700
Accepted Solution

Dialog box not working

I'm trying to get a dialog box to show up, but nothing seems to happen in the simulator at all. I'm using the code from the development guide (shown below) so I would assume it should run fine. I've tried a trace() and its definately going into the event, its just not displaying anything. I'm running 0.9.4 if that makes any difference

 

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import qnx.dialog.*;
	import qnx.display.IowWindow;
	import qnx.ui.buttons.LabelButton;
	import qnx.ui.text.*;
	[SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
	public class Dialogs extends Sprite
	{
		private var lblWhichButton:Label = new Label();
		public function Dialogs()
		{
			var btnShowDialog:LabelButton = new LabelButton();
			btnShowDialog.label = "Click here";
			btnShowDialog.x = (stage.stageWidth - btnShowDialog.width)/2;
			btnShowDialog.y = (stage.stageHeight - btnShowDialog.height)/2;
			btnShowDialog.addEventListener(MouseEvent.CLICK, ButtonClicked);
			lblWhichButton.x = (stage.stageWidth - btnShowDialog.width)/2;
			lblWhichButton.y = btnShowDialog.y + btnShowDialog.height;
			lblWhichButton.width = 600;
			lblWhichButton.text = "Button index reported here.";
			addChild(btnShowDialog);
			addChild(lblWhichButton);
		}
		public function ButtonClicked(event:Object):void
		{
			var myDialog:AlertDialog = new AlertDialog();
			myDialog.dialogSize = DialogSize.SIZE_SMALL;
			myDialog.addEventListener(Event.SELECT, alertButtonClicked);
			myDialog.title = "Dialog";
			myDialog.message = "This is a small alert dialog";
			myDialog.addButton("OK");
			myDialog.addButton("Cancel");
			myDialog.show(IowWindow.getAirWindow().group);
		}
		public function alertButtonClicked(event:Object):void
		{
			lblWhichButton.text = "Button Clicked Index: " + event.target.selectedIndex;
		}
	}
}

 

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog box not working

Just in case, QNX alerts only work in the simulator and not in AIR.  Are you running this code in the simulator?

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog box not working

Also, in your event listener functions, best to use "Event" class instead of "Object" class.

Please use plain text.
New Contributor
adrianyoung
Posts: 5
Registered: ‎03-11-2011
My Device: Bold 9700

Re: Dialog box not working

I'm using the simulator.

 

I've changed the classes from "Object" to "Event" but still no luck.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog box not working

  • Is the app displaying?
  • Buttons show up?

 

Please use plain text.
New Contributor
adrianyoung
Posts: 5
Registered: ‎03-11-2011
My Device: Bold 9700

Re: Dialog box not working

Everything else works fine, app loads, buttons show. Clicking on the button runs the method (trace call verifies this) but the alert dialog doesn't show at all.

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10

Re: Dialog box not working

Everything "looks" fine.

 

Try only:

 

myDialog.show();

Please use plain text.
New Contributor
adrianyoung
Posts: 5
Registered: ‎03-11-2011
My Device: Bold 9700

Re: Dialog box not working

I've fixed it now. Did a full reinstall of the simulator and no problems at all. Unsure why it wasn't working before though.

Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: Dialog box not working

Try resetting your simulator. Sometimes there is a memory issue and it stops all service down to the OS level. Go to Virtual Machine > Restart.
J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Developer
JohnPinkerton
Posts: 350
Registered: ‎01-21-2011
My Device: Curve 8900 (Personal) / Bold 9650 (Work)

Re: Dialog box not working

 


adrianyoung wrote:

I've fixed it now. Did a full reinstall of the simulator and no problems at all. Unsure why it wasn't working before though.


I've had similar issue happen to me, only way was to wipe and reinstall.

 

Please use plain text.