PDA

View Full Version : Coloring a line with Actionscript? PLEASE HELP ASAP!



Fidelity88
April 25th, 2005, 10:54 AM
Im working on some actionscript drawing, right now Im drawing a curved line on a map to show a route for a shipping company, the line is red but I would like to color a portion of the line green for the completed portion of the journey. How would I do this?
If you have anymore Questions please ASK!
Thanks
Fidelity88

scotty
April 25th, 2005, 11:14 AM
my_mc.lineStyle([thickness:Number[, rgb:Number[, alpha:Number]]])
Look it up in the AS reference;)

scotty(-:

Fidelity88
April 25th, 2005, 11:26 AM
I did and couldnt find anything for partial line fill..

scotty
April 25th, 2005, 12:26 PM
LOL, I should have read better :trout:

You can change linestyles, depending how your code is setted up.

scotty(-:

Fidelity88
April 25th, 2005, 08:41 PM
and how would I go about doing that? For Example, color this line 50% green and 50% percent Red? Is that possible?
Thanks
Fidelity88

scotty
April 26th, 2005, 04:31 AM
To get an idea

var line = this.createEmptyMovieClip("line", 999);
var x = 0;
var y = 50;
var oldx = 0;
line.lineStyle(1, 0xFF0000);
line.onEnterFrame = function() {
x += 5;
this.moveTo(oldx, y);
this.lineTo(x, y);
oldx = x;
if (x>100) {
this.lineStyle(1, 0x00FF00);
}
};

scotty(-:

Fidelity88
April 27th, 2005, 09:08 AM
hey man thanks! This helps A LOT! One other thing how would you do this with a curved line? Is that a possibility?

Dutchy
April 27th, 2005, 09:13 AM
hi,

change lineTo to CurveTo and then you have a curve...

Dutchy

Fidelity88
April 27th, 2005, 10:20 AM
and this code that scotty used can just be pasted into the curved line code? I already have the curved line, I wsa just wondering how to implement it.
Thanks :D
Fidelity88

Dutchy
April 27th, 2005, 10:27 AM
Yes it should work the same for the curved line.

Dutchy

scotty
April 27th, 2005, 11:48 AM
Dutchy has right, it depends how your code is setup, in my example it was easy to have an if statement:)

scotty(-: