Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It really depends what you are trying to do with the vertices, but this should get you started.</p> <p>Here is some code I've used in the past to retrieve vertex info from shapes on the stage:</p> <pre><code>// Trace Vertex Information - Andrew Doll // http://www.andrewdollanimation.com/ // Clear the output panel. fl.outputPanel.clear(); var dom = fl.getDocumentDOM(); var tl = dom.getTimeline(); var foundMovieClips = false; var layer; var frame; var element; var vertices = []; var movieClips = []; var newLine = "\r\n"; var lockStatus; // grab layers var layers = tl.layers; // layer loop for (var i = 0; i &lt; layers.length; i++) { layer = layers[i]; // Check if the layer is locked. lockStatus = layer.locked; if (lockStatus) { layer.locked = false; } // Frame loop for (var j = 0; j &lt; layer.frames.length; j++) { frame = layer.frames[j]; // Element loop for (var k = 0; k &lt; frame.elements.length; k++) { element = frame.elements[k]; element.selected = true; // Only check elements that are shapes. if (element.elementType == 'shape') { vertices = element.vertices; var vertArray = []; // Vertice loop for (var l = 0; l &lt; vertices.length; l++) { // Push the x and y coordinates of the vertices to the vertArray. vertArray.push(' x: ' + vertices[l].x + ' y: ' + vertices[l].y); } // Trace the vertex count per frame. fl.trace('The vertex count of frame ' + (j + 1) + ' on ' + layer.name + ' is: ' + vertices.length + newLine); for (var m = 0; m &lt; vertArray.length; m++) { // Trace the vertex locations. fl.trace('Vertex ' + (m + 1) + ' on frame ' + (j + 1) + ' is located at: ' + vertArray[m]); } } else if (element.elementType == 'instance') { // If a movie clip is found add it to the movie clips array. foundMovieClips = true; movieClips.push(element.libraryItem.name); } } if (foundMovieClips) { foundMovieClips = false; fl.trace('LAYER: ' + layer.name + ' FRAME: ' + (j + 1) + ' SYMBOL: ' + movieClips[j]); } } } </code></pre> <p>The code above will run through the frames on all layers of the main timeline and trace out the vertex count of each frame, and if it encounters a movieclip instead of a shape it will trace out the name of the movie clip. As well as tracing out the vertex count it will also trace out the X and Y coordinate of each vertex on the shape elements if finds on each frame.</p> <p>Going further you could use the JSFL method: <a href="http://help.adobe.com/en_US/flash/cs/extend/WS5b3ccc516d4fbf351e63e3d118a9024f3f-77c3.html" rel="nofollow">vertex.setLocation()</a> to run through the array of vertex objects and move them around to a new X and Y if that is what you are wishing to do. Again, it really depends on what you are trying to do with the vertices in the end, but this should get you started. Hope you find this answer helpful.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload