回答
那么有在柔性无虚线或点线。
但是,您可以创建自己的线条或边框: http://cookbooks.adobe.com/post_Creating_a_dashed_line_custom_border_with_dash_and-13286.html
尝试和享受!
无论如何,你不能,不仅仅是通过使用Flex库类。当然,你可以自己做。下面是实现它的类(从代码修改发现here,感谢肯·福克斯):
/*Copyright (c) 2006 Adobe Systems Incorporated
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
*/
package com.some.package {
import mx.graphics.IStroke;
import flash.display.Graphics;
public class GraphicsUtils {
public static function _drawDashedLine(target:Graphics, strokes:Array, pattern:Array,
drawingState:DashStruct,
x0:Number, y0:Number, x1:Number, y1:Number):void {
var dX:Number = x1 - x0;
var dY:Number = y1 - y0;
var len:Number = Math.sqrt(dX * dX + dY * dY);
dX /= len;
dY /= len;
var tMax:Number = len;
var t:Number = -drawingState.offset;
var patternIndex:int = drawingState.patternIndex;
var strokeIndex:int = drawingState.strokeIndex;
var styleInited:Boolean = drawingState.styleInited;
while(t < tMax) {
t += pattern[patternIndex];
if(t < 0) {
var x:int = 5;
}
if(t >= tMax) {
drawingState.offset = pattern[patternIndex] - (t - tMax);
drawingState.patternIndex = patternIndex;
drawingState.strokeIndex = strokeIndex;
drawingState.styleInited = true;
t = tMax;
}
if(styleInited == false) {
(strokes[strokeIndex] as IStroke).apply(target);
}
else {
styleInited = false;
}
target.lineTo(x0 + t * dX, y0 + t * dY);
patternIndex = (patternIndex + 1) % pattern.length;
strokeIndex = (strokeIndex + 1) % strokes.length;
}
}
public static function drawDashedLine(target:Graphics, strokes:Array, pattern:Array,
x0:Number, y0:Number, x1:Number, y1:Number):void {
target.moveTo(x0, y0);
var struct:DashStruct = new DashStruct();
_drawDashedLine(target, strokes, pattern, struct, x0, y0, x1, y1);
}
public static function drawDashedPolyLine(target:Graphics, strokes:Array, pattern:Array,
points:Array):void {
if(points.length == 0) { return; }
var prev:Object = points[0];
var struct:DashStruct = new DashStruct();
target.moveTo(prev.x, prev.y);
for(var i:int = 1; i < points.length; i++) {
var current:Object = points[i];
_drawDashedLine(target, strokes, pattern, struct,
prev.x, prev.y, current.x, current.y);
prev = current;
}
}
}
}
class DashStruct {
public function init():void {
patternIndex = 0;
strokeIndex = 0;
offset = 0;
}
public var patternIndex:int = 0;
public var strokeIndex:int = 0;
public var offset:Number = 0;
public var styleInited:Boolean = false;
}
而且你可以用它喜欢:
var points:Array = [];
points.push({ x: 0, y: 0 });
points.push({ x: this.width, y: 0 });
points.push({ x: this.width, y: this.height });
points.push({ x: 0, y: this.height });
points.push({ x: 0, y: 0 });
var strokes:Array = [];
var transparentStroke:Stroke = new Stroke(0x0, 0, 0);
strokes.push(new Stroke(0x999999, 2, 1, false, 'normal', CapsStyle.NONE));
strokes.push(transparentStroke);
strokes.push(new Stroke(0x222222, 2, 1, false, 'normal', CapsStyle.NONE));
strokes.push(transparentStroke);
GraphicsUtils.drawDashedPolyLine(this.graphics, strokes, [ 16, 5, 16, 5 ], points);
该代码是版权2006 Adobe Systems Incorporated公司。原文在http://demo.quietlyscheming.com/dashes/srcview/index.html发表了博文。它是免费软件,但您必须保留归属。 – 2010-01-03 15:28:44
很感谢你的发现。 – rfunduk 2010-01-03 15:34:30
所以修复你的文章 – 2010-01-03 15:35:12
我跑过这个,今天,我很喜欢。提供虚线/虚线和其他一些东西(主要是曲线)。
http://flexdevtips.blogspot.com/2010/01/drawing-dashed-lines-and-cubic-curves.html
我做到这一点很简单:
public static function drawDottedLine(target:Graphics, xFrom:Number, yFrom:Number, xTo:Number, yTo:Number, dotLenth:Number = 10):void{
var isGap:Boolean;
target.moveTo(xFrom, yFrom);
xFrom += dotLenth;
for(xFrom; xFrom < xTo; xFrom += dotLenth){
if(isGap){
target.moveTo(xFrom, yFrom);
} else {
target.lineTo(xFrom, yFrom);
}
isGap = !isGap;
}
}
UPD::)用同样的方法在罗斯提供的链接。
该算法仅适用于水平虚线,根本不适用于垂直线(xFrom = xTo但yFrom!= yTo),并且根据斜率,点长度可能会改变 – 2013-08-14 12:31:24
我写了一些简单的代码DashedLine -
import flash.display.Graphics;
import spark.primitives.Line;
public class DashedLine extends Line
{
public var dashLength:Number = 10;
override protected function draw(g:Graphics):void
{
// Our bounding box is (x1, y1, x2, y2)
var x1:Number = measuredX + drawX;
var y1:Number = measuredY + drawY;
var x2:Number = measuredX + drawX + width;
var y2:Number = measuredY + drawY + height;
var isGap:Boolean;
// Which way should we draw the line?
if ((xFrom <= xTo) == (yFrom <= yTo))
{
// top-left to bottom-right
g.moveTo(x1, y1);
x1 += dashLength;
for(x1; x1 < x2; x1 += dashLength){
if(isGap){
g.moveTo(x1, y1);
} else {
g.lineTo(x1, y1);
}
isGap = !isGap;
}
}
else
{
// bottom-left to top-right
g.moveTo(x1, y2);
x1 += dashLength;
for(x1; x1 < x2; y2 += dashLength){
if(isGap){
g.moveTo(x1, y2);
} else {
g.lineTo(x1, y2);
}
isGap = !isGap;
}
}
}
}
然后使用它像这样 -
<comps:DashedLine top="{}" left="0" width="110%" >
<comps:stroke>
<s:SolidColorStroke color="0xff0000" weight="1"/>
</comps:stroke>
</comps:DashedLine>
- 1. WinAPI - 如何绘制虚线?
- 2. 如何绘制虚线?
- 3. 绘制虚线
- 4. android,如何在edittext中绘制虚线
- 5. 如何在MonoGame/XNA中绘制虚线
- 6. 在flex中绘制具有虚线边框的矩形?
- 7. 如何绘制虚线连接的点?
- 8. 在java中绘制虚线
- 9. 如何使用cgcontext iOS绘制虚线?
- 10. 如何在对象上绘制虚线?
- 11. 如何使用xml绘制粗虚线?
- 12. JavaFx 2.x:如何绘制虚线或虚线?
- 13. 在flex中的线图上绘制点
- 14. 使用fabric.js绘制虚线
- 15. AndroidPlot:支持绘制虚线
- 16. JavaFX帆布:绘制虚线
- 17. 绘制虚线边框
- 18. 绘制垂直虚线
- 19. 使用CGContextSetLineDash绘制虚线
- 20. 从UIViewController绘制虚线
- 21. HOWTO:在.NET中绘制虚线(WinForms)
- 22. 安卓绘制动画虚线曲线
- 23. 绘制虚线和连续线
- 24. 在2017年使用IBDesignable绘制虚线(不是虚线!)线条
- 25. 如何在Flex中绘制直线与行动脚本
- 26. 在cocos2d中使用绘制方法绘制虚线iPhone
- 27. 如何为网格绘制普通线而不是虚线?
- 28. Java - 如何绘制虚线和波浪线?
- 29. 如何在flex 4.5.1中绘制矩形?
- 30. 如何在php中用虚线边框绘制一个圆圈?
非常有帮助,谢谢! – 2010-01-05 13:37:34