Jump to content
Search Community

Transforming Text Objects wrapped in Sprites or MovieClips

rob.roberts test
Moderator Tag

Recommended Posts

I am attempting to create speech balloons for an application that contain editable text. I understand that textfields are controlled differently by TransformManager if the flag hasSelectableText is set to true (basically the only way you can edit the text if TransformManager is used on an input or dynamic text field.)

I have now embedded my text field into a movieClip (trying a sprite next) so that I can still flip the graphic, but have the text remain the same. Not working obviously or I wouldn't be posting here. The purpose of wrapping it is not only to allow the balloon to flip, but also to help with deleting the object (which hasSelectableText prevents as well.)

Below is the creation of the object (basically the oval graphic with the speech tab/tic and a textField on the layer above it; created as a movieClip symbol called roundSpeech. Fonts are embedded in the application (thus the use of myComic for Comic Sans.)

function addTextItem(evt:Event):void
{
var itemObj:Object = new Object;
var tmpTextFormat:TextFormat = new TextFormat();
++textNumber;
   textFieldNames[textNumber] = new roundSpeech();
tmpTextFormat.font = myComic.fontName;
tmpTextFormat.color = 0x000000;
tmpTextFormat.size = 48;
textFieldNames[textNumber].txtSpeech.text = "edit this text";
textFieldNames[textNumber].width = 300;
textFieldNames[textNumber].height = 200;
textFieldNames[textNumber].x = 400;
textFieldNames[textNumber].y = 300;
textFieldNames[textNumber].txtSpeech.autoSize = TextFieldAutoSize.LEFT;
textFieldNames[textNumber].txtSpeech.type = TextFieldType.INPUT;
textFieldNames[textNumber].txtSpeech.wordWrap = true;
textFieldNames[textNumber].txtSpeech.multiline= true;
textFieldNames[textNumber].txtSpeech.embedFonts = true;
picStage1.addChild(textFieldNames[textNumber]);
manager.addItem(textFieldNames[textNumber],TransformManager.SCALE_WIDTH_AND_HEIGHT,true);

textFieldNames[textNumber].txtSpeech.setTextFormat(tmpTextFormat);
manager.selectItem(textFieldNames[textNumber]);
}

Any help appreciated. Others on the forum have posted about embedding a text object in a sprite or movieClip, which is what drove me down this avenue.

Link to comment
Share on other sites

Handling TextFields properly in Flash can be a real headache because there are some bugs/inconsistencies in Adobe's stuff. There's a bunch of legwork TransformManager/TransformItem does behind the scenes to correctly render them, but unfortunately allowing things to flip and make text editable are particularly problem-laden with TextFields. You could just keep your wrapper and listen for when your items are selected and manually handle giving the TextField focus and maybe even temporarily deselect it from TransformManager (if that's the effect you want). Feel free to add it back to TransformManager when you're done and/or select it again.

Link to comment
Share on other sites

  • 2 weeks later...

I've tried this using a movieClip as well, but to no avail. I can live without the flipping--I just have to create 4 times as many movieClip objects.

 

One thing that I think is not working correctly is the scaling. When I have SCALE_WIDTH_AND_HEIGHT set to true, I would expect the embedded text object to increase its height and width property, but leave the font size the same as that which is set in TextFormat.size. It doesn't do that. Instead, it scales the text up at the same rate as the movieClip object (I would expect scaling using scale_x and scale_y.) Is this a bug or is there a setting I am missing?

Object created as an oval, then converted to movieClip symbol. Oval exists on layer1, textField created on layer2 with a different font embedded (others are embedded in the application.)

Link to comment
Share on other sites

One thing that I think is not working correctly is the scaling. When I have SCALE_WIDTH_AND_HEIGHT set to true, I would expect the embedded text object to increase its height and width property, but leave the font size the same as that which is set in TextFormat.size. It doesn't do that. Instead, it scales the text up at the same rate as the movieClip object (I would expect scaling using scale_x and scale_y.) Is this a bug or is there a setting I am missing?

I'm not sure I understand your question properly, but if you change the width/height of a MovieClip, it does indeed affect its scaleX/scaleY - that's a Flash thing, not a TransformManager thing. When you directly change the width/height property of a TextField, it doesn't scale things - it just alters the size of the container of the text. So if you put a TextField inside of a MovieClip and then alter the width/height of the MovieClip, it will indeed scale the whole child TextField (so the text will appear to grow/shrink too). Make sense? You could certainly adjust the font size downward in proportion to the MovieClip scaling up and visa-versa by using a SCALE event handler.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...