TwelvestoneFlash

as3 text disappearing shenanigans


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Big Ern
 
2008-12-10

This is weird.

I've got a button I'm placing to the stage and populating with text dynamically. It was working in the past until I started mucking with setChildIndex of other elements (I think). Now the text is disappearing. I have since commented out everything that had setChildIndex attached and it still doesn't show up.

This is the code:

var dimensionButtonkimensionButton = new DimensionButton(); addChild(dimensionButton); dimensionButton.label_txt.text = "hello"; trace("dimensionButton = "+dimensionButton); // returns [object DimensionButton] trace("dimensionButton.label_txt = "+dimensionButton.label_txt); //returns [object TextField] trace("dimensionButton.label_txt.text = "+dimensionButton.label_txt.text); //returns "hello" -- so it is there...

I have embedded the font, added the font to the library (overkill considering it's Arial), made sure the colour is a readable one, and the alpha is 100. I've even deleted the background on the button so it is now ONLY a text box inside the mc. Not only that, but when I roll over the button the text cursor comes up so I know the text box is there!!

In fact, if I place text into the text field directly, it shows up.

Any ideas why it's disappeared on me? Like I said, I have in fact had it working in the past and not changed the dimensionButton.label_txt.text line at all.

I'm stumped.

EDIT: -- In an act of desperation, I've commmented out all the rest of the code in the document class and the DimensionButton class and it is STILL disappearing. God, it must be something simple... I have a feeling I'm about to look like an ass... k

Big Ern
 
2008-12-10

For the love of all things holy.

It works when I DON'T embed the font -- but now it's no longer bold. Someone please explain.

I am going to shoot the man that invented AS3.

JLM
 
2008-12-10

have you checked whats at the highest depth and depth of the textfield, are any masks involved, try tracing the htmlText and check the bold or whatever arial varient is embbeded, tell the text to be embeded in code try setting with html...

JLM
 
2008-12-10

you have to embed bold and not bold text make the textfield html and add an a and an a and embed latin or something for arial.

Big Ern
 
2008-12-10

Originally posted by: JLM you have to embed bold and not bold text

I'm not quite sure what you mean here...

I changed the text field to htmlText and added tags and that has seemed to work.

How have I never run into this before and why was it working before?!?! What's even more random is that I have another text box on the stage that I am populating dynamically whose font is ERAS ITC Demi and it works without the htmlText, the tags or adding the font to the library. How bizarre.

Jesus, maybe I better go back and check all the flas I've ever made.

mystic_juju
 
2008-12-10

What JLM is getting at is that if you are trying to display various weights of a single font, you will have to embed that font more than once - each time for the different weight. So, if you want Arial to be both bold and not bold, you have to have two separate instances of embedded fields, one with the bold setting on, and one with it off. Same with italic.

However, what I usually do (if I'm working in Flash), is to right-click in the library and add a font there. Then you can specify whether you want bold or not - so in your case you may have "ArialBold" as well as "ArialNormal". On top of this, a good way to make sure you are referencing the correct family, is to export it for actionscript (eg. call the class ArialBold), then when you make a textformat you do it like this:

var fmt:TextFormat = new TextFormat(new Arial().fontName, 12, 0x000000);

(obviously with Arial the fontName is obvious, but flash does odd and strange things with font names and it's best to let it provide the name for you)

if you aren't using flash, then embed fonts using the Embed syntax in your code.

JLM
 
2008-12-11

mm not sure lib font symbols are so good in practice.. it might seem messy but shoving html textfields off stage seems simplier and easier to control the actual font symbols added. In AS3 you can load shared application domains at run times and ref unclosed fonts by class name at runtime.

mystic_juju
 
2008-12-11

fair enough, but like you say - it does feel messier to have things lying around the stage - therefore not what i like to do...keeping things in the lib just feels better. in any case, i prefer to use the Embed syntax and then you can specify unicode ranges.

JLM
 
2008-12-11

you can load them in at run time but the textfield in a lib instance and make sure you load them into the same application domain, that way it keeps the main swf clean??

mystic_juju
 
2008-12-11

yeah good makes sense - pretty much what i was getting at before i think. when you load it in, you gotta do a Font.registerFont call as well.

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

as3 text disappearing shenanigans