
Well, I finally came up with a fix for this issue and thought to archive it. Basically, the issue is that when you have textfields in a Sprite that you use for a material source for Papervision3D, you want to be able to set focus to those text fields. Without them being on stage, however, it doesn’t work to say “stage.focus = myTextField”.
So, very simply, all you have to do is add the textfield to the stage, then use stage.focus = myTextField, then re-add back to your Sprite. Bingo, you have focus in your TextField. Now, I should say, that i’ve seen it work with just using stage.focus = myTextField, but in this particular situation, adding it to the stage first, then setting focus, then adding it back worked. So give it a whirl either way.
example:
stage.addChild(myTextField);
stage.focus = myTextField;
this.addChild(myTextField);
Bam! done. As long as you’re redrawing your material so that you can see what you’re typing ( bitmapMaterial.drawBitmap()), it’ll work just fine.
Tabbing is controlled easily with:
protected function handleKeyUp(e:KeyboardEvent):void
{
if( e.keyCode == 9 ) // tab
{
if( currentField == username )
changeToPassword();
else if( currentField == password )
changeToUsername();
}
}
hope that helps someone!


November 16, 2008 at 6:44 pm
[...] > Setting focus on TextFields not on stage – Papervision3D « RockOnFlash m/ [...]
December 20, 2008 at 9:39 pm
totally wicked man.. tips like these makes all the difference. thanks!
February 19, 2009 at 3:32 am
[...] Setting focus on TextFields not on stage – Papervision3D [...]
June 24, 2009 at 3:11 pm
Well done!
I found the same solution “stage.focus = myTextField”, but for a MovieMaterial or MovieAssetMaterial, the stage is null. I solved it passing the stage trough a parameter.
Worked perfectly with your solution.
Thanks a lot!