473,701 Members | 2,763 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

2 New Member
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

(createTextFiel d)
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.createText Field("news_txt ", 99, 50, 50, 450, 300);
news_txt.border = true;
news_txt.html = true;
news_txt.multil ine = true;
news_txt.wordWr ap = true;
news_txt.embedF onts = true;
news_txt.autoSi ze = true;
news_txt.setNew TextFormat(mf);


// Load CSS
var styles:TextFiel d.StyleSheet = new TextField.Style Sheet();
styles.load("he ading.css");

// Load XML apply to headingText
var banner_xml:XML = new XML();
banner_xml.igno reWhite = true;
banner_xml.onLo ad = function(succes s:Boolean):Void {
if (success) {
news_txt.styleS heet = styles;
news_txt.text = banner_xml;
} else {
trace("Error loading XML.");
}
};
banner_xml.load ("heading.xml") ;



XML:

<story>
<title></title>
<mainBody>
<heading>Headin g Text</heading>
<tagline>Clev er tagline goes here</tagline>
</mainBody>
</story>



CSS:

heading {
color:#000000;
font-family:"Frankli n 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:"Frankli n 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 5614
xNephilimx
213 Recognized Expert New Member
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

(createTextFiel d)
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.createText Field("news_txt ", 99, 50, 50, 450, 300);
news_txt.border = true;
news_txt.html = true;
news_txt.multil ine = true;
news_txt.wordWr ap = true;
news_txt.embedF onts = true;
news_txt.autoSi ze = true;
news_txt.setNew TextFormat(mf);


// Load CSS
var styles:TextFiel d.StyleSheet = new TextField.Style Sheet();
styles.load("he ading.css");

// Load XML apply to headingText
var banner_xml:XML = new XML();
banner_xml.igno reWhite = true;
banner_xml.onLo ad = function(succes s:Boolean):Void {
if (success) {
news_txt.styleS heet = styles;
news_txt.text = banner_xml;
} else {
trace("Error loading XML.");
}
};
banner_xml.load ("heading.xml") ;



XML:

<story>
<title></title>
<mainBody>
<heading>Headin g Text</heading>
<tagline>Clev er tagline goes here</tagline>
</mainBody>
</story>



CSS:

heading {
color:#000000;
font-family:"Frankli n 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:"Frankli n 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
1893
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 them like this: >>>> XML SNIPPET >>>> <fields>
4
4243
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 Win XP development machine as both the browser and Web server. However if I try to display the same page from another machine (Mac OS X, Win 2000, or Win XP) using the Win XP development machine as the Web server then I get the default font...
13
1605
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 Application which outputs asterisks (*)on the screen displaying your name like a matrix screen. it has to be in a top down-design style. PLS HELP THIS AMATEUR STUDENT. *_* if you can help me just send the source code... even that i cant do that...
3
2133
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 be pretty simple, but I have been pulling my hair out for hours with this. :/ Can someone smart pleaseeee help me tweak this code to work? <?php // Read POST request params into global vars
1
1774
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 the IPageContent interface. A page (aspx) must then be created that loads (using Page.LoadControl) the page template, and the page content. The page content adds itself to the page template. The page template is then added to the aspx's control...
10
1484
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 (lineitem.vb & lineitems.vb). I create a form (form1.frm) and write the corresponding code to initialize an invoice object, there are textboxes on the form to display the data, an update and load button. My data is stored in an access database.
20
4272
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 is structured as an upside-down tree, and (if I remember correctly) never more than 4 levels. The site basically grew (like the creeping black blob) ... all the pages were created in Notepad over the last
6
1940
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 where you can rename it to whatever name you chose (later I'll add something to check and make sure none of the names are the same... but for now it doesn't matter). I'm not very familiar with GUI in java so I don't know the best way of doing this. ...
0
2843
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. Here is the website: holtz-realty And also the html file and css file. Anny help will by mostly appreciated. I did try everything I can think of. HTML:
0
8738
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9233
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8936
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7829
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6575
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4665
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3104
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2036
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.