Dynamic Text on Transparent Background in Papervision3D
So, for the last couple of weeks I've been playing with the very cool Papervision3D library for Flash. More specifically, I've been mucking around in the Effects branch of version 2.0 alpha, code-named GreatWhite. One of the things I wanted to do was create a dynamic text field on a plane. Luckily, I found this post, which gave me all I needed to know to get what I wanted, or at least I thought it did.
I wanted my text on a transparent plane, so that it had no background. Simple, I thought. I'll just create the TextField, add it to a MovieClip and create a material out of said MovieClip. Unfortunately, doing so will result in the ugliest text human eyes have ever beheld on a screen. After a bit of trial and error, I came to this conclusion / solution: Draw a rect below the TextField and give it a fill opacity of 0. Doing this made my text look beautiful and I still had a transparent background. My code looks like so:
var textMC : MovieClip = new MovieClip; var textField : TextField = new TextField(); textField.wordWrap = true; textField.width = 800; textField.height = 150; textField.multiline = true; textField.text = "Default Text"; textField.autoSize = TextFieldAutoSize.LEFT; var textFormat : TextFormat = new TextFormat( "Arial" ); textFormat.size = 36; textFormat.color = 0xFFFFFF; textField.setTextFormat( textFormat ); //Create a rect the size of the MovieClip with an opacity of 0 //This lets the TextField render properly textMC.graphics.beginFill( 0x000000, 0 ); textMC.graphics.drawRect( 0, 0, 800, 150 ); textMC.graphics.endFill(); textMC.addChild( textField ); var tfMaterial : MovieMaterial = new MovieMaterial( textMC, true, false, true ); tfMaterial.smooth = true; tfMaterial.tiled = true; var tmpPlane : Plane = new Plane( tfMaterial, 800, 150 );
