[英]TextArea scrolling pauses timerEvent
我有一個TimerEvent,它使形狀的alpha每秒改變一次:
private function changeLightStatus(e:TimerEvent):void{
if (boolFlashOn == false){
light.alpha = 1;
boolFlashOn = true;
}else{
light.alpha = 0.5;
boolFlashOn = false;
}
沒問題,它工作正常,但是下面有一個<s:TextArea/>
,當用戶滾動它時,計時器暫停,形狀停止閃爍。
我查看了其他問題,並回答說要創建新的時間線程,以使它們不連接,但顯然我無法在Flash Builder中執行此操作(如果我輸入錯了,請糾正我)。
提前致謝
我已經更新了您的標簽,使其包含Flex,但不幸的是,我只使用過純AS3(沒有Flex標簽)。
因此,在等待更好的答案時,您可以嘗試...
(1)
當您添加light.mouseChildren = light.mouseEnabled = false;
addChild(light)
,還設置為: light.mouseChildren = light.mouseEnabled = false;
。
(2)
否則考慮使用EnterFrame
而不是Timer
:
//# add to initial setup of vars...
var counter:int = 0;
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
然后添加輔助功能
private function onEnterFrame (e:Event) : void
{
if ( count >= 50)
{
if (boolFlashOn == false)
{ light.alpha = 1; boolFlashOn = true; }
else
{ light.alpha = 0.5; boolFlashOn = false; }
count = 0; //reset for next loop
}
count++
}
讓我知道事情的后續...
作為使用文本區域的替代方法,我進行了以下操作:
<s:Group width="{this.width*0.8}" height="{this.height*0.175}" top="{this.height*0.475}" horizontalCenter="0">
<s:Rect left="0" right="0" top="0" bottom="0">
<s:fill>
<s:SolidColor color="0xFFFFFF"/>
</s:fill>
</s:Rect>
<s:Scroller>
<s:Group width="{this.width*0.8}" height="{this.height*0.175}" top="{this.height*0.475}" horizontalCenter="0">
<s:Label id="lblInfo" color="0x000000" width="{this.width*0.8}"/>
</s:Group>
</s:Scroller>
</s:Group>
這創建了一個非常基本的框,用戶可以在其中滾動文本並且不會影響我的timerEvent。
我仍然想知道textArea暫停時間軸的原因。 我舉了一個非常簡單的例子:
<?xml version="1.0" encoding="utf-8"?>
<fx:Script>
<![CDATA[
private var tmrTest : Timer = new Timer(100);
private var boolTest : Boolean = false;
private function init():void{
tmrTest.addEventListener(TimerEvent.TIMER, testChange)
tmrTest.start();
}
private function testChange(e:TimerEvent):void{
if (boolTest == false){
btnTest.label = "Bye";
boolTest = true;
}else{
btnTest.label = "Hi";
boolTest = false;
}
}
]]>
</fx:Script>
<s:Button id="btnTest" label="Hi" width="{this.width*0.5}" height="{this.height*0.1}"/>
<s:Group width="{this.width*0.8}" height="{this.height*0.175}" top="{this.height*0.475}" horizontalCenter="0">
<s:Rect left="0" right="0" top="0" bottom="0">
<s:fill>
<s:SolidColor color="0xFFFFFF"/>
</s:fill>
</s:Rect>
<s:Scroller>
<s:Group width="{this.width*0.8}" height="{this.height*0.175}" top="{this.height*0.475}" horizontalCenter="0">
<s:Label color="0x000000" width="{this.width*0.8}"
text="{'a\nb\nc\nd\ne\nf\ng'}"/>
</s:Group>
</s:Scroller>
</s:Group>
<s:TextArea width="{this.width*0.8}" height="{this.height*0.175}" top="{this.height*0.725}" horizontalCenter="0" editable="false"
text="{'a\nb\nc\nd\ne\nf\ng'}"/>
我可能之前應該提到過,它是在iPhone而不是模擬器上運行的。 模擬器沒有給我任何問題,我也沒有嘗試過android。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.