Interesting! If it's true I think it has to do with there being a difference in
major version number, and that number getting written into the SWF header. It
may well be that Player 10 APIs are made invisible to a SWF whose header says
it is for Player 9. I think this may be how the addition of the z property to
DisplayObject was added without disruption to SWFs that defined their own
subclasses with a z property.
I'm pretty sure that it doesn't apply for minor version changes. For example if
you compile with a playerglobal.swc for 10.0, I'm almost certain that you can
use code like
if ("doSomething" in obj)
obj["doSomething"]();
to look for and call a doSomething() method that has been added for 10.1. But
that's doesn't help you.
Gordon Smith
Adobe Flex SDK Team
From: [email protected] [mailto:[email protected]] On Behalf
Of Richard Rodseth
Sent: Thursday, July 23, 2009 3:42 PM
To: [email protected]
Subject: Re: [flexcoders] FileReference.load()
Thanks for the explanation. More or less what I expected until Gordon made his
suggestion.
I think I have approval to require 10, but I'd still be interested to know if
Gordon concurs with your conclusion.
On Thu, Jul 23, 2009 at 12:19 PM, Beau Scott
<[email protected]<mailto:[email protected]>> wrote:
Ah, I see what you're saying now. The answer is you're not going to be able to
do it unless you use 10, because the compiler looks at the compatible player
version and includes version-specific swcs at compile time (Flex Builder 3
Plug-in\sdks\3.2.0\frameworks\libs\player\9\playerglobal.swc vs Flex Builder 3
Plug-in\sdks\3.2.0\frameworks\libs\player\10\playerglobal.swc). Therefore
"load" will never be available no matter what player is playing it if you're
specifiying 9 as the lowest compatible version. These libs don't exist in the
player itself, it's supplied by the swf.
Beau
On Thu, Jul 23, 2009 at 12:57 PM, Richard Rodseth
<[email protected]<mailto:[email protected]>> wrote:
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]<mailto:[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]<mailto:[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]<mailto:[email protected]>> wrote:
if(fileReference.hasOwnProperty('load'))
fileReference([load']();
Beau
On Thu, Jul 23, 2009 at 12:18 PM, Richard Rodseth
<[email protected]<mailto:[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]<mailto:[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]<mailto:[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]>
[mailto:[email protected]<mailto:[email protected]>] On
Behalf Of Richard Rodseth
Sent: Wednesday, July 22, 2009 6:12 PM
To: [email protected]<mailto:[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
--
Beau D. Scott
Software Engineer