Flash cs3 as3 file "click.swf"
ActionScript Code:
MXML Flex 2.0click_mc.addEventListener(MouseEvent.CLICK, reportClick);
var output:String = new String();
function reportClick(evt:MouseEvent):void
{
for(var i:int = 0; i<5; i++) {
output += "I have been clicked. i = " + i + "\n";
}
}
ActionScript Code:
Made for Flex 2 but perfectly applicable to 3, 4 and perhaps beyond... Thanks to the forums at actionscript.org for this one.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function updateTextField():void
{
output_txt.text += swf.content["output"];
}
]]>
</mx:Script>
<mx:SWFLoader x="10" y="10" source="click.swf" scaleContent="false" id="swf" click="updateTextField()"/>
<mx:TextArea x="10" y="518" width="550" height="211" id="output_txt"/>
</mx:Application>
No comments:
Post a Comment