1
我有一個圖像庫加載一個細節圖像,然後根據圖像尺寸在圖像的一側繪製一條線。點擊圖像返回到主圖像縮略圖列表,然後單擊一個拇指將另一圖像加載到詳細信息持有者中。一切正常,除了線條,而不是消失在細節圖像卸載,積累。有沒有辦法清除lineDrawing MovieClip中的內容而無需將其從舞臺上移除,以便我可以在其中繪製一條新線?我已經嘗試過MovieClip上的removeChild,但是線條完全消失,與在setupDetail函數頂部放置lineDrawing.clear()一樣。這是我的(相關的)代碼到目前爲止,任何援助將不勝感激,我很難過!從MovieClip中刪除內容(圖形線)
var detailImage:Loader = new Loader();
var lineDrawing:MovieClip = new MovieClip();
setupDetail();
function setupDetail():void {
detail.visible = false;
detail.buttonMode = true;
detail.closeMessage.mouseEnabled = false;
detail.addChild(detailImage);
detailImage.contentLoaderInfo.addEventListener(Event.COMPLETE, fullyLoaded);
// make sure detail is above the gallery
addChild(detail);
detail.addEventListener(MouseEvent.CLICK, onCloseDetail, false, 0, true);
}
function fullyLoaded(evt:Event):void {
var imgHeight:int = evt.target.content.height;
var imgWidth:int = evt.target.content.width;
var hOffset:int = imgWidth + 5 + 27;
var vOffset:int = imgHeight + 5;
detail.addChild(lineDrawing);
if(imgWidth == 600) {
lineDrawing.graphics.lineStyle(3,0x9a9345);
lineDrawing.graphics.moveTo(28,vOffset);
lineDrawing.graphics.lineTo(626,vOffset);
}
else if(imgHeight == 600) {
lineDrawing.graphics.lineStyle(3,0x9a9345);
lineDrawing.graphics.moveTo(hOffset, 1);
lineDrawing.graphics.lineTo(hOffset, 599);
}
}
function onCloseDetail(evt:MouseEvent):void {
// only allow it to be closed if it is at least 90% opaque
if (detailImage.alpha>.9){
detailImage.unload();
TweenLite.to(detail,.5, {autoAlpha:0});
detailImage.unload();
detail.visible = false;
}
}
哇哦,謝謝,這工作完全置於onCloseDetail功能。再次感謝!!! – 2010-07-31 17:00:56