我在製作放大鏡應用程序,需要一些幫助。目前,我有以下代碼:Flex「放大鏡」/掩蔽
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="init()">
<mx:Script>
<![CDATA[
// This code assumes it's being run within a display object container
// such as a MovieClip or Sprite instance.
import flash.display.GradientType;
import flash.display.Loader;
import flash.display.Sprite;
import flash.geom.Matrix;
import flash.net.URLRequest;
private function init():void {
// Load an image and add it to the display list.
var loader:Loader = new Loader();
var url:URLRequest = new URLRequest("images/ZionsMap.png");
loader.load(url);
this.stage.addChild(loader);
// Create a Sprite.
var oval:Sprite = new Sprite();
// Draw a gradient oval.
/* var colors:Array = [0x000000, 0x000000];
var alphas:Array = [1, 0];
var ratios:Array = [0, 255];
var matrix:Matrix = new Matrix();
matrix.createGradientBox(200, 100, 0, -100, -50);
oval.graphics.beginGradientFill(GradientType.RADIAL,
colors,
alphas,
ratios,
matrix); */
oval.graphics.beginFill(0xFFFFFF,1.0);
oval.graphics.drawEllipse(-200, -50, 200, 200);
oval.graphics.endFill();
// add the Sprite to the display list
this.stage.addChild(oval);
// Set cacheAsBitmap = true for both display objects.
//loader.cacheAsBitmap = true;
//oval.cacheAsBitmap = true;
// Set the oval as the mask for the loader (and its child, the loaded image)
loader.mask = oval;
// Make the oval draggable.
oval.startDrag(true);
}
]]>
</mx:Script> </mx:Application>
但我不確定如何有超過「在」圖像縮放頂部的縮小「走出去」的形象。當前可拖動蒙版將通過縮小圖像顯示放大圖像。有小費嗎?
感謝您的迴應!這將適用於我所需要的!你有沒有得到該應用程序的工作?我試過這個例子,它不會爲我加載。 – Eponine 2011-03-19 00:52:20
嘿,我創建了一個新的Flex項目(使用sdk 3.2,但我認爲3.5也可以),並將他的mxml文件的內容複製/粘貼到我的主應用程序文件中 - 沒有任何probs。不要複製整個mxml文件,只是其內容 – Ryan 2011-03-22 11:41:41
嗨,布賴恩,我想打開您在答案中提供的鏈接,但我無法打開源代碼。它會給出錯誤請求(無效主機名)的錯誤。所以請幫助我。我在FLEX中更新,並開發該應用程序。請幫幫我。提前致謝。 – 2012-02-27 09:27:18