But it's the flash.netFileReference class that's in play:
private var fileReference:FileReference = new FileReference();
private function onAddFile(event:Event):void {
var filter:FileFilter = new FileFilter("Text", "*.xml");
fileReference.browse([filter]);
fileReference.addEventListener(Event.SELECT, onFileSelect);
fileReference.addEventListener(Event.COMPLETE, onFileComplete);
}
private function onFileSelect(event:Event):void
{
if ("load" in this.fileReference) {
fileReference["load"]();
}
}
private function onFileComplete(event:Event):void
{
var property:String = "data";
myText.text =
fileReference["data"].readUTFBytes(fileReference["data"].length);
}
On Thu, Jul 23, 2009 at 11:51 AM, Beau Scott <[email protected]> wrote:
>
>
> Works fine for me.I just tried it in both 9.0.124 and 10 players:
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="absolute" xmlns:local="*">
> <mx:Script>
> <![CDATA[
> import mx.controls.Label;
> import mx.controls.Alert;
> override protected function childrenCreated():void
> {
> if(this.hasOwnProperty("foo"))
> {
> this["foo"]();
> }
> }
>
> public function foo():void
> {
> var lbl:Label = new Label();
> lbl.text = "It worked";
> addChild(lbl);
> }
> ]]>
> </mx:Script>
> </mx:Application>
>
> Beau
>
>
>
>
> On Thu, Jul 23, 2009 at 12:33 PM, Richard Rodseth <[email protected]>wrote:
>
>>
>>
>> Nope, I've tried that too. Has that worked for you, or are you guessing?
>>
>> On Thu, Jul 23, 2009 at 11:23 AM, Beau Scott <[email protected]>wrote:
>>
>>>
>>>
>>> if(fileReference.hasOwnProperty('load'))
>>> fileReference([load']();
>>>
>>> Beau
>>>
>>>
>>>
>>>
>>> On Thu, Jul 23, 2009 at 12:18 PM, Richard Rodseth <[email protected]>wrote:
>>>
>>>>
>>>>
>>>> Unfortunately,
>>>>
>>>> if ("load" in fileReference)
>>>>
>>>> does not succeed unless I specify Player 10 in the build settings.
>>>>
>>>> On Thu, Jul 23, 2009 at 9:56 AM, Richard Rodseth <[email protected]>wrote:
>>>>
>>>>> Nice! But it's not working for me yet. The "in" expression doesn't
>>>>> succeed. I'll keep digging through the reflection docs, but if you have
>>>>> any
>>>>> refinements, please pass them along.
>>>>>
>>>>>
>>>>> On Wed, Jul 22, 2009 at 6:33 PM, Gordon Smith <[email protected]>wrote:
>>>>>
>>>>>>
>>>>>>
>>>>>> Try this:
>>>>>>
>>>>>>
>>>>>>
>>>>>> if ("load" in fileReference)
>>>>>>
>>>>>> fileReference["load"]();
>>>>>>
>>>>>>
>>>>>>
>>>>>> That should compile against the Player 9 version of playerglobal.swc,
>>>>>> but, in Player 10, detect that the method exists and call it by name.
>>>>>>
>>>>>>
>>>>>>
>>>>>> Gordon Smith
>>>>>>
>>>>>> Adobe Flex SDK Team
>>>>>>
>>>>>>
>>>>>>
>>>>>> *From:* [email protected] [mailto:[email protected]]
>>>>>> *On Behalf Of *Richard Rodseth
>>>>>> *Sent:* Wednesday, July 22, 2009 6:12 PM
>>>>>> *To:* [email protected]
>>>>>> *Subject:* [flexcoders] FileReference.load()
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> I was hoping to provide an optional feature that requires reading a
>>>>>> local file if Player 10 is available, without requiring 10 for the whole
>>>>>> application.
>>>>>>
>>>>>> But it appears that I can't compile code that uses
>>>>>> FileReference.load() without setting the target player in FlexBuilder.
>>>>>>
>>>>>> Anyone dealt with this situation?
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> Beau D. Scott
>>> Software Engineer
>>>
>>
>>
>
>
> --
> Beau D. Scott
> Software Engineer
>
>