You can set and alter the transparency of any item you add to your swf movie. We do this by adding an extra value to our color codes so that we have four digits for RGBA or Red Green Blue Alpha where Alpha=transparency from 0-255 just like the color values.
At this time, there is no way to add transparency to the background color of a swf movie created with Ming, but there may be a workaround in the future. Let's hide some text behind a box, then slowly make the box transparent showing our hiding text. A) Begin as always by starting your HTML page and opening your php code block. <html> <body> <?php B) Next, we define our font and create our text as usual Download font $myFont=new SWFFont("Arioso.fdb"); $myText1=new SWFText(); $myText1->setFont($myFont); $myText1->setColor(0,0,255); $myText1->setHeight(40); $myText1->moveTo(-($myFont->getWidth("Hiding"))/3,0); $myText1->addString("Hiding"); C) Then, add our box shape as normal $myShape2=new SWFShape(); $myShape2->setRightFill(255,0,0,255); $myShape2->drawLine(150,0); $myShape2->drawLine(0,60); $myShape2->drawLine(-150,0); $myShape2->drawLine(0,-60); D) Now, we define our swf movie and set it's attributes as always $myMovie=new SWFMovie(); $myMovie->setDimension(300,200); $myMovie->setBackground(255,255,255); E) Next, we add our text to our movie, then our box shape. Whichever item is added first will be the bottom layer, and each item added after it will be layered over previous items. $firstText=$myMovie->add($myText1); $firstText->moveTo(150,150); $transparentSquare=$myMovie->add($myShape2); $transparentSquare->moveTo(80,110); F) Now, we use our multColor function in a loop from lesson 9, but change the Alpha channel instead of one of the RGB channels for($i=0; $i<20; $i++){ $myMovie->nextFrame(); $transparentSquare->multColor(1.0,1.0,1.0,1.0-$i/20); } G) Finally, we save our movie, close our php code block, and add our html object coding as always. $myMovie->save("lesson13.swf"); ?> <OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=4,0,0,0" ID=objects WIDTH=300 HEIGHT=200> <PARAM NAME=movie VALUE="lesson13.swf"> <EMBED src="lesson13.swf" WIDTH=300 HEIGHT=200 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"> </EMBED> </OBJECT> </BODY> </html> Transparency combined with gradients and the use of the multColor function can create truly awe inspiring transformations! Code summary for lesson 13: Result: |