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
1 5582
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: -
Stage.scaleMode = "noScale";
-
-
var home:MovieClip = this;
-
var searching:Boolean = false;
-
var totalresults:Number = 0;
-
-
var xml:XML = new XML();
-
xml.ignoreWhite = true;
-
xml.onLoad = parseXML;
-
-
buscar.onRelease = function() {
-
search(q.text);
-
}
-
-
function search(str:String) {
-
searching = true;
-
clearLastSearch();
-
xml.load("rs-xml.php?q=" + str);
-
}
-
-
function parseXML() {
-
if(searching) {
-
var nodes:Array = xml.firstChild.childNodes;
-
-
for (i = 0; i < nodes.length; i++) {
-
var titulo:String = nodes[i].firstChild.firstChild;
-
var texto:String = nodes[i].childNodes[1].firstChild;
-
var relev = nodes[i].childNodes[2].firstChild;
-
-
var r:MovieClip = attachMovie("result","r"+i,i);
-
r._x = 35 + r._width/2;
-
r._y = 150 + (r._height*i);
-
r.titulo.text = titulo;
-
r.texto.htmlText = rebuildHTML(String(texto));
-
r.relev.text = "Relevancia: " + relev + "%";
-
-
totalresults = (i+1);
-
}
-
}
-
}
-
-
function clearLastSearch() {
-
for(i = 0; i < totalresults; i++) {
-
home["r"+i].removeMovieClip();
-
}
-
}
-
-
function rebuildHTML(theText:String):String {
-
var tempText:String = theText;
-
var chunks:Array = new Array();
-
-
chunks = tempText.split("<");
-
tempText = chunks.join("<");
-
chunks = tempText.split(">");
-
tempText = chunks.join(">");
-
chunks = tempText.split("&");
-
tempText = chunks.join("&");
-
-
chunks = tempText.split("href="");
-
tempText = chunks.join("href=\"");
-
chunks = tempText.split("">");
-
tempText = chunks.join("\">");
-
return tempText;
-
}
-
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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. ...
|
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...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
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...
|
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)...
|
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...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
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
|
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...
|
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...
| | |