flex3 - Event.SELECT is not firing for local variables in Flex 3 -
i made simple application in flex 3. code 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 event.select never fired. if make fr reference of filereference global(i.e. declared outside function), event.select gets fired. please note happens in flex 3. in flex 4, working fine in both cases. has garbage collection mechanism in actionscript? can explain please? curious know reason.
yes, has garbage collection. since fr (filereference) variable declared inside function browsefile(), variable exists within function. therefore eligible garbage collected function finishes executing.
the fact seems work in flex 4 little strange, keep in mind garbage collection happens on flash's schedule. chance in flex 4 doesn't garbage collected right away (or maybe flex 4 app uses less memory, garbage collection doesn't happen quickly). bug in flex 4, in keeping reference filereference object, preventing being garbage collected.
Comments
Post a Comment