[编辑] 请看代码。我可以加载图像,我可以加载影片剪辑。图像缩放并平移到用户输入。但是,movieclip (mcInfo) 需要“附加”到图像上的某个点,以确保它随图像一起缩放和平移。这样做的原因是因为该图像是一个由许多不同产品组成的大型灌溉装置。信息图标 (mcInfo) 应该是一个可点击的影片剪辑,以显示该产品的信息。图像上会有很多这样的图标。但它必须与用户想要查看的产品相关联。
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);
}