2013-04-17 60 views
0

[編輯] 請參閱代碼。 我可以加載圖像,我可以加載影片剪輯。圖像放大和平移到用戶輸入。但影片剪輯(mcInfo)需要「附加」到圖像上的某個點,以確保它能夠縮放和平移圖像。 原因是因爲圖像是由大量不同產品組成的大型灌溉設施。信息圖標(mcInfo)應該是可點擊的動畫片段,以顯示該產品的信息。 圖像上會有很多這些圖標。但它必須與用戶想要查看的產品相關聯。您可以將動畫片段鏈接到Actionscript 3中外部加載的圖像上的某個點嗎?

var spImage:Sprite = new Sprite(); //load image to sprite "I think" 
board.addChild(spImage);  

function initPic(e:Event):void { 
     infoBox.text = ""; 
     infoBox.visible = false; 
     image = Bitmap(loader.content); 
     minScale = boardWidth/image.width; 
     image.scaleX = minScale; 
     image.scaleY = minScale; 

     spImage.addChild(image);// the loaded image 
     spImage.addChild(mcIn); // custom zoom in cursor 
     spImage.addChild(mcOut); // custom zoom out cursor 
     spImage.addChild(mcInfo); //information icon. This is the movieclip that I need to set at a point 

     spImage.addEventListener(MouseEvent.MOUSE_DOWN, startDragging); 
     stage.addEventListener(MouseEvent.MOUSE_UP, stopDragging); 

     loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, initPic); 
     loader.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS, updateInfo); 
     loader = null; 

     board.filters = [ new DropShadowFilter() ]; 
     spImage.addEventListener(MouseEvent.CLICK, zoom); 
} 

回答

0

把你的加載圖像的Sprite內,然後添加所需的DescriptionObject徘徊無論你想的一樣Sprite內。從現在開始,請對Sprite執行所有縮放和平移操作,而不是加載的圖像。 觸發loaded.contentLoaderInfoEvent.COMPLETE事件時,您的圖像變得完全可用。 initPic函數做到:

theSprite.addChild(event.target.content) //adds your image to the Sprite object 
theSprite.addChild(description); 
description.x = 100; 
description.y = 200; 
+0

var spImage:Sprite = new Sprite(); board.addChild(spImage); – Deon

+0

請參閱修訂後的問題 – Deon

+0

您能否提出問題陳述?在最後?:) 我不完全明白你的問題是什麼。 – SzRaPnEL

相關問題