동적 텍스트를 "듣는"방법이 있습니까? 스테이지에이 동적 텍스트 필드가 있고 동적 텍스트가 변경되면 함수를 호출하려고합니다. 이벤트 리스너를 추가하려고했지만 INPUT 텍스트에서만 작동하는 것 같습니다. 어떤 제안? 감사합니다.actionscript 3 트랙 동적 텍스트 변경
답변
CHANGE
이벤트를 시도 했습니까? 비 입력 텍스트 필드를 포함한 모든 유형의 TextField에 대해 작동해야합니다.
이 질문에서 알 수 있듯이 입력 텍스트 만 CHANGE 이벤트를 전달합니다. http://stackoverflow.com/questions/977847/as3-textbox-change-event-not-firing – annonymously
입력 텍스트 만 CHANGE 이벤트를 전달합니다. 당신은 아마 다음과 같이 그것을 해결해야합니다 :
는 @ annonymously의 응답 작품 (그 문제에 대한, 또는 변경) 텍스트의 변화를 기다릴를 enterFrame 리스너를 부착은 좋은 생각이 아니다var oldText:String = "";
function changeEnterFrame (e:Event) {
if (oldText != textField.text) {
// Do your stuff here
}
oldText = textField.text;
}
addEventListener(Event.ENTER_FRAME, changeEnterFrame);
동안 - 텍스트가 전혀 변경되지 않을 수도 있습니다. 그러면 피할 수 있다면 초당 여러 번 코드를 실행해야하는 이유는 무엇입니까? 사실, 당신이 모니터하고 싶은 각각의 새로운 텍스트 필드 인스턴스에 대해 반복해서해야 할 필요는 없습니다.
실제 변경 사항에 반응하는 것이 더 좋으며, 이는 사용자가 설정 한 속성으로 인해 발생합니다. 당신은 단순히 TextField 클래스를 확장하고 재정의 세터의 htmlText 및/또는 텍스트에 대 한 변경 이벤트를 파견해야
override public function set text (text : String) : void {
super.text = text;
dispatchEvent (new Event (Event.CHANGE);
}
알겠습니다, 감사합니다. 다른 모든 도우미들에게도 감사드립니다. – jazz
당신은 당신이 텍스트 변경 이벤트를들을 수 있습니다 매우 간단한 서브 클래스를 작성할 수 있습니다.
Sublass :
package
{
import flash.events.Event;
import flash.text.TextField;
public class CustomTextField extends TextField
{
public function CustomTextField()
{
super();
}
override public function set text(value:String):void
{
if(super.text != value)
{
super.text = value;
dispatchEvent(new Event(Event.CHANGE, true));
}
}
}
}
사용 예 :
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
public class CustomTextFieldTest extends Sprite
{
private var tf:CustomTextField;
public function CustomTextFieldTest()
{
tf = new CustomTextField();
tf.x = tf.y = 10;
tf.width = tf.height = 200;
tf.addEventListener(Event.CHANGE, onTfChange);
addChild(tf);
stage.addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
}
private function onTfChange(e:Event):void {
trace("text changed, new text: '" + tf.text + "'");
}
private function onMouseDown(e:MouseEvent):void {
tf.text = "some random text: " + Math.round(100 * Math.random());
}
}
}
죄송합니다, @ weltraumpirat의 답변을 놓쳤습니다 :) – skozin
- 1. 여러 트랙 믹싱 및 재생 Actionscript 3
- 2. Actionscript 3 및 동적 마스크
- 3. Flash Actionscript 3 숫자를 동적 텍스트 필드에 전달
- 4. 트랙 변경
- 5. Flash CS5.5에서 Actionscript 3 Android/iOS 용 Actionscript 3
- 6. Actionscript-3 네임 스페이스 및 동적 유형?
- 7. ActionScript 3 스크롤 문제
- 8. 깜박임없이 ActionScript 3에서 동적 인 그림 변경
- 9. ActionScript 3 작업 영역 크기 변경
- 10. Adobe CS3 ActionScript 3 버튼 그래픽 변경
- 11. ActionScript-3에서 하나의 UILoader 내의 동적 텍스트
- 12. Actionscript 3 Label 구성 요소 텍스트 수정
- 13. 트랙 변경 ms 단어
- 14. actionscript 2 to actionscript 3
- 15. actionscript 3 sleep?
- 16. 스크롤 카운터? actionscript 3
- 17. 여왕 백 트랙 (n 변경)
- 18. ActionScript 3.0의 동적 변수
- 19. Dynamic Audio Generation Actionscript 3
- 20. 액션 스크립트 3 : 애니메이션 동적 텍스트 인스턴스의 텍스트 설정
- 21. Actionscript 3 htmlText의 TextField 버그?
- 22. Actionscript 3 3d with fieldofview
- 23. WPF MediaElement, 오디오 트랙 변경
- 24. SQL 2008 FTS 트랙 변경
- 25. Actionscript 3 Actionscript를 사용하여 TextField에 중국어 기호로드
- 26. ActionScript 2.0의 동적 정렬
- 27. ActionScript 동적 클래스
- 28. ActionScript 3 및 글꼴 임베드
- 29. ActionScript 2 - ActionScript 3 : 공통 하위 집합?
- 30. Actionscript 3 디버그 로깅
가능한 중복 : 사실 http://stackoverflow.com/questions/977847/as3-textbox-change-event-not-firing – annonymously