关于FXG Path元素与DisplayObject.graphics是否支持抬笔命令的问询
Answer to Your FXG & DisplayObject.graphics Pen Lift Question
Great question! Let’s break this down clearly since you’re familiar with SVG’s path commands and want to map that to FXG and Flash’s DisplayObject.graphics API:
FXG Path Elements
Absolutely, FXG’s Path element supports pen lift functionality, and it works almost identically to SVG’s path commands.
- The
Mcommand (e.g.,M 0 0) you mentioned is exactly the pen lift command here. It tells the renderer to "lift" the pen and move it to the specified (x,y) coordinate without drawing any line in between. - You can also use the lowercase
mcommand for relative positioning:m 10 20will lift the pen and move it 10 units right and 20 units down from the current position, no line drawn. - After using
M/m, commands likeL(line to) will start drawing again from the new position, just like in SVG.
DisplayObject.graphics API
Yes, this API also supports pen lift operations—though instead of string-based commands, it uses method calls:
- The
moveTo(x, y)method is the direct equivalent of SVG/FXG’sMcommand. Calling it lifts the pen and moves it to the target (x,y) coordinate without rendering any path. - Once you’ve used
moveTo(), methods likelineTo(x, y),curveTo(), ordrawCircle()will start drawing from that new position. - To create disconnected paths, just call
moveTo()again to lift and reposition the pen before starting a new segment.
Here’s a quick ActionScript example to illustrate:
// Create a new Shape to draw on var myShape:Shape = new Shape(); myShape.graphics.lineStyle(2, 0x0000FF); // Set line style // First path segment: lift pen to (0,0), draw line to (0,100) myShape.graphics.moveTo(0, 0); myShape.graphics.lineTo(0, 100); // Lift pen to (50,50), draw line to (150,50) (disconnected from first segment) myShape.graphics.moveTo(50, 50); myShape.graphics.lineTo(150, 50); addChild(myShape); // Add to display list
Quick Summary
Both FXG Path elements and DisplayObject.graphics support the pen lift/move functionality you’re looking for. The core logic matches SVG’s path behavior—just with different syntax:
- FXG uses path string commands (
M/m) - DisplayObject.graphics uses the
moveTo()method
内容的提问来源于stack exchange,提问作者1.21 gigawatts
相关产品推荐
相关产品推荐

