我正在爲Blackberry Playbook開發ActionScript 3.0應用程序。等待,直到兩個圖像之間的轉換完成
我有12個加載了Loader類的圖像。我用Event.ENTER_FRAME褪色的方法,使用此事件處理淡出圖片:
private function onEnterFrame(event:Event):void
{
imageToFront.alpha += 0.1; // slow fade
imageToBack.alpha -= 0.1;
if(imageToFront.alpha >= 1.0)
{
imageToFront.alpha = 1.0;
// hide the first image
imageToBack.alpha = 0.0;
imageToBack.visible = false;
// remove the enter frame event listener
stage.removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
當圖像的用戶點擊它拋出以下click處理程序:我有以下問題
private function onImageClicked(event:MouseEvent):void
{
switch((event.currentTarget as Loader).name)
{
case imageCell11Back.name:
imageToFront = imageCell11Front;
imageToBack = imageCell11Back;
break;
case imageCell11Front.name:
imageToFront = imageCell11Back;
imageToBack = imageCell11Front;
break;
case imageCell12Back.name:
imageToFront = imageCell12Front;
imageToBack = imageCell12Back;
break;
case imageCell12Front.name:
imageToFront = imageCell12Back;
imageToBack = imageCell12Front;
break;
case imageCell13Back.name:
imageToFront = imageCell13Front;
imageToBack = imageCell13Back;
break;
case imageCell13Front.name:
imageToFront = imageCell13Back;
imageToBack = imageCell13Front;
break;
case imageCell21Back.name:
imageToFront = imageCell21Front;
imageToBack = imageCell21Back;
break;
case imageCell21Front.name:
imageToFront = imageCell21Back;
imageToBack = imageCell21Front;
break;
case imageCell22Back.name:
imageToFront = imageCell22Front;
imageToBack = imageCell22Back;
break;
case imageCell22Front.name:
imageToFront = imageCell22Back;
imageToBack = imageCell22Front;
break;
case imageCell23Back.name:
imageToFront = imageCell23Front;
imageToBack = imageCell23Back;
break;
case imageCell23Front.name:
imageToFront = imageCell23Back;
imageToBack = imageCell23Front;
break;
}
stage.addEventListener(Event.ENTER_FRAME, onEnterFrame);
imageToFront.visible = true;
}
:
如果用戶在上一張圖片尚未達到alpha = 1.0之前點擊另一張圖片,則該圖片的alpha值會小於1.0。
換句話說,我不得不讓onEnterFrame
功能設置alpha爲1.0。
任何想法?我試過stage.hasEventListener(Event.ENTER_FRAME)
但它不起作用。
我有同樣的問題,如果我點擊一個圖像使淡出,然後我點擊另一個圖像,使其淡出。 – VansFannel 2011-03-18 16:20:28