AS3 Embedded font in linked SWC/source blanks out when setting dynamic text field
Okay, that's a fairly complicated title up there, so I'll explain the setup that's causing this error first.
I've got a number of related projects set up in Flash Builder. Each project gets its graphical assets from an exported SWC file (or multiple SWC files.) This works fine, but I wanted to create a shared project that contains stuff used across all projects. The first item in there is a screen with a number of clips containing dynamic text fields on them. This screen (and associated assets) are exported to a SWC and then I have written code in the shared project to add functionality to the screen and buttons. I'm using 2 fonts, both are embedded.
Both show up just fine in my test harness, but when I link the shared SWC and src folder (which is required in order to use t开发者_如何学Chis code/assets in the other projects) the textfields blank out if I try to set their text properties. If I leave the default text (set in the FLA) it shows up, and the static text fields in the FLA also show up, it's only when I set the text property.
I've tried a number of combinations, including removing embedding, exporting for ActionScript, setting all textfields in the shared project to dynamic, all with no luck. The main project does have the same font embedded, and I've checked that the same glyphs are selected in both the main and shared projects.
I realize this is a rather complicated setup, but I have yet to find a workflow to allow a designer and developer to work on large projects that is better (but I'd love to hear one!)
Had the same problem last night. Solved this morning..
- Flash CS5's new interface for embedding a font looks highlighted but you need to ensure that the checkbox is also selected.
- Flash Builder 4, (and Flex), files need to be manually refreshed after updating your SWC file, as the system lags for some reason.
These two things together can lead to some unnecessary back and forth.
Try embeding the font within the TextField. That works for me.
To summarize there were a couple of key points for me that solved it:
- In Flash embed the required font in the standard manner, no need to Export for ActionScript. If you publish the SWC and rebuild from your IDE you'll still be missing characters.
- FIRST KEY POINT: In Flash change the font of the dynamic text field to _sans. Publish the SWC and rebuild from your IDE, all characters should now be present but of course the font is incorrect.
- SECOND KEY POINT: Jump back to Flash and once again change the font of the dynamic text field making sure to select the font that matches the name you input in step 1 when embedding. This font will be in a section of its own near the top of the font list and will have an asterisk appended to the name you entered.
- Once again publish the SWC and rebuild from your IDE and you should find everything working as expected.
Forcing a rebuild with a system font in step 2 seems to flush something out and gets everything working properly but it's also important you select the embedded version of the font in step 3 and not just the normal version.
精彩评论