Notes to Lesson 3

The square shape drawn in this sample is a series of lines which follow one another.

$myShape2->drawLine(50,0);
$myShape2->drawLine(0,50);
$myShape2->drawLine(-50,0);
$myShape2->drawLine(0,-50);


(50,0) draws a line that is 50 pixels wide. The second line of $myShape2 continues drawing lines from the first line, as if you were drawing with a pen. The pen is now at (50,0) and from that point it continues to draw a line (0,50) that is 50 pixels down on the right side of the square. Next (-50,0), the pen will draw a line across the bottom of the square going back 50 pixels, and finally (0,-50) draws a line going up 50 pixels on the left side of the square.

Again, For those who are familiar with php scripting, There is a function for drawing squares in Ming. You can place the following function in your movie and use it over and over to draw squares.

FILLED SQUARE OR RECTANGLE (this function draws and fills the square with the same color)

function square($r, $g, $b, $a, $W, $H){
$s = new SWFShape();
$s->setLine(1,$r,$g,$b,$a);
$s->setRIGHTFill($s->addFill($r, $g, $b, $a));
$s->drawLine($W,0);
$s->drawLine(0,$H);
$s->drawLine(-$W,0);
$s->drawLine(0,-$H);
return $s;
}

Once the function is in the script, then you can call it with the following codes:

$LILACSquare=$myMovie->add(square(red,green,blue,alpha,width,height));
$LILACSquare->moveTo(x,y);

EMPTY SQUARE OR RECTANGLE (draws only the outline of the square).

function blanksquare($sz, $r, $g, $b, $a, $W, $H){
$s = new SWFShape();
$s->setLine($sz, $r,$g,$b, $a);
$s->drawLine($W,0);
$s->drawLine(0,$H);
$s->drawLine(-$W,0);
$s->drawLine(0,-$H);
return $s;
}

Call the function with the following code:

$BlankSquare=$myMovie->add(blanksquare(size,red,green,blue,alpha,width,height));
$BlankSquare->moveTo(x,y);

To use both of those functions on a page, make sure that the blanksquare is entered after the filled square codes, so that it will draw on top of the filled square. Ming uses a z-index in that it will place the last item listed closest to the viewer.

You can combine those 2 functions into one if you prefer, with the following codes:

function bordersquare($sz,$r2, $g2, $b2, $a2, $r, $g, $b, $a, $W, $H){
$s = new SWFShape();
$s->setLine($sz,$r,$g,$b,$a);
$s->setRIGHTFill($s->addFill($r2, $g2, $b2, $a2));
$s->drawLine($W,0);
$s->drawLine(0,$H);
$s->drawLine(-$W,0);
$s->drawLine(0,-$H);
return $s;
}

The $sz is for the line thickness,$r2,4g2,$b2,$a2, are for the fill color, while $r,$g,$b,$a are for the border color. It is called with the following code:

$LILACSquare=$myMovie->add(square(8,255,255,0,255,200,0,255,255,100,200));
$LILACSquare->moveTo(100,50);

Below is a sample script using the combined border/square function:

Result: