=================================
=================================
=================================
키보드가 나올때:
addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, function_);
이 이벤트를 사용하는것이 좋다.
키보드가 들어갈때:
addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, f);
addEventListener(FocusEvent.FOCUS_OUT, f);
위와같이 두개를 같이 써주는게 개인적으로 좋았다.
=================================
=================================
=================================
출처: http://help.adobe.com/en_US/as3/dev/WSfffb011ac560372f6bc38fcc12e0166e73b-8000.html
Controlling virtual keyboard behavior
The runtime automatically opens the virtual keyboard when the user taps inside a text field or a specially configured interactive object. When the keyboard opens, the runtime follows the native platform conventions in panning and resizing the application content so that the user can see the text as they type. When the keyboard opens, the focused object dispatches the following events in sequence: softKeyboardActivating event — dispatched immediately before the keyboard begins to rise over the stage. If you call the preventDefault() method of the dispatched event object, the virtual keyboard does not open. softKeyboardActivate event — dispatched after softKeyboardActivating event handling has completed. When the focused object dispatches this event, the softKeyboardRect property of the Stage object has been updated to reflect the area of the stage obscured by the virtual keyboard. This event cannot be canceled. Note: If the keyboard changes size, for example, when the user changes the keyboard type, the focused object dispatches a second softKeyboardActivate event. softKeyboardDeactivate event — dispatched when the virtual keyboard closes for any reason. This event cannot be canceled. The following example adds two TextField objects on the stage. The upper TextField prevents the keyboard from raising when you tap the field and closes it if it is already raised. The lower TextField demonstrates the default behavior. The example reports the soft keyboard events dispatched by both text fields. |
package
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.events.SoftKeyboardEvent;
public class SoftKeyboardEventExample extends Sprite
{
private var tf1:TextField = new TextField();
private var tf2:TextField = new TextField();
public function SoftKeyboardEventExample()
{
tf1.width = this.stage.stageWidth;
tf1.type = TextFieldType.INPUT;
tf1.border = true;
this.addChild( tf1 );
tf1.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATING, preventSoftKe yboard );
tf1.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, preventSoftKe yboard );
tf1.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, preventSoftKeyboard );
tf2.border = true;
tf2.type = TextFieldType.INPUT;
tf2.width = this.stage.stageWidth;
tf2.y = tf1.y + tf1.height + 30;
this.addChild( tf2 );
tf2.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATING, allowSoftKeyboard );
tf2.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, allowSoftKeyboard );
tf2.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, allowSoftKeyboard);
}
private function preventSoftKeyboard( event:SoftKeyboardEvent ):void
{
event.preventDefault();
this.stage.focus = null; //close the keyboard, if raised
trace( "tf1 dispatched: " + event.type + " -- " + event.triggerType );
}
private function allowSoftKeyboard( event:SoftKeyboardEvent ) :void
{
trace( "tf2 dispatched: " + event.type + " -- " + event.triggerType );
}
}
}
=================================
=================================
=================================
출처: http://cafe.naver.com/flashdev/74781
this.stageText = new StageText( new StageTextInitOptions( true ) );
this.stageText.softKeyboardType = SoftKeyboardType.DEFAULT;
this.stageText.returnKeyLabel = ReturnKeyLabel.GO;
this.stageText.editable = true;
this.stageText.stage = this.stage;
this.stageText.visible = true;
this.stageText.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, openKeyboard );
this.stageText.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, closeKeyboard );
this.stageText.addEventListener( KeyboardEvent.KEY_DOWN, keyDownHandler );
대략 이런 식으로 작성을 해봤는데, 안드로이드든, 아이폰이든 이벤트도 반응이 없고, 어떻게 쓰는지 잘 모르겠군요...
어쨌든, 사실 가상키보드의 '완료' 버튼의 클릭을 받아내는 것이 목적인데, 이 버튼이 눌렸다는 것을 받을 수 있을까요?
focus_out 같은 것만으론 해결이 안될것 같고...
[출처] StageText 쓰는 법?? 또는 가상 키보드의 완료버튼의 이벤트 받기 (플래시(Flash)로 생계를 이어가는 사람들의 모임:플생사모)|작성자 난누군가
=================================
=================================
=================================
출처: http://clack.tistory.com/369
모바일 기기에 키패드 띄우기
textField, textArea 같이 사용자 입력에 반응하는 인터렉티브 객체는 가상 키패드를 띄을 수 있다.
private var bg: Sprite; private var tf: TextField; private var keyboardOverRect: Rectangle; private var overRect: Shape public function SoftKeyboardTest() { super(); bg = new Sprite(); bg.graphics.beginFill( 0x555555 ); bg.graphics.lineStyle( 1, 0xff0000 ); bg.graphics.drawRect( 0, 0, 400, 500 ); this.addChild( bg ); var btn: Sprite = new Sprite(); btn.graphics.beginFill( 0x333333 ); btn.graphics.lineStyle( 1, 0xFF0000 ); btn.graphics.drawRect( 0, 0, 100, 50 ); this.addChild( btn ); btn.x = 50; btn.y = 50; btn.addEventListener(MouseEvent.CLICK, onBtnClick ); tf = new TextField(); tf.border = true; tf.borderColor = 0xFF0000; tf.width = 300; tf.height = 50; tf.background = true; tf.backgroundColor = 0xFFFF00; tf.type = TextFieldType.INPUT; tf.x = 50; tf.y = 400; this.addChild( tf ); tf.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, onKeyboardActivate ); tf.addEventListener( SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, onKeyboardDeactivate ); this.addEventListener(Event.ADDED_TO_STAGE, onAddStage ); trace("키보드 테스트 생성 완료"); } private function onBtnClick( e:MouseEvent ): void { trace("버튼 클릭"); tf.needsSoftKeyboard = true; this.stage.focus = tf; tf.requestSoftKeyboard(); } private function onAddStage( e:Event ): void { trace("스테이지에 추가됨"); } private function onKeyboardActivate( e:SoftKeyboardEvent ): void { trace( "키보드 나타남", this.stage.softKeyboardRect ); keyboardOverRect = this.stage.softKeyboardRect; overRect = new Shape(); overRect.graphics.beginFill( 0x000000, 0 ); overRect.graphics.drawRect( 0, 0, keyboardOverRect.width, keyboardOverRect.height ); this.stage.addChild( overRect ); overRect.x = keyboardOverRect.x; overRect.y = keyboardOverRect.y; if( tf.hitTestObject( overRect ) ) { trace("텍스트 필드 키보드에 가려짐"); } else { trace("텍스트 필드 키보드에 안가려짐"); } if( e.triggerType == SoftKeyboardTrigger.USER_TRIGGERED ) { trace("사용자가 키보드를 띄웠음"); } else if( e.triggerType == SoftKeyboardTrigger.CONTENT_TRIGGERED ) { trace("컨텐츠에서 키보드를 띄웠음"); } } private function onKeyboardDeactivate( e:SoftKeyboardEvent ): void { trace("키보드 감춰짐"); if( overRect != null && this.stage.contains( overRect ) == true ) { this.stage.removeChild( overRect ); } } |
tf.requestSoftKeyboard(); 요렇게 사용자가 텍스트필드를 선택하지 않았을 때에도 키패드를 띄우는 메소드가 있다.
=================================
=================================
=================================
'ADOBE > ActionScript' 카테고리의 다른 글
ios air 네트워크 정보 NetworkInfo native extension sample ios 네트워크정도 air로 알아내기 주소, 맥어드레스 등등 (0) | 2020.09.22 |
---|---|
[AS] adobe 액션스크립트 소켓 타임 아웃 관련 (0) | 2020.09.22 |
ios swf 로드 관련 Flash Professional Help / Load external SWF into another SWF 관련 (0) | 2020.09.22 |
[AS] 액션스크립트 as3 web page refresh code PLEASE HELP!! (0) | 2020.09.22 |
ActionScript 개발 결제 air그리고 IOS, android 결제 관련 (0) | 2020.09.22 |