我正在制作放大镜应用,需要一些帮助。我目前有以下代码:
<?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>
但我不确定如何将放大的“out”图像放在缩放的“in”图像上方。当前可拖动的蒙版将通过缩小的图像显示放大的图像。有什么提示吗?
答案 0 :(得分:1)
只是一个指针:这个家伙制作了一个非常酷的放大镜,将其保存在我的Gmail帐户中供将来参考:
http://devsachinonflex.blogspot.com/2010/04/magnifying-glass-in-flex.html
答案 1 :(得分:1)
我为WordPress编写了一个放大镜插件。
(http://s.wordpress.org/extend/plugins/glass/screenshot-4.png)
您可以在我的博客http://codeblab.com/glass/上看到它的实际操作,其中还有一些文章解释了它的工作原理。如果您愿意,可以查看JavaScript代码,它是GPL。