tags:

views:

122

answers:

2

hi,

how can I assign the stroke to my LineSeries, programmatically in Actionscript ?

<mx:LineSeries stroke="{new Stroke(0xCC33CC, 2)}"  />

How is it in Actionscript ?

LineSeries.stroke doesn't exist

thanks

A: 

It would be something like this:

var s:Sprite = new Sprite();
s.graphics.lineStyle(2, 0xCC33CC); // define your line style
s.graphics.moveTo(new Point(whatever, whatever)); // move to origin
s.graphics.lineTo(new Point(whatever2, whatever2)); // draw line to target
s.graphics.lineStyle(); // this just clears the linestyle.

Look into the Graphics class for more information.

Myk
...though there might be a way more specific to LineSeries, which I've never seen before.
Myk
Sorry but this is drawing a line right ? I have to apply the stroke all along the lines of my LineSeries, not just one line. Anyway, isn't there a easier solution ? I actually need to do programatically because I don't know how many LineSeries I'm going to have...
Patrick
Hmm, okay, I see your point. I'm not sure if you can do a stroke specifically like that - I think as far as AS3 is concerned, strokes just become lines like this in the graphics class. I could be wrong about that, though. I'll check back later to see if anyone else is able to help.
Myk
The LineSeries stroke is completely different.
quoo
Ah, thanks. Was completely unaware of that, all of the strokes/fills I've worked with have been done through the graphics class. Thanks for the education!
Myk
A: 

The lineStroke "property" of a charting series, such as LineSeries is not actually a property but a style, therefore it needs to be set via either mxml, css, or a call to setStyle. So you could potentially call from actionscript:

myLineSeries.setStyle("lineStroke", myStroke);

However, it's best to limit your calls to setStyle() as it's an expensive call, so I'd try to use css or mxml if at all possible.

quoo
ok cool, I've just noticed that Flex assign random colors to my lines, so I don't need to do anything :)
Patrick
Yep, as far as styles go, there's nearly always a default.
quoo