2011-07-01 3 views
0

私は、AIR 2.7(およびFlash Builder 4.5.1)でFlex 4.5.1を使用して、Blackberryプレイブック用のアプリケーションを構築しています。フレックス4.5モバイルソフトキーボードアクティブ化イベントでアニメーションを使用してテキストエリアのサイズを変更しますか?

アプリには、ソフトキーボードが表示されたときにサイズを変更する必要がある大きなテキストエリアがあります。私は、ソフトキーボードのイベントにフックして、そこにいることができます。

キーボードが表示されたときに、画面の残りの部分に合わせてテキストエリアのサイズを変更します。私は現在と宛先のサイズを知っていて、滑らかなアニメーションを使ってテキストエリアのサイズを変更したいと思っています。 (私はすでに高さを設定することはできませんし、keyboard_activatingイベントでテキスト領域が正しくサイズ変更されているのを見ることができますが、アニメーションでそれをやりたいのです)。私はAnimateクラス、spark.effects.Moveクラスを使用しようとしましたが、どれもこの場合には動作しません。彼らはアニメーションを実行するようだが、画面がリフレッシュされません!

私は、ViewNavigatorApplicationに組み込みのresizeAppForKeyboardプロパティを使用したくありません。私はアプリディスクリプタに 'none'を設定して、その一部が正常になるようにしました。

アイデアやアイデアはありますか?私のアプローチはまったく正しいのですか?キーボードのアクティブ化イベントでアニメーションを使用してテキストエリアのサイズを変更するにはどうすればよいですか?私のコードのようになります。メインビュー(onCreationCompleteイベント)で

:(txNoteが問題のテキストエリアである)

txNote.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, function(e:SoftKeyboardEvent):void { 
    toggleEditMode(true); 
}); 

txNote.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, function(e:SoftKeyboardEvent):void { 
    toggleEditMode(false); 
}); 

private function toggleEditMode(keyboardActivated:Boolean):void { 
    trace("toggle edit: " + editMode + ", kb activating: " + keyboardActivated + ", txNote height = " + txNote.height); 

    editMode = keyboardActivated; 

    //we handle resize manually, because we want a nice animation happening and we want to resize only the text area - nothing else. 
    var y:Number = editMode ? -38 : 0; 
    var height:Number = editMode ? 218 : 455; 
    txNote.moveAndSize(y, height); 
} 

txNote.moveAndSizeのコード:

public function moveAndSize(newY:Number, newHeight:Number):void { 

//parent group uses BasicLayout 
//(this.parent as Group).autoLayout = false; 
//resizePath.valueFrom = this.height; 
//resizePath.valueTo = newHeight; 

//movePath.valueFrom = this.y; 
//movePath.valueTo = newY; 

//resizeEffect.heightFrom = this.height; 
//resizeEffect.heightTo = height; 

    this.top = newY; 
    moveEffect.xFrom = this.x; 
    moveEffect.xTo = this.x; 

    moveEffect.yFrom = this.y; 
    moveEffect.yTo = newY; 

    moveEffect.end(); 
    moveEffect.play([ this ]); 

    //this.move(x, newY); 
    //animate.play([ this ]); 

    //this.height = height; 
    //this.y = y; 

    //setLayoutBoundsSize(width, height); 
    //setLayoutBoundsPosition(x, y); 
} 

moveEffect /試した様々なことをmovePath/animateは、次のようにtxNoteコンストラクタで設定されます:

public class NotesArea extends TextArea { 
//  private var animate:Animate; 
//  private var movePath:SimpleMotionPath; 
//  private var resizePath:SimpleMotionPath; 

     private var moveEffect:Move; 
//  private var resizeEffect:Resize; 

     public function NotesArea() { 
      super(); 

//   animate = new Animate(); 
//   var paths:Vector.<MotionPath> = new Vector.<MotionPath>(); 
//   movePath = new SimpleMotionPath("top"); 
//   resizePath = new SimpleMotionPath("height"); 
//   paths.push(movePath); 
      //paths.push(resizePath); 

//   animate.duration = 300; 
//   animate.motionPaths = paths; 

//   animate.addEventListener(EffectEvent.EFFECT_UPDATE, function(e:EffectEvent):void { 
//    trace("y = " + y); 
//    invalidateDisplayList(); 
//   }); 
//   animate.addEventListener(EffectEvent.EFFECT_END, function(e:EffectEvent):void { 
//    trace("EFFECT ended: y = " + y); 
//   }); 

      moveEffect = new Move(); 
      moveEffect.duration = 250; 
      moveEffect.repeatCount = 1; 
      moveEffect.addEventListener(EffectEvent.EFFECT_END, function (e:EffectEvent):void { 
       //(this.parent as Group).autoLayout = true; 
       trace("move effect ran. y = " + y + ", top = " + top); 
      }); 

      //this.setStyle("moveEffect", moveEffect); 
// 
//   resizeEffect = new Resize(); 
//   resizeEffect.duration = 250; 
//   this.setStyle("resizeEffect", resizeEffect); 
     } 

} 

答えて

0
yourTextField.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_DEACTIVATE, onActivating); 
yourTextField.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATING, onActivating); 
yourTextField.addEventListener(SoftKeyboardEvent.SOFT_KEYBOARD_ACTIVATE, onActivating); 

// in the event listener to the textField IE : 

private function onActivating(event:SoftKeyboardEvent):void 
{ 
    //listen to the event; make your move here. 
} 
+0

ありがとう、私はすでにそれを働いていた - しかし、あなたが正しい答えを投稿したので... :) – Krishna

関連する問題