Skip to main content
Participating Frequently
November 20, 2009
Question

Why does highlighting the text in my textfield cause the format to change?

  • November 20, 2009
  • 2 replies
  • 1853 views

The movie I am working on has a dynamic text field which I setup and format in the constructor of the ActionScript 3.0 class code for the movie - I am working with CS3 Flash. I do not reformat the text field anywhere in the code after the constructor.The text displays in the text field perfectly as long as I do not highlight the text when running the movie.

If I highlight the text in the text box as if I were going to copy and paste, the next time text is written to the text field the font type and size changes. The only way to reset the font formatting is to restart the movie.

Does anyone understand why this happens? Is there a solution or workaround? Of course I can reformat the text everytime I write new text to the textfield, but during the course of the movie text is rewritten to the textfield many times.

Any help is greatly appreciated.

TimP

This topic has been closed for replies.

2 replies

November 21, 2009

Perhaps there is a mouseover event connected to the text box somehow?

Participating Frequently
November 23, 2009

Perhaps there is a mouseover event connected to the text box, but if there is I am not aware of it. There certainly isn't anything in my code that explicitly sets up a mouseover event associated with the text box. As a matter of fact I wouldn't even know how to do that.

It seems to me that the flash player is resetting the format (default maybe?) as part of the highlighting/copy&paste process.

funkysoul
Inspiring
November 21, 2009

can you post a screenshot of both states? That sounds very weird.

Participating Frequently
November 23, 2009

I agree! This is very wierd. I am attching 3 screenshots:

Highlighting Bug 1.jpg - Normal text appearance in the flash player.

Highlighting Bug 2.jpg - Here I highlight some text as if I were going to copy & paste.

Highlighting Bug 3.jpg - This is what the text looks like after highlighting and I click one of the hot spot buttons outlined in yellow boxes. The text box will continue to use this font until I restart the movie to reset the text formating.

As you can see from the screen shots, this is a very simple movie. I am displaying a screenshot of one page of a setup wizard. In the dynamic text field above the screenshot I display text depending on which button the user clicks. I setup the text box in the constructor for the SetupWizard1_1 class I have defined. I do not change the format at all after the constructor here is the relevant code:

public class SetupWizardv1_1 extends Sprite

 {

  var textFormat:TextFormat = new TextFormat();

  var imageLoader:Loader = new Loader();

  var description_txt:TextField = new TextField();

  var MoreReqHDImport_txt:TextField = new TextField();

  var Title_txt:TextField = new TextField();

  

  public function SetupWizardv1_1()

  {

   setupTextBoxes();

   Frame1(); // Dashboard

  }

public function setupTextBoxes():void

  {

   // Title Text Box

   Title_txt = createTextBox(45, 15, 50, 670, false, false);

   textFormat = TextFormattingII(32); // Set text format for Title_txt.

   Title_txt.defaultTextFormat = textFormat; // associate TextFormat with TextField

   addChild(Title_txt);

   

   // Description Text Box

   description_txt = createTextBox(65, 75, 155, 670, false, false);

   textFormat = TextFormatting(15); // Set text format for description_txt textfield.

   description_txt.defaultTextFormat = textFormat; // associate TextFormat with TextField

   description_txt.multiline = true;

   addChild(description_txt);

  }

private function createTextBox(boxx:Number, boxy:Number, boxh:Number, boxw:Number, boxborder:Boolean, boxbackground:Boolean):TextField

  {

   var box:TextField = new TextField();

   box.x = boxx;

   box.y = boxy;

   box.height = boxh;

   box.width = boxw;

   box.border = boxborder;

   box.background = boxbackground;

   box.wordWrap = true;

   return box;

  }

private function TextFormatting(txtSize:Number):TextFormat

  {

   // Set text field formating optons

   var txtFormat:TextFormat = new TextFormat(); //text field format object

   txtFormat.font = "Tahoma";

   txtFormat.color = 0x666666; //RGB

   txtFormat.size = txtSize;

   //txtFormat.bold = true;

   return txtFormat;

  }

TimP

Inspiring
November 23, 2009

I don't see any screen shots.