本文介绍了如何从形状/图形对象读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



在我的项目中,我想要使用actionscript 3获取存储在Flash中的形状/图形对象中的数据能够绘制一个形状,然后读取所有形状的点到我的脚本。原因是我需要从这些点生成线,我稍后可以用来检查我的角色速度是否与其中任何一个相交。

解决方案 和AIR 3.6:

$ p $ flash.display.Grapics.readGraphicsData()





例子:

  var s:Shape = new Shape(); 
s.graphics.lineStyle(2,0xFF0000);
s.graphics.drawCircle(0,0,50)

var gd:Vector。< IGraphicsData> = s.graphics.readGraphicsData(false);

var copy_of_s:Shape = new Shape();
copy_of_s.graphics.drawGraphicsData(gd);

addChild(copy_of_s);






要使用新版本,您必须更新playerglobal.swc




I am wondering if it is possible to get the data that is stored in a shape/graphics object in flash using actionscript 3?

In my project I would like to be able to draw a shape and then read all the points in that shape into my script. The reason for that is that I need go generate lines from those points that I later can use to check if my characters velocity intersects with any of them.

解决方案

You can read all parts of Shape.

New feature added to Flash Player 11.6 and AIR 3.6:

flash.display.Grapics.readGraphicsData()

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#readGraphicsData%28%29

Example:

var s :Shape = new Shape();
s.graphics.lineStyle(2, 0xFF0000);
s.graphics.drawCircle(0, 0, 50)

var gd:Vector.<IGraphicsData> = s.graphics.readGraphicsData(false);

var copy_of_s :Shape = new Shape();
copy_of_s.graphics.drawGraphicsData(gd);

addChild(copy_of_s);


To use the new version, you have to update playerglobal.swc

http://www.adobe.com/support/flashplayer/downloads.html

这篇关于如何从形状/图形对象读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 12:20