Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 文本区域滚动暂停timerEvent_Actionscript 3_Apache Flex_Flash Builder - Fatal编程技术网

Actionscript 3 文本区域滚动暂停timerEvent

Actionscript 3 文本区域滚动暂停timerEvent,actionscript-3,apache-flex,flash-builder,Actionscript 3,Apache Flex,Flash Builder,我有一个TimerEvent,它使形状的alpha每秒都发生变化: private function changeLightStatus(e:TimerEvent):void{ if (boolFlashOn == false){ light.alpha = 1; boolFlashOn = true; }else{ light.alpha = 0.5; boolFlashOn = false;

我有一个TimerEvent,它使形状的alpha每秒都发生变化:

private function changeLightStatus(e:TimerEvent):void{
    if (boolFlashOn == false){
        light.alpha = 1;
        boolFlashOn = true;
    }else{
        light.alpha = 0.5;          
        boolFlashOn = false;
    }
没有问题,它工作正常,但我有一个
在下面,当用户滚动它时,计时器暂停,形状停止闪烁

我看了其他问题,答案是创建一个新的时间线程,这样它们就不会连接,但显然我不能在Flash Builder中这样做(如果我错了,请纠正我)


提前感谢

我已经更新了您的标签以包含Flex,但不幸的是,我只使用纯AS3(没有Flex标签)

所以当你等待更好的答案时,你可以试试

(1)
当您
addChild(light)
时,也设置为:
light.mouseChildren=light.mouseEnabled=false

(2)
否则考虑<代码> Engults<代码>,而不是<代码>定时器< /代码>:

//# 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"?>



我以前可能应该提到,这是在iPhone上运行的,而不是模拟器。模拟器没有给我任何问题,我也没有尝试过android。

“我有一个TimerEvent…没有问题,它工作正常”
,所以不要只是向我们展示工作的计时器代码。。。您的
鼠标悬停在
代码上时,会导致计时器停止、无声错误甚至崩溃。调试器怎么说?关于未定义或空变量的任何警告?没有鼠标悬停代码。我正在使用一个标准,如果有太多的文本,它会滚动。当我滚动时,计时器停止事件。调试器中没有错误、崩溃和任何内容。一旦我停止滚动,它就会再次运行。此外,我还提供了计时器事件代码,以防任何人有其他方法作为解决方案。感谢VC的想法,但不幸的是没有运气。使用了两种想法,没有区别。我的猜测是,当文本区域被滚动时,它会暂停时间线。我想我需要一种在滚动开始后重新启动时间线的方法。我听到了,但这似乎仍然是一个奇怪的“功能”。可能是一个可能的错误。。。如果
灯位于其他位置(而不是文本上方),它是否仍会暂停?如果到今天晚些时候你还没有得到答案,我会尝试重现这个问题。实际上我有四盏灯,所有的灯都会亮起来。我已找到解决此问题的替代方法。如果出于某种原因,我使用滚动条(同样使用flex)创建一个组,滚动条不会影响时间线。不知道为什么。一旦我把它整理好,我会把它放在这里给其他人看。不过,找出textArea工作方式不同的原因还是很有意思的。只是将textArea的skinclass更改为spark组件,而不是手机,并且没有冻结计时器。所以我假设这是MobileSkinclass中使用的richEditableText组件的问题。如果我的研究是正确的,richEditableText实际上并不是这个阶段的一部分,它是分层的,这在过去给我带来了很多问题。
<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'}"/>