Digital Survivors
 

How to fix drunken components nested in a component

Scott Manning
October 1, 2002 | Comments (22)

Today, I was trying to build a scrolling form in Flash MX using components. Everything was going well until I published my movie. The fonts and UI components nested within the scrolling component were... drunk. Text was missing and then appearing out of nowhere, and the UI components were missing or distorted.

Here's a sample of what I'm talking about:

embeddedcomponents_drunk (9k image)

After doing some investigation on Macromedia's support site, I found the problem. When nesting components inside another component, any fonts used need to be embedded in the movie and some custom ActionScript needs to be added to the first frame of the movie. Although, Macromedia's technote says this solution only fixes the font disappearing act, it also fixes the UI component problem.

Here are the steps I took:

1. Open Window > Library

embeddedcomponents_window-library (4k image)


2. Select the Options Menu pop-up in the upper right of the Library.

3. Choose New Font.


embeddedcomponents_newfont (7k image)


4. Name the font (i.e., "verdana") and select the desired font from the Font list (the components use the Arial font by default, so if you want the default look of the component, choose Arial).


embeddedcomponents_fontproperties (8k image)


5. Select OK.

6. Right-click on the new font symbol in the Library and choose Linkage.


embeddedcomponents_linkage (9k image)


The Linkage Properties box will pop up:

embeddedcomponents_linkageproperties (7k image)


7. Check "Export for ActionScript".

8. Check "Export in first frame".

9. Enter a name (i.e., "verdana").

10. In the first frame of your movie, add the following ActionScript:

globalStyleFormat.embedFonts = true;
globalStyleFormat.textFont = "verdana";
globalStyleFormat.applyChanges();

Edit the text that says "verdana" to whatever you named your font in step 4.


The results
That's it. Once I did that, the published movie looked perfect. Here's how the form should look:


Enjoy this article? There's more. Digital Survivors is a source of articles, tutorials, reviews, and commentary on all things digital.

Stay informed with rss, our feed is permanently ad-free.

These articles are new:

bullet Valkyrie
bullet 1940 Aircraft Production Figures
bullet Let Teachers Carry Concealed Firearms at Schools
bullet 50 Books on World War II Recommended by John Keegan

If you don't immediately see what you want, you can start a topic in our forums.

 



Comments (22):
1) Posted by: Rowan
November 18, 2002 5:32 AM

check your spelling/typing errors!

Verdana, not veranda.
Episode, not episdoe.
Questionnaire, not questionaire

I really enjoy reading your articles and tutorials. It deflates the impact of what you are saying, when it looks as if you have not proofread your writing. Presentation does matter.
Please keep up the great work and I look forward to reading future pieces.


2) Posted by: Scott
November 18, 2002 6:49 AM

That comes from not having a spell checker in Flash.


3) Posted by: Rowan
November 24, 2002 8:14 AM

Pooh-pooh.
Maybe we will see one in the next version of Flash.


4) Posted by: Trevor
January 17, 2003 8:25 PM

I've searched high and low for help on 'globalstyleformat.embedfonts' because I just can't seem to get it to work. I've used the linkage many times previous, but not with UI components. Am I missing something?? I'm using FFF Professional w/ Extensis Suitcase if that helps. ...the darn fonts just won't embed! bugger!


5) Posted by: Trevor
January 17, 2003 8:29 PM

Oh... and I realize it's case-sensitive:

globalStyleFormat.embedFonts=true;
globalStyleFormat.textFont="myLinkageString";
globalStyleFormat.applyChanges();

Thanks!


6) Posted by: mraak
March 14, 2003 7:43 AM

my problem was that i couldn't get scrollpane working when in a movie clip. your advice didn't solve that problem. maybe someone knows something else?


7) Posted by: talves
April 3, 2003 11:55 AM

You need to embed the fonts into the clip you are using in the setScrollContent(_root.mc_Example).

This will embed the objects into the scrollPane.

I was having this issue also.


8) Posted by: sd
June 19, 2003 4:56 AM

This was very very helpful, and saved my head from completely breaking after multiple self-inflicted poundings upon my desk!

I'm still a bit stumped by the .embedFonts bit though. embedFonts seems to be a property of TextField objects and other objects which use the same style syntax (like FStyleFormat, globalStyleFormat). So by setting the embedFonts property of globalStyleFormat, I guess you're telling all Macromedia authored components to embed the desired font. Neat. I think.

No, I have it wrong. For instance, the title bar in the Draggable Pane component (Flash UI Component Set 2) won't embed the right font unless you target the TextField object nested in the component instance (myDraggablePanInstance.titleText_mc.labelField.embedFonts = true;). Ack!

I hope I don't have to specifically target all TextField instances in all component instances to embed fonts lest I experience the nested nuttiness shown above.

