Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Move graphics points at runtime?

Enthusiast ,
Aug 16, 2015 Aug 16, 2015

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.

TOPICS
ActionScript
278
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2015 Aug 16, 2015

what are you trying to change?  the transform/registration point?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 16, 2015 Aug 16, 2015

I want to change the shape points positions (to do some motion tween for the shape points)

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 16, 2015 Aug 16, 2015

the update every 25 milliseconds not 2..

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 16, 2015 Aug 16, 2015
LATEST

you can change the _points array values but that will not change the myShape graphics property.  you need to clear and redraw.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines