473,326 Members | 2,148 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

NEED SOME HELP HERE... embedded fonts, css, xml, textfields, dynamic content

I'm dying here trying to figure this out for days.
Here's the scenario:

1) External script.as file dynamically imported to loader.swf file that creates a textfield

(createTextField)
2) Content for the text field should be provided by an XML file
3) Content styled by external css file
4) Fonts need to be embedded so as to apply anti-alias

I can get the XML & CSS to apply to the text field, but can't get the content to use the embedded font. It

usually comes back "undefined" if the embedded font works. Otherwise, when I comment out the embed font, the

content work, but of course, not the anti-aliasing. Ugh. I've tried doing all kinds of forum searches, but

nothing has clarified this for me. I'm intermediate at AS and this is something new to me. Any help will be

GREATLY appreciated and I will send good juju your way.
Here's a sampling of some of the script I have been using:

ACTIONSCRIPT:

mf = new TextFormat();
mf.font = "arial_font";
Stage.scaleMode = "noScale";

this.createTextField("news_txt", 99, 50, 50, 450, 300);
news_txt.border = true;
news_txt.html = true;
news_txt.multiline = true;
news_txt.wordWrap = true;
news_txt.embedFonts = true;
news_txt.autoSize = true;
news_txt.setNewTextFormat(mf);


// Load CSS
var styles:TextField.StyleSheet = new TextField.StyleSheet();
styles.load("heading.css");

// Load XML apply to headingText
var banner_xml:XML = new XML();
banner_xml.ignoreWhite = true;
banner_xml.onLoad = function(success:Boolean):Void {
if (success) {
news_txt.styleSheet = styles;
news_txt.text = banner_xml;
} else {
trace("Error loading XML.");
}
};
banner_xml.load("heading.xml");



XML:

<story>
<title></title>
<mainBody>
<heading>Heading Text</heading>
<tagline>Clever tagline goes here</tagline>
</mainBody>
</story>



CSS:

heading {
color:#000000;
font-family:"Franklin Gothic Book", Arial, sans-serif;
display: block;

font-size: 50pt;
margin: 0px;
padding: 0px;
letter-spacing: -5px;
}

tagline {
color:#000000;
font-size: 20pt;
font-family:"Franklin Gothic Book", Arial, sans-serif;
display: block;
font-weight: bold;
}

So, if I turn off the xml/css and use htmlText to create content for the text field, the text uses the

embedded font and is anti-aliased. If I keep the xml/css but comment out embedFonts, then the content works

but is not anti-aliased. I need both of these to work at the same time. PLEASE HELP!!

peace
Jun 28 '07 #1
1 5582
xNephilimx
213 Expert 100+
I'm dying here trying to figure this out for days.
Here's the scenario:

1) External script.as file dynamically imported to loader.swf file that creates a textfield

(createTextField)
2) Content for the text field should be provided by an XML file
3) Content styled by external css file
4) Fonts need to be embedded so as to apply anti-alias

I can get the XML & CSS to apply to the text field, but can't get the content to use the embedded font. It

usually comes back "undefined" if the embedded font works. Otherwise, when I comment out the embed font, the

content work, but of course, not the anti-aliasing. Ugh. I've tried doing all kinds of forum searches, but

nothing has clarified this for me. I'm intermediate at AS and this is something new to me. Any help will be

GREATLY appreciated and I will send good juju your way.
Here's a sampling of some of the script I have been using:

ACTIONSCRIPT:

mf = new TextFormat();
mf.font = "arial_font";
Stage.scaleMode = "noScale";

this.createTextField("news_txt", 99, 50, 50, 450, 300);
news_txt.border = true;
news_txt.html = true;
news_txt.multiline = true;
news_txt.wordWrap = true;
news_txt.embedFonts = true;
news_txt.autoSize = true;
news_txt.setNewTextFormat(mf);


// Load CSS
var styles:TextField.StyleSheet = new TextField.StyleSheet();
styles.load("heading.css");

// Load XML apply to headingText
var banner_xml:XML = new XML();
banner_xml.ignoreWhite = true;
banner_xml.onLoad = function(success:Boolean):Void {
if (success) {
news_txt.styleSheet = styles;
news_txt.text = banner_xml;
} else {
trace("Error loading XML.");
}
};
banner_xml.load("heading.xml");



XML:

<story>
<title></title>
<mainBody>
<heading>Heading Text</heading>
<tagline>Clever tagline goes here</tagline>
</mainBody>
</story>



CSS:

heading {
color:#000000;
font-family:"Franklin Gothic Book", Arial, sans-serif;
display: block;

font-size: 50pt;
margin: 0px;
padding: 0px;
letter-spacing: -5px;
}

tagline {
color:#000000;
font-size: 20pt;
font-family:"Franklin Gothic Book", Arial, sans-serif;
display: block;
font-weight: bold;
}

So, if I turn off the xml/css and use htmlText to create content for the text field, the text uses the

embedded font and is anti-aliased. If I keep the xml/css but comment out embedFonts, then the content works

