Solved

Flash MX Formatting the Content of TextField Objects Newbie Question

Posted on 2003-11-16
5
375 Views
Last Modified: 2010-04-03
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
Comment
Question by:coson
  • 2
  • 2
5 Comments
 
LVL 27

Expert Comment

by:negatyve
ID: 9763140
// 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
 
LVL 27

Accepted Solution

by:
negatyve earned 125 total points
ID: 9763160
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
 
LVL 1

Expert Comment

by:text_problems
ID: 9765088
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
 
LVL 1

Expert Comment

by:text_problems
ID: 9770461
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
 

Author Comment

by:coson
ID: 9783768
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now