Solved

Flash MX Formatting the Content of TextField Objects Newbie Question

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Microsoft WSUS 4 97
bandwidth 5 71
Shouldn't i be able to use an old win xp machine as an internet radio? 7 124
You Tube Videos not playing 9 124
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

809 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