mactinker123
04-10-2005, 04:50 AM
Hi,
I have been making alot of drawings with actionscript and I got tried of writing codes to make simple shapes. So I made some scripts that allows me to draw shapes based on where to place the reference point and the overall dimensions of the shape.
What I like to do is put several shapes in one frame but for some reason only one drawing appears.
To show you what I mean, I want the arrow and triangle to appear in the same screen, the code I use is below. When I test the movie only the triangle appears. Im not sure what Im doing wrong?
stop();
//reference is at arrow point
//for arrow point up h must be +ve
//for arrow point down h must be -ve
MovieClip.prototype.drawArrow = function(w, h, x, y) {
this.moveTo(x, y);
this.lineTo(x - (w/2), y + (h/3));
this.lineTo(x - (w/3), y + (h/3));
this.lineTo(x - (w/3), y + h);
this.lineTo(x + (w/3), y + h);
this.lineTo(x + (w/3), y + (h/3));
this.lineTo(x + (w/2), y + (h/3));
}
var ar = this.createEmptyMovieClip("Arrow", 1);
ar.lineStyle(1, 0x000000, 100);
ar.beginFill(0x000000, 100);
ar.drawArrow(10, 10, 400, 200);
ar.endFill();
//reference is at top of triangle
//upward facing triagle h is +ve
//downward facing triangle h is -ve
MovieClip.prototype.drawTriangle = function(w, h, x, y) {
this.moveTo(x, y);
this.lineTo(x + (w/2), y + h);
this.lineTo(x - (w/2), y + h);
}
var tri = this.createEmptyMovieClip("TRIANGLE", 1);
tri.lineStyle(1, 0x00aa00, 100);
tri.beginFill(0xffff00, 100);
tri.drawTriangle(20, 20, 400, 400);
tri.endFill();
Can someone please help?
I have been making alot of drawings with actionscript and I got tried of writing codes to make simple shapes. So I made some scripts that allows me to draw shapes based on where to place the reference point and the overall dimensions of the shape.
What I like to do is put several shapes in one frame but for some reason only one drawing appears.
To show you what I mean, I want the arrow and triangle to appear in the same screen, the code I use is below. When I test the movie only the triangle appears. Im not sure what Im doing wrong?
stop();
//reference is at arrow point
//for arrow point up h must be +ve
//for arrow point down h must be -ve
MovieClip.prototype.drawArrow = function(w, h, x, y) {
this.moveTo(x, y);
this.lineTo(x - (w/2), y + (h/3));
this.lineTo(x - (w/3), y + (h/3));
this.lineTo(x - (w/3), y + h);
this.lineTo(x + (w/3), y + h);
this.lineTo(x + (w/3), y + (h/3));
this.lineTo(x + (w/2), y + (h/3));
}
var ar = this.createEmptyMovieClip("Arrow", 1);
ar.lineStyle(1, 0x000000, 100);
ar.beginFill(0x000000, 100);
ar.drawArrow(10, 10, 400, 200);
ar.endFill();
//reference is at top of triangle
//upward facing triagle h is +ve
//downward facing triangle h is -ve
MovieClip.prototype.drawTriangle = function(w, h, x, y) {
this.moveTo(x, y);
this.lineTo(x + (w/2), y + h);
this.lineTo(x - (w/2), y + h);
}
var tri = this.createEmptyMovieClip("TRIANGLE", 1);
tri.lineStyle(1, 0x00aa00, 100);
tri.beginFill(0xffff00, 100);
tri.drawTriangle(20, 20, 400, 400);
tri.endFill();
Can someone please help?