• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 386
  • Last Modified:

Flash MX Formatting the Content of TextField Objects Newbie Question

Working on a Flash form that will submit items to the database.  Got everything working except the formatting of the text objects...

Here's my example:

http://www.thisiswaytoocool.com/formtest2.html

All of the text fields (Name, Company, Address and Phone) were created using Flash MX's user interface tool.

However, I've recently found out it's possible to dynamically create these text fields at runtime.  So, in my Movie Clip called form (which is the form you see at the above URL) on Frame 1

Here's my code:

// setup the email field dynamically @ run-time
this.createTextField("email", 2, -49.0, 27.1, 235.9, 20.0);
email.type = "Input";
email.variable = "email";
email.background = true;
email.backgroundColor = 0xD6E7E8;
email.text = "";

titleStyle = new TextFormat();
titleStyle.font = "Arial";
titleStyle.size = 12;
titleStyle.color = 0x990000;

email.setTextFormat(titleStyle);
// I've also tried to use email.setNewTextFormat(titleStyle), but that doesn't appear to work

// I've also tried using the other way to declare new TextFormat()
// titleStyle = new TextFormat("Arial", 12, 0x990000, null, null, null, null, null, null, null, null, null, null);

Here's my problem:

// I've also tried embedding the font by creating a new Font symbol called arialEmbed
// Then I tried linking the font outlines to the flash movie
// and using the aforementioned code

It doesn't work.  I'm positive that my code is correct, but since I don't know all the "ins and outs", I may be missing something I'm unaware of..
0
coson
Asked:
coson
  • 2
  • 2
1 Solution
 
negatyveCommented:
// the font is embedded in the library as symbol
// with "arialEmbed" linkage

this.createTextField("email", 2, -49.0, 27.1, 235.9, 50);
email.type = "Input";
// this is the line that breaks the code
// without it works fine...
// email.variable = "email";
email.embedFonts = true;
email.background = true;
email.backgroundColor = 0xD6E7E8;
email.text = "";


titleStyle = new TextFormat();
titleStyle.font = "arialEmbed";
titleStyle.size = 13;
titleStyle.color = 0x990000;
email.setNewTextFormat(titleStyle);
0
 
negatyveCommented:
well, know I see. it breaks the code because you cannot set "email" both as the instance name and the assigned variable of the input textfield. this code works:

this.createTextField("email", 2, -49.0, 27.1, 235.9, 20.0);
email.type = "Input";
email.variable = "email_var"; // different variable name
email.embedFonts = true;
email.background = true;
email.backgroundColor = 0xD6E7E8;
email.text = "";


titleStyle = new TextFormat();
titleStyle.font = "arialEmbed";
titleStyle.size = 12;
titleStyle.color = 0x990000;
email.setNewTextFormat(titleStyle);
0
 
text_problemsCommented:
I have the exact same problem, my code looks like:

// verdana text format
_root.verdanaFmt = new TextFormat();
_root.verdanaFmt.size = 10;
_root.verdanaFmt.font = "verdana";
//-------------------------------------
_root.contHolder.cHolder.createTextField("InaText", 14, 334, 83, 300, 20);
_root.contHolder.cHolder.InaText.text = "";
_root.contHolder.cHolder.InaText.textColor = 0x000000;
_root.contHolder.cHolder.InaText.type = "input";
_root.contHolder.cHolder.InaText.autoSize = false;
_root.contHolder.cHolder.InaText.embedFonts = false;
_root.contHolder.cHolder.InaText.setTextFormat(_root.verdanaFmt);

instead of verdana with no aliasing, I get a serif font with anti-alias!!

Sorry I can't help but I'd be interested to find the solution to this...

0
 
text_problemsCommented:
For anyone who is interested, I think I've found the answer!

This was the code I [i]was[/i] using

[code]
// verdana text format
_root.verdanaFmt = new TextFormat();
_root.verdanaFmt.size = 10;
_root.verdanaFmt.color = 0xff0000;
_root.verdanaFmt.font = "verdana";
//-------------------------------------
_root.contHolder.cHolder.createTextField("InaText", 14, 334, 83, 300, 20);
_root.contHolder.cHolder.InaText.type = "input";
_root.contHolder.cHolder.InaText.setTextFormat(_root.verdanaFmt);
[/code]

But it wouldn't format my input textfield.

I changed setTextFormat() in the last line to setNewTextFormat(), and now it works fine.

Coson, if you change your email var as per negatyve's comment then change your format code back to setNewTextFormat() I'm guessing it will work for you too.

Hope that helps.
Tp
0
 
cosonAuthor Commented:
I've found Flash MX to be a memory hog.  It turns out that the size of the file I'm working on is approaching 2MB.  Even though I have a gig of RAM, I thought I was OK, but I've noticed weird things going on with this file.

For example, when I initially tried negatvye's answer, it didn't work.  I thought maybe I had a typo, but that wasn't the case.  It was really early in the morning (1:35 AM) and I was starting to contact double-vision.

I figured if I got some sleep, that would do the trick.  So I get up, and check it out again, (after some java) and it's still not working.

I rebooted my machine and everything works fine.  I thought I could run ten applications at the same time including Flash MX and an MP3 player along with IE, Fireworks, etc...

That's what I get for thinking..  :(
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now