but is not anti-aliased. I need both of these to work at the same time. PLEASE HELP!!

peace
I was having the very same problem, I think it's caused by Flah's poor HTML parsing. It only allows certain tags, like <b>, and <a>, unordered list's, paragraphs and I think that's all, if you have content in other tags, like <i> the text won't be displayed. Also sometimes the font you choose is not properly displayed, Trebuchet MS is one that works alright, but it's kinda random. The solution I managed is to make a function to rebuild the HTML tags, since Flash sometimes wrecks it all up, and up till now it works fine.

This is the AS part of an app I've been working in, it's a relevant search:

Expand|Select|Wrap|Line Numbers
  1. Stage.scaleMode = "noScale";
  2.  
  3. var home:MovieClip = this;
  4. var searching:Boolean = false;
  5. var totalresults:Number = 0;
  6.  
  7. var xml:XML = new XML();
  8. xml.ignoreWhite = true;
  9. xml.onLoad = parseXML;
  10.  
  11. buscar.onRelease = function() {
  12.     search(q.text);
  13. }
  14.  
  15. function search(str:String) {
  16.     searching = true;
  17.     clearLastSearch();
  18.     xml.load("rs-xml.php?q=" + str);
  19. }
  20.  
  21. function parseXML() {
  22.     if(searching) {
  23.         var nodes:Array = xml.firstChild.childNodes;
  24.  
  25.         for (i = 0; i < nodes.length; i++) {
  26.             var titulo:String = nodes[i].firstChild.firstChild;
  27.             var texto:String = nodes[i].childNodes[1].firstChild;
  28.             var relev = nodes[i].childNodes[2].firstChild;
  29.  
  30.             var r:MovieClip = attachMovie("result","r"+i,i);
  31.             r._x = 35 + r._width/2;
  32.             r._y = 150 + (r._height*i);
  33.             r.titulo.text = titulo;
  34.             r.texto.htmlText = rebuildHTML(String(texto));
  35.             r.relev.text = "Relevancia: " + relev + "%";
  36.  
  37.             totalresults = (i+1);
  38.         }
  39.     }
  40. }
  41.  
  42. function clearLastSearch() {
  43.     for(i = 0; i < totalresults; i++) {
  44.         home["r"+i].removeMovieClip();
  45.     }
  46. }
  47.  
  48. function rebuildHTML(theText:String):String {
  49.     var tempText:String = theText;
  50.     var chunks:Array = new Array();
  51.  
  52.     chunks = tempText.split("&lt;");
  53.     tempText = chunks.join("<");
  54.     chunks = tempText.split("&gt;");
  55.     tempText = chunks.join(">");
  56.     chunks = tempText.split("&amp;");
  57.     tempText = chunks.join("&");
  58.  
  59.     chunks = tempText.split("href=&quot;");
  60.     tempText = chunks.join("href=\"");
  61.     chunks = tempText.split("&quot;>");
  62.     tempText = chunks.join("\">");
  63.     return tempText;
  64. }
  65.  
There are some spanish words in it, sorry about that, I'm from Argentina...
"texto" means text, "buscar" means serch, "relevancia" means "relevance", sorry if I missed some.

I hope it serves to you.
Jun 29 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Philip | last post by:
Hi, I am trying to output certain nodes inside another. I have an xml template with field definitions for a form, and this includes textfields, labels, checkboxes etc plus fieldssets. I defined...
4
by: Clive Everett | last post by:
I thought it would be rather fun to try out @font-face, but I cannot get it to work. I used Microsoft WEFT to generate several embedded fonts and find that the example below works when I use my...
13
by: Joe Black | last post by:
Just to inform you guys that i have only like 2 weeks that i took my first classes in c++, and my proffesor now is asking me to solve this problem: /// Using a function create a Win32 Console...
3
by: marsandys | last post by:
Hello, I have this code below, which I am trying to have it send HTML formatted mail with embedded images. I can get this to send the mail, but it spits out a bunch of junk . I know this should...
1
by: Hasani \(remove nospam\) | last post by:
The way the system works is, you create a user control (ascx) that will be a template and must implement the interface IPageTemplate. You then create one or more user controls (ascx) that implement...
10
by: pcthug | last post by:
Hi All, I am creating multi-tier app in vb.net using visual studio .net. I create a invoice.vb class file with properties, events and methods. This also has a line item collection class...
20
by: mike | last post by:
I help manage a large web site, one that has over 600 html pages... It's a reference site for ham radio folks and as an example, one page indexes over 1.8 gb of on-line PDF documents. The site...
6
blazedaces
by: blazedaces | last post by:
Hey, so here's an example of what I want to do: This "window" if you will, or simple gui, will accept an ArrayList<String> and in turn spit out for every one of them a checkbox and a text field...
0
by: richard12345 | last post by:
Hi Guys I have problem with site I am building. The sidebar with menu and other thinks is overlapping footer. The footer move with the content and but it dos it dos not move with the sidebar. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.