So -- what exactly does globalStyleFormat.embedFonts do? What is globalStyleFormat.embedFonts supposed to do?


9) Posted by: VK
November 12, 2003 6:04 PM

Has anybody besides me noticed how, as the quality of the special effects in the Star Wars series improves the quality of the story gets worse.

I used to be such a big fan of Star Wars and I didn't even see Episode II after seeing Episode I. I hope Episode III is worth seeing.

Embedding fonts is a real headache. Unpredictable and sloppy at best. Thanks for bringing this important topic to light.

Keep up the good work!


10) Posted by: JRush
November 13, 2003 12:15 AM

I have already inserted the embedfonts routine instruction. Though it reduced my bickering, my combobox components still display tentatively on the screen (they do not show any data when you click on them). by the way, my combo components are inserted dynamically (actionscript)..


11) Posted by: Alex Knights
November 28, 2003 10:00 AM

I find that the quality of font rendering deteriorates if you set the embedFonts property to true for a TextField compared to how well it renders if you set the embedFonts property to false and have the font installed on the client machine. Obviously this is not something one can guarantee (having the correct fonts installed on the client machine that is) but can anyone confirm that this degradation of quality is unavoidable with embedded fonts?


12) Posted by: David
December 4, 2003 3:41 AM

H Guys, Re; can anyone confirm that this degradation of quality is unavoidable with embedded fonts?

Just spent a few difficult days finding out for myself about degradation of font quality, built a movie, font embedded, looked great when viewed at greater than the native 800x600,

BUT according to the client fuzzy at 800x600, and illegibly fuzzy on 640x480 (according to me!),.
So I suggested dynamic boxes should allow the aliasing to be turned off, and therefore should render the text sharply.

Then the nightmare to find that masking made the font disappear altogether when using dynamic or imput boxes, but fine if using static text box (and you get fuzzy fonts).

Trouble then is I can only apply one colour inside that text box.
Can anyone advise or know if I can set a font color toelected text via actionscript?

Cheers


13) Posted by: David
December 4, 2003 3:43 AM

typo...
Can anyone advise or know if I can set a font color to selected text via actionscript?


14) Posted by: JAN
December 5, 2003 2:08 AM

Alpha doesn't seem to work when I expoert the movie. I hope you guys can help me out.


15) Posted by: Sanjay
December 8, 2003 2:38 AM

hi all

globalStyleFormat.embedFonts=true;
globalStyleFormat.textFont="myLinkageString";
globalStyleFormat.applyChanges();
---------------------------------------------------

this does not work for Flash mx 2004 components ... for example: datagrid, combobox, etc ...


16) Posted by: Rob
December 12, 2003 6:52 AM

I haven't done any Flash for about a year, but from what I can remember if you want to use dynamic text with a mask then the font has to be embedded otherwise it won't appear.

However, this makes the text anti-alias, in other words go slightly blurry. To get round this you need to use special flash fonts that are pixel based. It's not the most ideal solution, but at least it works. An example font off the top of my head is Hooge, do a google search for "Hooge font".


17) Posted by: Nadine
February 23, 2004 11:53 AM

Thanks for that solution. But it does not seem to help my checkboxes or radiobuttons. It did work great for the comboboxes, though.
Is this a bug, or is there another solution?


18) Posted by: Raffaello Zucco
March 31, 2004 2:24 PM

Awesome! You save my life dude! I was going crazy trying to rotate a dinamic text box and with your help It finally worked!


19) Posted by: Stephen
July 5, 2004 10:43 PM

Hey Guys,

nice tutorial...

My problem is a little different..
I'm not using forms but the text enlarges and gets smaller as part of a menu system for a splash page...
Upon waiting around 2 or 3 minutes. This can vary, the text fades away and disappears. I have tried to use the embedded text in this tutorial and I can see it controlling the font properties (eg bold etc). Text still appears though.
The dynamic text is nested in a movie clip. Perhaps, it's to do with my actionscript I'm not sure..
Any ideas??

at the moment it all stops at frame 108 which contains action script for rollovers is there a bitter way...
What is a good way to have mousevents respond to rollovers...?

Thanks...


20) Posted by: kram
August 6, 2004 5:07 AM

ive got a swf file using the component Ky scrolly..works fine on its own ..problem is i am calling it from a mc_holder on my main flash file....IT goes Bonkers then.help?


21) Posted by: deke
August 16, 2004 2:04 PM

I'm still having a problem with my text not showing at all.. I'm using the dataGrid component... I can tell its working cus the grid scrolls after I enter a certain amount.. the text just isnt showing. I'm close to pulling all my hair out.

can anyone help??


22) Posted by: Andre Mattos
April 12, 2005 12:40 PM

My dropdowns were not working at all.

Thanx a lot for the greatful help.

Wonder when macromedia will solver these ugly bugs that fester Flash ...


border