Copy link to clipboard
Copied
Hello, how to get the graphics points and change the values of its x&y at runtime?
for example:
var moveToX:Array = [50, 200];
var moveToY:Array = [0, 0];
var lineToX:Array = [100, 0, 50, 250, 150, 200];
var lineToY:Array = [100, 100, 0, 100, 100, 0];
var _points:Array = [];
var linesIndex:int = 0;
var myShape:Shape = new Shape();
myShape.graphics.lineStyle(3, 0x000000, .2);
myShape.graphics.beginFill(0x666666, .1);
for (var i:uint = 0; i< moveToX.length; i++)
{
var _point:Point = new Point(moveToX, moveToY);
_points.push(_point);
}
for (var p:uint = 0; p< _points.length; p++)
{
myShape.graphics.moveTo(_points
.x, _points
.y);
myShape.graphics.lineTo(lineToX[linesIndex], lineToY[linesIndex]);
myShape.graphics.lineTo(lineToX[linesIndex+1], lineToY[linesIndex+1]);
myShape.graphics.lineTo(lineToX[linesIndex+2], lineToY[linesIndex+2]);
linesIndex +=3;
}
myShape.x = 0;
myShape.y = 0;
addChild(myShape);
// Now I want to change the points values and update the shape at runtime, but what I am looking for is NOT to clear and redraw it again.. I am trying to apply the changes directly to the same shape because it has a lot of points and lines as the update will be every 2 milliseconds..
So can you help please? Thnaks.
Copy link to clipboard
Copied
what are you trying to change? the transform/registration point?
Copy link to clipboard
Copied
I want to change the shape points positions (to do some motion tween for the shape points)
Copy link to clipboard
Copied
the update every 25 milliseconds not 2..
Copy link to clipboard
Copied
you can change the _points array values but that will not change the myShape graphics property. you need to clear and redraw.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now