Native Dialogs is an  extension that allows developers to show native alert dialogs and messages on Android and iOS.

Some features:

  • Display Alert dialogs
  • Display multiple choice option dialogs
  • Manage multiple dialogs and process user responses individually
  • Customise all button labels, dialog titles and messages
  • Single API interface – your code works across iOS and Android with no modifications
  • Sample project code and ASDocs reference

Sample

/**
 *        __       __               __
 *   ____/ /_ ____/ /______ _ ___  / /_
 *  / __  / / ___/ __/ ___/ / __ `/ __/
 * / /_/ / (__  ) / / /  / / /_/ / /
 * \__,_/_/____/_/ /_/  /_/\__, /_/
 *                           / /
 *                           \/
 * http://distriqt.com
 *
 * This is a test application for the distriqt extension
 *
 * @author Michael Archbold & Shane Korin
 *
 */
package
{
	import com.distriqt.extension.dialog.Dialog;
	import com.distriqt.extension.dialog.events.DialogEvent;

	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.text.TextField;
	import flash.text.TextFormat;

	/**
	 * Sample application for using the Dialog Native Extension
	 *
	 * @author	Michael Archbold
	 */
	public class TestDialog extends Sprite
	{

		/**
		 * Class constructor
		 */
		public function TestDialog()
		{
			super();
			create();
			init();
		}

		//
		//	VARIABLES
		//

		private var _text		: TextField;

		//
		//	INITIALISATION
		//	

		private function create( ):void
		{
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;

			var tf:TextFormat = new TextFormat();
			tf.size = 24;
			_text = new TextField();
			_text.defaultTextFormat = tf;
			addChild( _text );

			stage.addEventListener( Event.RESIZE, stage_resizeHandler, false, 0, true );
			stage.addEventListener( MouseEvent.CLICK, mouseClickHandler, false, 0, true );

			addEventListener( Event.ACTIVATE, activateHandler, false, 0, true );
			addEventListener( Event.DEACTIVATE, deactivateHandler, false, 0, true );
		}

		private function init( ):void
		{
			try
			{
				Dialog.init( "your_dev_key" );

				message( "Dialog Supported: "+ String(Dialog.isSupported) );
				message( "Dialog Version: " + Dialog.service.version );

				//
				//	Add test inits here
				//

				Dialog.service.addEventListener( DialogEvent.DIALOG_CLOSED, dialog_dialogClosedHandler, false, 0, true );

			}
			catch (e:Error)
			{

			}
		}

		//
		//	FUNCTIONALITY
		//

		private function message( str:String ):void
		{
			trace( str );
			_text.appendText(str+"\n");
		}

		//
		//	EVENT HANDLERS
		//

		private function stage_resizeHandler( event:Event ):void
		{
			_text.width  = stage.stageWidth;
			_text.height = stage.stageHeight - 100;
		}

		private function mouseClickHandler( event:MouseEvent ):void
		{
			//
			//	Show an alert dialog
			//	

			var titleString:String = "test";
			var messageString:String = "";
			var cancelLabel:String = "cancel";
			var otherLabels:Array = [];

			// Add some random otherLabels
			var extraButtonCount:int = Math.ceil( Math.random()*20 );
			for (var i:int = 0; i < extraButtonCount; i++)
			{
				otherLabels.push( "button " +String(i+1) );
			}

			message( "showAlertDialog("+titleString+","+messageString+","+cancelLabel+","+otherLabels.join(",")+")");
			Dialog.service.showAlertDialog( 0, titleString, messageString, cancelLabel, otherLabels );

//			message( "showMultipleChoiceDialog("+titleString+","+messageString+","+otherLabels.join(",")+")");
//			Dialog.service.showMultipleChoiceDialog( 1, titleString, messageString, otherLabels );
		}

		//
		//	NOTIFICATION HANDLERS
		//

		private function activateHandler( event:Event ):void
		{

		}

		private function deactivateHandler( event:Event ):void
		{
			trace( "deactivateHandler() ");
		}

		private function dialog_dialogClosedHandler( event:DialogEvent ):void
		{
			message( "Dialog Closed: id="+event.id +" button="+event.data );
		}

	}
}
Air Native Extension, Android, iOS . URL.