Gunto,
Post by Guntoa=new Point(32,54);
b=new Point(65,128);
That's not a bad idea in theory, but the Point class isn't necessary for
drawing lines (in fact, the Point class doesn't give you much more than an
object with built-in x and y properties; it's has no visual
characteristics).
Post by GuntoNow, how do I draw a line between these points or connect
them? Is this the right way at all?
The exact working depends on what version of ActionScript you're using,
but in a basic sense, you'll be using the MovieClip class (that is, a movie
clip symbol). In AS2, the MovieClip class features drawing methods
directly; in AS3, this same class features a graphics property, which points
to an instance of the Graphics class, and it's the Graphics class that
features the drawing methods. A quick example will make it all clear.
First, create a movie clip:
// AS2
this.createEmptyMovieClip("line1", 0);
Then, use the drawing-related methods:
// AS2
line1.lineStyle(3, 0xFF0000);
line1.moveTo(32, 54);
line1.lineTo(65, 128);
That really, that's it. Note in the very first line, AS2 provides you a
way to give the new movie clip an instance name (line1) and a depth (happens
to be 0). There are additional drawing-related methods, and you can look
them up in the MovieClip class. Keep in mind, everything in ActionScript is
an object, and objects are defined by classes. The class entry in the
ActionScript 2.0 (or 3.0) Language Reference generally tells you three
categories: a) characteristics the object has (properties), b) things the
object can do (methods), and c) things the object can react to (events).
In AS3, the preceding lines are pretty similar. Again, first create a
movie clip:
// AS3
var line1:MovieClip = new MovieClip();
The, use the graphics property, which points to an instance of the
Graphics class, to pull off the same feat:
line1.graphics.lineStyle(3, 0xFF0000);
line1.graphics.moveTo(32, 54);
line1.graphics.lineTo(65, 128);
In AS3, you have to add the new movie clip (line1) to the display list,
which you can do at the end:
addChild(line1);
David Stiller
Co-author, Foundation Flash CS4 for Designers
http://tinyurl.com/dpsFoundationFlashCS4
"Luck is the residue of good design."