小编Joh*_*ele的帖子

为什么updateDisplayList在Flex中停止发生?

奖励:已被声明.

概述:代码给我提出了这个问题:http://www.johnuckele.com/MastersOfTime.html

我遇到的问题是,某些操作序列(我不完全理解如何或为什么)导致我对invalidateDisplayList的调用无法生成对updateDisplayList的后续调用.我所知道的是,在此期间,其他一些视觉效果将无法发生(例如更改组件的宽度或添加新的孩子).

示例:下面的程序绘制两列水平线.在commitProperties期间绘制左侧的列,在updateDisplayList期间绘制右侧的列.某一系列操作可能导致右列停止更新.

要触发此错误:首先添加一个新项目.现在点击开始按钮,一个栏开始填满.如果按添加行按钮,则右列和填充栏都会停止生长.左栏继续不受约束.直到TEComputeRow.tick()中if语句的最后一行不为帧执行时才会出现额外组件.单击停止按钮以停止执行TEComputeRow.tick()中if语句内的块,一切都恢复正常.

问题:这里发生了什么?

我现在可以通过使用验证来强制它行为,但它不能解决问题,它只是为了框架而覆盖它.它似乎也是一个非常草率的黑客.有没有比使用validateNow更好的方法来处理updateDisplayList的丢失?有没有办法准确地识别世界的状况?

MastersOfTime.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    backgroundColor="white"
    backgroundGradientAlphas="[1,1]"
    initialize="init()"
    enterFrame="tick()"
    creationComplete="addComputeArray()">
    <mx:Script>
        <![CDATA[
            import mx.containers.HBox;
            import mx.controls.Button;
            import mx.containers.VBox;
            import flash.utils.getTimer;
            private var global:int = 0;

            private function addComputeArray():void
            {
                var addButton:Button = new Button;
                addButton.label = "Add Row Item";
                addButton.addEventListener(MouseEvent.CLICK, addComputeBox);
                box.addChild(addButton);
            }

            private function addComputeBox(a:* = null):void
            {
                box.addChild(new TEComputeRow());
            }

            private function init():void
            {
                box.clipContent = false;
                box.graphics.lineStyle(1);
            }

            private function tick():void …
Run Code Online (Sandbox Code Playgroud)

apache-flex

1
推荐指数
1
解决办法
1678
查看次数

标签 统计

apache-flex ×1