簡體   English   中英

AS3 Apache Flex:在鼠標移動之前隨機單擊不更新階段

[英]AS3 Apache Flex: click randomly not updating stage until mouse moves

我有一個SWF,它將一個星場顯示為添加到舞台的單個BITMAP。 該圖像是通過位圖的BitmapData動態生成的,以允許軌跡球與星空交互。 行星和其他按鈕也在舞台上,下方帶有提示標簽。

所有工作均按預期進行。 但是,有時單擊一個按鈕會執行一項操作,直到鼠標移動才會顯示該操作。 例如,單擊按鈕切換行星標簽,將立即打開和關閉標簽來更新舞台。 但是有時,單擊不執行任何操作,直到移動鼠標或再次單擊,然后連續激活兩次單擊。

按鈕重置星形字段以顯示“太陽到地球”或“地球到太陽”視圖時也是如此。 單擊圖像(按鈕),背景星域立即更新。 但是,有時直到鼠標移動它什么都不做。 似乎是接口計時問題超出了我的控制范圍。

有人遇到這種情況嗎? 在Firefox上使用MAC,所有最新更新。

這是事件代碼。

private function moveRespond(e:MouseEvent):void {
    var X:int=mouseX,Y:int=mouseY,R:int=Assets.Assets.radius/10; if(R<15){R=15}
    if( moveActive ) {
        Assets.Assets.STUFF.view.rotateMatrix(PT.x,PT.y,X,Y);
        FIELD.update(w,h);
        }
    else {
        Assets.Assets.STUFF.line.hover(X,Y,R);
        var btn:Vector.<Button>=Assets.Assets.BTN_list;
        var i:int,I:int=btn.length;
        for( i=0; i<I; i++ ) {
            btn[i].label.visible=btn[i].hover(X,Y);
        }   }
    DP.x=PT.x-X; PT.x=X;
    DP.y=PT.y-Y; PT.y=Y;
    }
private function upRespond(e:MouseEvent):void { moveActive=false }
private function downRespond(e:MouseEvent):void { moveActive=true;
    var X:int=mouseX,Y:int=mouseY;
    PT.x=X; PT.y=Y;
    }
private function clickRespond(e:MouseEvent):void {
...
//lots of button management, similar to above
//FIELD.update(w,h); and new zodiac sign fetch...
//but if there was a soft error in here,
//then the click at the end would get skipped,
//and it doesnt.
...
    if( click ) { Assets.Assets.soundClick(X); }
    }

由於錯誤的隨機性,我假設內存在我的代碼中的某個地方發生混亂,正在中斷下一個事件,但是由於未單擊事件是事件排隊的,因此有點希望它出現通信問題。 它只是直到移動或再次單擊后才發送到我的應用程序。 App.swf可以在沒有包裝器(基本上是預加載器)的情況下運行,並且具有相同的隨機性。 即使非常罕見,也仍然很煩人。

還有一個ConstantUpdate計時器:

public function constantUpdate(evt:TimerEvent):void {
    Mouse.hide(); Mouse.show();
    dateMessage();
    if( !Assets.Assets.BTN_help.glowing && Math.random()<0.05 ) { Assets.Assets.BTN_help.glow(); }
    if( !Assets.Assets.BTN_logo.glowing && Math.random()<0.01 ) { Assets.Assets.BTN_logo.glow(); }
    if( !Assets.Assets.BTN_next.glowing && Math.random()<0.05 ) { Assets.Assets.BTN_next.glow(); }
    Assets.Assets.BTN_help.update();
    Assets.Assets.BTN_logo.update();
    Assets.Assets.BTN_next.update();
    Assets.Assets.BTN_star.update();
    Assets.Assets.BTN_note.update();
    Assets.Assets.BTN_moon.update();
    }

只是更多的按鈕管理。 禁用contextMenu后,鼠標隱藏/顯示ping鼠標。 否則,鼠標會變成contextMenu上的箭頭,並保持該狀態,直到鼠標離開窗口並返回為止。 雖然在啟動時仍然有一些鼠標提示音-加載App.swf之后未設置光標。 不知道這是否與點擊問題有關,但這是該代碼:

var cursor:MouseCursorData=new MouseCursorData();
    cursor.hotSpot=new Point(
        Assets.Assets.BTN_sun.icon.width/2,
        Assets.Assets.BTN_sun.icon.height/2);
    var pointer:Vector.<BitmapData>=new <BitmapData>[Assets.Assets.BTN_sun.icon.bitmapData];
    cursor.data=pointer;
    Mouse.registerCursor("myCursor",cursor);
    Mouse.cursor="myCursor";

我不保留光標對象的本地句柄。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM