I made a simple application in flex 3. The code is below.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
private function browseFile():void
{
var fr:FileReference = new FileReference();
fr.addEventListener(Event.SELECT, onFileSelect);
fr.browse();
}
private function onFileSelect(evt:Event):void
{
trace(evt.currentTarget);
}
]]>
</mx:Script>
<mx:Button click="browseFile()" />
</mx:Application>
The case is that Event.SELECT
never get fired. But if I make the fr
reference of FileReference global(i.e. declared it outside any function), the Event.SELECT
gets fired.
Please Note that this happens only in Flex 3. In Flex 4, its working fine in both cases.
Does It has to do something with Garbage Collection Mechanism in Actionscript? Can anybody explain please? I am just curious to know the reason.