Tag Archives: android

Android Native Extension Text Input Dialog for Adobe Air

Andorid Text Input Dialog Native Extension for Adobe Air

New in asNativeAlert .

So once again to make the package compatible with every platform I’m working on I’v packed to the same ANE file additional classes.
I think one of the main feature of a basic Dialog Box on every platform is to show some kind of input for people to interact with it.
So NativeTextInputDialog add this functionality to the whole package.

Usage:

public function openTextInputDialog(event:MouseEvent):void{
	if(NativeTextInputDialog.isSupported()){
		textInputDialog = new NativeTextInputDialog();
		textInputDialog.theme = NativeTextInputDialog.THEME_HOLO_LIGHT;
		textInputDialog.addEventListener(NativeDialogEvent.CANCLED,trace);
		textInputDialog.addEventListener(NativeDialogEvent.OPENED,trace);
		textInputDialog.addEventListener(NativeExtensionErrorEvent.ERROR,trace);
		textInputDialog.addEventListener(NativeTextInputDialogEvent.CLOSED, onTextInputDialogClosedHandler);
		var buttons:Vector.<String> = new Vector.<String>();
		buttons.push("OK","Cancle");
		var v:Vector.<NativeTextInput> = new Vector.<NativeTextInput>();
		var ti1:NativeTextInput = new NativeTextInput("name");
		ti1.inputType = NativeTextInput.text;
		ti1.messageBefore ="name:";
		ti1.text = "jacek";
		v.push(ti1);
		var ti2:NativeTextInput = new NativeTextInput("password");
		ti2.inputType = NativeTextInput.textPassword;
		ti2.messageBefore ="password:";
		ti2.text = "dddd";
		v.push(ti2);
		textInputDialog.show(titleInput.text,v,buttons);
	}
}
private function onTextInputDialogClosedHandler(event:NativeTextInputDialogEvent):void
{
	for each (var n:NativeTextInput in event.list) 
	{
		trace(n.name+":  "+n.text);
	}
	trace(event.buttonIndex);
}
Advertisements
Tagged , , ,

as3 Android native multi-choice (single) dialog for adobe Air

Android Native Extension Dialog for Air
The more I work on extensions the more I see how chaotic they are.
But never mind..
New classes in my as3NativeAlert.
Now a class NativeMultiChoiceDialog has the ability to show a native android popup multi-choice(or single) dialog inside Adobe Air project.

Usage:

private var NativeListDialog;
private var choces:Vector.<String>;
private var buttons:Vector.<String>;
private var checkedItems:Vector.<Boolean>;
private var selectedIndex:int = -1;

protected function view1_viewActivateHandler(event:ViewNavigatorEvent):void
{
      choces = new Vector.<String>();
//the text of the items to be displayed in the list.
      choces.push("one",'two","three","four");
      checkedItems = new Vector.<Boolean>();  
// specifies which items are checked. It should be null in which case no items are checked. If non null it must be exactly the same length as the array of items.
      checkedItems.push(true,false,false,true);
      buttons = new Vector.<String>();
//the labels for the buttons. It should be null in which case there will be only one button "OK". If non null max length 3 buttons
      buttons.push("OK","Settings","Cancle");
}
protected function openMultiChoiceDialog(event:MouseEvent):void
{
      multChDialog = new NativeListDialog();
      multChDialog.theme = NativeListDialog.THEME_HOLO_DARK;
      multChDialog.addEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
      multChDialog.addEventListener(NativeDialogEvent.OPENED,traceEvent);
      multChDialog.addEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
      multChDialog.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
      multChDialog.addEventListener(NativeDialogListEvent.LIST_CHANGE,onListChange);
      multChDialog.title ="Some Title";
      multChDialog.cancleble = true;
      multChDialog.showMultiChoice(choces,checkedItems,buttons);
}
public function openSingleChoiceDialog(event:MouseEvent):void
{
	singleChDialog = new NativeListDialog();
	singleChDialog.theme = ThemeSelector.selectedItem.data;
	singleChDialog.addEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
	singleChDialog.addEventListener(NativeDialogEvent.OPENED,traceEvent);
	singleChDialog.addEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
	singleChDialog.addEventListener(LogEvent.LOG_EVENT,traceEvent);
	singleChDialog.addEventListener(NativeExtensionErrorEvent.ERROR,onError);
	singleChDialog.addEventListener(NativeDialogListEvent.LIST_CHANGE,onListChange);
	singleChDialog.cancleble = true;
	singleChDialog.showSingleChoice(choces,selectedIndex,buttons,titleInput.text);
}
public function closeNativeDialogHandler(event:NativeDialogEvent):void
{
	var dialog:NativeListDialog = (event.target  as NativeListDialog);
	dialog.removeEventListener(NativeDialogEvent.CANCLED,closeNativeDialogHandler);
	dialog.removeEventListener(NativeDialogEvent.CLOSED,closeNativeDialogHandler);
	dialog.removeEventListener(NativeDialogEvent.OPENED,traceEvent);
	dialog.removeEventListener(NativeExtensionErrorEvent.ERROR,onError);
	dialog.kill();
}

private function onListChange(event:NativeDialogListEvent):void
{
        var dialog:NativeListDialog = (event.target as NativeListDialog)
	if(dialog.selectedIndex>-1){
		selectedIndex = dialog.selectedIndex;
	}else{
		const a:Vector.<String> = dialog.selectedLabels;
		if(a.length>0){
			for (var i:int = 0; i < a.length; i++) 
			{
				trace(a[i]);
			}
		}
	}
}

like always available themes for android :

THEME_DEVICE_DEFAULT_DARK
THEME_DEVICE_DEFAULT_LIGHT
THEME_HOLO_DARK
THEME_HOLO_LIGHT
THEME_TRADITIONAL

All my extensions are compiled by Android SDK revision 12 (Android 3.1).

Tagged