问题描述
在我的项目中,我想要使用actionscript 3获取存储在Flash中的形状/图形对象中的数据能够绘制一个形状,然后读取所有形状的点到我的脚本。原因是我需要从这些点生成线,我稍后可以用来检查我的角色速度是否与其中任何一个相交。
$ 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()
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
这篇关于如何从形状/图形对象读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!