Wikipedia:Reference desk/Computing: Difference between revisions
Content deleted Content added
Line 330:
<pre>var textLoader:URLLoader = new URLLoader();
var textReq:URLRequest = new URLRequest("html.txt");
function textLoaded(event:Event):void
{
}
textLoader.load(textReq);
Line 339 ⟶ 340:
:The HTML above is contained in the <i>html.txt</i> file. Also, HTML and XHTML are almost identical and both will look the same in a browser. XHTML is XML-''based'' but use whichever you want since it doesn't matter at all.--[[User:Hello. I'm new here, but I'm sure I can help out.|Hello. I'm new here, but I'm sure I can help out.]] ([[User talk:Hello. I'm new here, but I'm sure I can help out.|talk]]) 08:27, 23 July 2008 (UTC)
::Hi, thanks for the response. Yes, I have Flash CS3 Professional, but unfortunately I'm not very proficient at ActionScript. Your script works great, thank you! However, would there be a way to also include formatting such as colors, sizes, etc. from the text file, or would I have to manually do that in the text field? Also, I'm assuming that I'd be able to call a new file when a button is clicked? Thanks, [[User:vic93|<b><font color="#00ff00" size="3" face="Monotype Corsiva">''Valens''</font> <font color="#000000" face="Cambria Math">Impérial</font> <font color="ff0000" face="Century">Császár</font>]] [[User talk:vic93|<font color="#0000ff">93</font></b>]] 23:17, 23 July 2008 (UTC)
:::Hi. You're welcome. The text file you reference can contain HTML tags, but Flash will only render some of them (e.g., links, lists, etc.), and not others (e.g., text coloring). If you're using CSS for formatting, then you can reference a CSS file (''style.css'' below) in addition to the HTML like so:
<pre>var textLoader:URLLoader = new URLLoader();
var textReq:URLRequest = new URLRequest("html.txt");
var cssLoader:URLLoader = new URLLoader();
var cssRequest:URLRequest = new URLRequest("style.css");
var style:StyleSheet = new StyleSheet();
function textLoaded(event:Event):void
{
cssLoader.load(cssRequest);
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
}
function cssLoaded(event:Event):void
{
style.parseCSS(cssLoader.data);
external_txt.styleSheet = style;
external_txt.htmlText = textLoader.data;
}
textLoader.load(textReq);
textLoader.addEventListener(Event.COMPLETE, textLoaded);</pre>
:::Also, I forgot to mention that the text field has to be dynamic in order to be given an instance name.--[[User:Hello. I'm new here, but I'm sure I can help out.|Hello. I'm new here, but I'm sure I can help out.]] ([[User talk:Hello. I'm new here, but I'm sure I can help out.|talk]]) 04:36, 24 July 2008 (UTC)
= July 23 =
|