Showing posts with label passing variables into flex from swf. Show all posts
Showing posts with label passing variables into flex from swf. Show all posts
Monday, May 11, 2009
Flex talking to Flash
Here's another good refresher on getting a Flex app synched up with Flash swf resources, this time at giantflyingsaucer.com. I'll post a link to a tutorial on Flex with Flash-compiled swcs as soon as I come across one. Any favorites out there?
Labels:
flex 3,
passing variables into flex from swf,
swc
Accessing swf vars from Flex
Ever need your memory jogged on the topic of putting swf vars into your Flex app? Here's just the thing for that:
Flash cs3 as3 file "click.swf"
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>
Subscribe to:
Posts (Atom)