Notes to Lesson 5

$firstText->moveTo((460/2-($myText->getWidth(" My First Flash!"))/2)+10,50);

The above line is actually the same as: $firstText->moveTo(x,y);

A value of 10 was added to the x parameter in order to center the text over the circle with the word "First," but when compared to the background, the words are not actually centered on the banner.

Fonts too, can be put into a function, which saves on scripting when using several lines of text, as there are only 2 lines of code to add for each line of text.

function font($font,$r,$g,$b,$a,$pointsize,$label){
$Font=new SWFFont("$font");
$Text=new SWFText();
$Text->setFont($Font);
$Text->setColor($r,$g,$b,$a);
$Text->setHeight($pointsize);
$Text->addString("$label");
return $Text;
}

Then you would call the function as follows:

//(font('font',red,green,blue,alpha,pointsize,'text')
$First=$myMovie->add(font('Park_Avenue_BT.fdb',255,200,0,255,70,'My First Word'));
$First->moveTo(10,80);

Font Function Sample:

Result:



Font Function Sample: