This is the first of two ways to send Text to Flash using HTML and JavaScript. To follow my example, you must download and link to [SWFObject](http://blog.deconcept.com/swfobject/).
<!--
/*******************************
This Code Goes inside your FLA
*******************************/
import flash.external.ExternalInterface;
import flash.events.Event;
ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);
function getTextFromJavaScript(str:String):void {
textTxt.appendText(str);
}
var textTxt:TextField = new TextField();
textTxt.x = 0;
textTxt.y = 0;
addChild(textTxt);
-->
<!--
/*******************************
THis Lives in your HTML FILE
*******************************/
-->
<html>
<head>
<!-- Flash swfObject v1.5 -->
<script type="text/javascript" src="./js/swfobject.js"></script>
<!-- Flash swfObject v1.5 -->
<!-- Send Text to Flash -->
<script language="JavaScript">
function getFlashMovie(movieName) {
var isIE = navigator.appName.indexOf("Microsoft") != -1;
return (isIE) ? window[movieName] : document[movieName];
}
function collectText(string) {
var text = string;
getFlashMovie("NAME_OF_FLASH_BLOCK").sendTextToFlash(text);
}
</script>
<!-- Send Text to Flash -->
</head>
<body onload="javascript:collectText(document.getElementById('welcome').innerHTML);">
<p id="welcome">Ut urna lorem, sodales in, iaculis, vel heicula eu, magna. Donec ultricies toror t</p>
<!-- Media Player starts -->
<div id="media_player">
<a href="http://www.adobe.com/go/getflash/" target="_blank"> Please Upgrade to Flash 9.0</a>
</div>
<script type="text/javascript">
// <![CDATA[
var so = new SWFObject("FLASHMOVIE.swf", "NAME_OF_FLASH_BLOCK", "700", "370", "9.0", "#ffffff");
so.write("media_player");
// ]]>
</script>
<!-- Media Player ends -->
</body>
</html>
AS3: Regular Expression Basics
Here are some Regular Expression basics in Actionscript 3. 1. RegExp.text(string) returns a Boolean 2. RegExp.exec(string) returns an Object 3. String.search(pattern) returns...
AS3: Regular Expression Basic example
The first example strips out the HTML. The second example shows how to target a single quote using unicode. //////////////////////////////////////////// //Example 1: //////////////////////////////////////////// var re:RegExp = /<font face=\u0022(...
AS2: Inline CSS
This shows how to create Cascading Style Sheets using ActionScript. /************************** CSS Translation of Properties **************************/ /* HTML ActionScript color color display display font-family fontFamily font-size fontSize font-weight fontWeight margin-left marginLeft...