Solved

Flash MX Formatting the Content of TextField Objects Newbie Question

Posted on 2003-11-16
5
378 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
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.

696 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