I have two questions.
First: I created this class, which supposed to create sort of 3D cube
package
{
import flash.display.*;
import flash.events.*;
//additional libs
import flash.text.*;
public class Cube extends MovieClip
{
public var star_commands:Vector.<int> = new Vector.<int>(12, true);
public var star_coord:Vector.<Number> = new Vector.<Number>(24, true);
public function Cube(xPos:Number,yPos:Number,size:Number)
{
star_commands[0] = 1;
star_commands[1] = 2;
star_commands[2] = 2;
star_commands[3] = 2;
star_commands[4] = 1;
star_commands[5] = 2;
star_commands[6] = 2;
star_commands[7] = 2;
star_commands[8] = 1;
star_commands[9] = 2;
star_commands[10] = 2;
star_commands[11] = 2;
star_coord[0] = xPos; //x
star_coord[1] = yPos; //y
star_coord[2] = xPos;
star_coord[3] = yPos + size;
star_coord[4] = xPos + size;
star_coord[5] = yPos + size;
star_coord[6] = xPos + size;
star_coord[7] = yPos;
star_coord[8] = xPos;
star_coord[9] = yPos;
star_coord[10] = xPos + size/2;
star_coord[11] = yPos - size/2;
star_coord[12] = xPos + size/2 + size;
star_coord[13] = yPos - size/2;
star_coord[14] = xPos + 40;
star_coord[15] = yPos;
star_coord[16] = xPos + size;
star_coord[17] = yPos + size;
star_coord[18] = xPos + size + size/2;
star_coord[19] = yPos + size - size/2;
star_coord[20] = xPos + size/2 + size;
star_coord[21] = yPos - size/2;
star_coord[22] = xPos + size;
star_coord[23] = yPos;
graphics.beginFill(0x003366);
graphics.drawPath(star_commands, star_coord);
graphics.endFill();
graphics.lineStyle(2,0x000000);
graphics.moveTo(xPos,yPos);
graphics.lineTo(xPos,yPos+size);
graphics.lineTo(xPos + size,yPos + size);
graphics.lineTo(xPos + size,yPos);
graphics.lineTo(xPos,yPos);
graphics.lineTo(xPos + size/2,yPos - size/2);
graphics.lineTo(xPos + size*1.5,yPos - size/2);
graphics.lineTo(xPos + size,yPos);
graphics.moveTo(xPos + size,yPos + size);
graphics.lineTo(xPos + size*1.5,yPos + size*0.5)
graphics.lineTo(xPos + size*1.5,yPos - size*0.5)
}
}
}
then in my fla file in frame one I try to call the class by
var cusbe:MovieClip;
cusbe = new Cube(100,100,10);
and i get this error
ArgumentError: Error #1063: Argument count mismatch on Cube(). Expected 3, got 0.
So my question is why am I getting this error. I pass 3 arguments to the class ?
The second question is related to the above class as well. What I’m trying to do is to have a class that creates a cube and then I can just use it anywhere in my animations. SO is this the most efficient way to have it done this way (meaning as a class and then the vectors as I have there)?
Many thanks