Copy link to clipboard
Copied
So, I have a movie clip which consists of a filled vector circle with a stroke. Is it possible to increase/decrease the stroke to a specific thickness in pixels with actionscript whilst the swf is playing?
Thanks
T
If you draw a circle dynamically using graphics API then its possible to chage the stroke by using lineStyle method.
But if that circle has already been drawn and placed in the stage, I don't think you can change it's stroke.
Can I ask, why don't you draw it dynamically using actionscript. It's so easy.
//make sure you import relavent apis
import flash.display.LineScaleMode;
import flash.display.CapsStyle;
import flash.display.JointStyle;
public var _cricleObj :Sprite;
public var _lineSize
...Copy link to clipboard
Copied
If you draw a circle dynamically using graphics API then its possible to chage the stroke by using lineStyle method.
But if that circle has already been drawn and placed in the stage, I don't think you can change it's stroke.
Can I ask, why don't you draw it dynamically using actionscript. It's so easy.
//make sure you import relavent apis
import flash.display.LineScaleMode;
import flash.display.CapsStyle;
import flash.display.JointStyle;
public var _cricleObj :Sprite;
public var _lineSize :Number = 1;
//Now draw your circle
_cricleObj = new Sprite();
_cricleObj.graphics.lineStyle(_lineSize, 0xFFFF00, 1, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 3);
_cricleObj.graphics.beginFill(0xFF,1);
_cricleObj.graphics.drawCircle(0,0,50);
_cricleObj.graphics.endFill();
_cricleObj.addEventListener(Event.ENTER_FRAME, reDrawCircle);
public function reDrawCircle(e:Event):void
{
_lineSize +=1;
_cricleObj.graphics.clear();
_cricleObj.graphics.lineStyle(_lineSize, 0xFFFF00, 1, false, LineScaleMode.VERTICAL, CapsStyle.NONE, JointStyle.MITER, 3);
_cricleObj.graphics.beginFill(0xFF,1);
_cricleObj.graphics.drawCircle(0,0,50);
_cricleObj.graphics.endFill();
}
thats all.
Copy link to clipboard
Copied
That was the solution, thanks for that code example.
But I have now come across a much larger problem with getting the dynamic circle to appear correctly:
http://forums.adobe.com/thread/505778
T
Copy link to clipboard
Copied
You can use the graphics class to change the line style, you need to access the shape inside the movie clip in order to use the class.
you can access a shape in a movieclip by using getChildAt. then you can use the lineStyle function.
graphics.lineStyle(thickness, color, transparency).
Copy link to clipboard
Copied
Although you use getChildAt to access a shape in a movieclip by using getChildAt. still you can't change it's linestyle.
if you use graphics.lineStyle(thickness, color, transparency) on that movieClip it can be used to draw a new graphic but can't alter the current one.
If I am wrong please show us an example with clear codes.
Copy link to clipboard
Copied
I think you are right getnaleen, thanks.
I don't know why, thought i did before but i just tried it and it doesn't work.
sorry..
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more