Solved

Flash MX Formatting the Content of TextField Objects Newbie Question

Posted on 2003-11-16
5
374 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

762 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

20 Experts available now in Live!

Get 1:1 Help Now