Textfields in Broomstick

Software: Away3D 4.x

alx1507, Newbie
Posted: 11 August 2011 03:03 PM   Total Posts: 4

Hello all,
I’ve done a bit of searching around the forum to see how to do this, and I’ve scraped together a few things but am still unsure on how to proceed.

So from what I’ve gathered on the forum this is the process to do it:
  - create text field. (enable cache as bitmap?)
  - create bitmap data var.
  - do a bitmapDataVar.draw(textFieldName, null, null, null, null, true);
  - assign new bitmap data to a material.
  - apply material to a plane or something.

This leads to nothing but a black texture with no text.  So here is my actual code:

bitText = new TextField();
bitText.name "mtfsdfd";
bitText.text "tessssssssssssssssssssssssssssst";
bitText.autoSize TextFieldAutoSize.CENTER
bitText
.stage.width/2-37 ;
bitText.170;
bitText.selectable false;
bitText.border false;
bitText.mouseEnabled false;

bitForm = new TextFormat();
bitForm.color 0xffffff;
bitForm.size 23;
bitForm.font "helvetica";
bitForm.bold true;
bitText.setTextFormat(bitForm);

var 
btmd:BitmapData = new BitmapData(256,256,true,0xffffff);
btmd.draw(bitText,null,null,null,nulltrue);

var 
erthMat BitmapMaterial = new BitmapMaterial(btmd,true,false,true); 

Any help would be fantastic!

Thanks,
Alex

   

Avatar
theMightyAtom, Sr. Member
Posted: 11 August 2011 04:08 PM   Total Posts: 669   [ # 1 ]

So far so good. I copied your code into flash and it worked fine, albeit white text on a white background. To make sure your BitmapData looks correct, you can also view it on screen in a Bitmap:

var bm:Bitmap = new Bitmap(btmd);
addChild(bm); 

The error must be somewhere else in your code. Are you for example triggering a view.render()? That’s a common mistake, that you comment out the function that actually renders the view.

Alternatively your camera may be looking at the reverse side of the plane, which appears black even with bothsides=true, if your scene contains lights.

Post more of your code, I’m sure there’s just some simple mistake.

cheers!

   

alx1507, Newbie
Posted: 11 August 2011 04:27 PM   Total Posts: 4   [ # 2 ]

Thanks for the reply!
I was originally attempting this on a sphere that I had in the scene already, and I guess it was wrapped in just the right way to be hidden from me.  I applied it to a new Plane primitive and it appeared!

The primitive still has a solid black background behind the text, is there any way for me to make that transparent?  Would it be smarter to be working with a Sprite3D? 

Thanks again for the help!
Alex

   

Avatar
theMightyAtom, Sr. Member
Posted: 11 August 2011 04:50 PM   Total Posts: 669   [ # 3 ]

There’s code examples of the two transparency methods in this post.
http://away3d.com/forum/viewthread/414/

Basically, alphaThreshold is the prefered way, but it can produce jagged edges. You set a threshold, and all alpha values under that number (0-1) are 100% transparent, all over the threshold are 100% opaque.

The other method, alphaBlending=true will give you a nice looking result, though can in some circumstances give unexpected z-sorting. You will find links to long explanations in the other post.

   

alx1507, Newbie
Posted: 11 August 2011 04:54 PM   Total Posts: 4   [ # 4 ]

alphaBlending was exactly what I was looking for.  I don’t think z-sorting will be an issue for it’s use. smile

Thanks for all your help!
Alex

   
   

X

Away3D Forum

Member Login

Username

Password

Remember_me



X