Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 AS3-舞台的收缩至缩放手势_Actionscript 3_Flash_Adobe_Gesture - Fatal编程技术网

Actionscript 3 AS3-舞台的收缩至缩放手势

Actionscript 3 AS3-舞台的收缩至缩放手势,actionscript-3,flash,adobe,gesture,Actionscript 3,Flash,Adobe,Gesture,我正在创建一个工具,允许代表为我们的客户选择最好的产品。有人要求在移动设备上使用此工具。我想给用户选择捏放大,以便在小型设备上更合适地使用该设备 由于该工具的性质,我无法将该工具的内容放入电影剪辑中,并通过按压来缩放该电影剪辑。我在搜索一个工作AS3代码来收缩以缩放舞台(因此舞台上的内容)时,结果是空的 我确实在堆栈溢出上找到了以下代码: Multitouch.inputMode = MultitouchInputMode.GESTURE; stage.addEventListener(Tra

我正在创建一个工具,允许代表为我们的客户选择最好的产品。有人要求在移动设备上使用此工具。我想给用户选择捏放大,以便在小型设备上更合适地使用该设备

由于该工具的性质,我无法将该工具的内容放入电影剪辑中,并通过按压来缩放该电影剪辑。我在搜索一个工作AS3代码来收缩以缩放舞台(因此舞台上的内容)时,结果是空的

我确实在堆栈溢出上找到了以下代码:

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom); 
function onZoom (e:TransformGestureEvent):void{
  stage.scaleX *= e.scaleX;
  stage.scaleY *= e.scaleY; 
}
通过Adobe Animate进行测试时,会返回以下错误:

Error: Error #2071: The Stage class does not implement this property or method.
    at Error$/throwError()
    at flash.display::Stage/set scaleX()
    at Beta04_fla::MainTimeline/onZoom()[Beta04_fla.MainTimeline::frame501:5]
    at runtime::ContentPlayer/simulationSendGestureEvent()
    at runtime::SimulatedContentPlayer/clientSocketDataHandler()

有人能提供关于如何解决此问题的工作代码或建议吗?提前谢谢。

停止缩放阶段,这不是正确的方法

将内容移动到子movieclip而不是stage,然后缩放或仅使用位图:

你必须放大。 你应该先拍一张舞台快照, 意味着用你自己的变换矩阵(matrix.scale(2,2)),将整个舞台或舞台上想要的区域绘制成位图对象,然后将其切割成你喜欢的大小,并将其作为新的临时movieclip呈现给你的客户

var bitmapData:BitmapData = new BitmapData(stage.stageWidth, stage.stageHeight);
var matrix:Matrix = new Matrix();
matrix.translate(-50,-50); // moves your stage under magnifier
matrix.scale(3,3); // magnification
bitmapData.draw(stage, matrix);

// And to actually see it 
var bitmap:Bitmap = new Bitmap(bitmapData);
this.addChild(bitmap);


此外,如果希望平滑动画缩放,您可以在事件侦听器中使用步长变量更新位图,该变量会根据手指之间的距离影响矩阵的变化,而不是在我的代码中进行静态缩放

而不是缩放阶段,缩放文档类(主时间轴)。所以:
this.scaleX*=e.scaleX这成功了!我当然是个业余的编码爱好者,但即便如此,我还是觉得错过了这个很愚蠢。谢谢你的帮助。我很感谢你的回答,但正如我所说的,把这个工具放到电影剪辑中是有问题的@这提供了一个以上有效的答案,尽管你的答案也可能有效。再次感谢您的回复。