Copy link to clipboard
Copied
I am trying to write a swf that has a variety of buttons to select another swf to load in. One of the SWFs to be loaded contains a list component that has been formated using the StyleManager. The results look good in that SWF; however, when it gets loaded into the parent SWF, all of the buttons in the parent SWF get reformatted. If I drop the StyleManager from the SWF (loaded SWF) and use the following code, nothing gets formatted.
var tf:TextFormat = new TextFormat();
tf.font = "Verdana";
tf.size = 12;
tf.bold = true;
tf.color = 0xcccccc;
vidList.setStyle("textFormat", tf);
Copy link to clipboard
Copied
Try vidList.setTextFormat(tf); in place of vidList.setStyle("textFormat", tf);
Copy link to clipboard
Copied
That results in the following error:
1061: Call to a possibly undefined method setTextFormat through a reference with static type fl.controls:List.
Thanks for trying.
Copy link to clipboard
Copied
What you're looking for is setRendererStyle. eg.
vidList.setRendererStyle("textFormat", tf);
I go into styling all Flash Components in more detail here.
Copy link to clipboard
Copied
Craig -
This had promise. It worked exactly as expected for the SWF file in which I put the code. However when that SWF was loaded by the parent SWF, all text and formatting disappeared fro the loaded SWF. I'll read some more on this. Thanks for helping.
Greg
Copy link to clipboard
Copied
And you're not using the StyleManager anywhere, including the parent swf?
Copy link to clipboard
Copied
The StyleManager is not used in either file.
These files are on a test site at www.ivestadog.org/newsite. The problrem occurs when you click the button K9TV. The included file is K9TV.swf.
That file can be played directly: www.ivestadog.org/newsite/K9TV.swf. You would see the problem if you have the time.
Copy link to clipboard
Copied
No, it's not used. I replied to the board. In a nutshell, you can see the
file plays correctly by itself (www.ivestadog.org/newsite/K9TV) but
incorrectly in the parent (www.ivestadog.org/newsite) when you click the
K9TV button.
Greg Ambrose
GRA Video Production Services
www.gravideo.com
Copy link to clipboard
Copied
Before I reply, let me just add your summary of the situation so far in an email to myself:
If you successfully style on or components in a SWF and then load that SWF into a parent SWF that contains only a UILoader sized the same as the first SWF and its source set to the first SWF, all formatting is lost as well as the text that would have appeared in those components.
It seems to me this isn't a problem with styling, its a problem with font embedding.
From my testing I've found that components in the loaded SWF only lose their font if there is a UIComponent in the parent.
I haven't been able to find documentation to confirm my theory, but I believe that once the parent has a UI Component it then tries to handle global Fonts, and doesn't immediately have access to Fonts embedded in SWFs it loads. To check this you can actually embed the same font with the same class name into the parent, and you'll find that the font starts working in the loaded SWF.
This isn't ideal in all situations though - sometimes you want the loaded SWF to handle the font embedding for itself. It appears as though if you register the Font in the loaded SWF, this adds the font to the global register that the parent SWF has access to, and this is all that is required for your font to appear.
Font.registerFont(ComicSans);
Copy link to clipboard
Copied
Keeping this in forums for the benefit of anyone else interested in solutions to this problem. (Greg Ambrose has emailed me his source code.)
After some experimentation with your files, Greg, (after tweaking them so that they followed the solution I've described) I've discovered that the problem came down to the 'parent' containing a textfield of the font 'Verdana' (i found it in 'Prayers_btn' - could be more, stopped there). This seems to be causing a conflict with the 'Verdana' you have embedded in the child.
One solution I found that seemed to resolve this was to embed the font 'Verdana' in the library of the parent, select export for actionscript, give it a different name obviously to avoid conflict, and then make sure that anywhere in the parent that you have referenced Verdana, make sure you reference this library font.