You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Trevor Holman <tr...@cqproducts.com> on 2014/09/23 23:27:24 UTC
nativePath
image.source = event.target.selectedItem.nativePath;
I’m trying to grab the path of an image file to show a preview when a given file is selected from a file tree directory. However I’m getting a broken image symbol. This is a learning exercise for me so it’s hard for me to tell if the material I’m pulling this from is too outdated or not.
I’ve taken that same image and put it in a asset folder within my application just to make sure it will show up (which it does when I embed it). So I’m assuming my file path is not complete from the code above.
Trevor
RE: nativePath
Posted by Trevor Holman <tr...@mchsi.com>.
It's a selectedItem from files from any given directory I might have images in.
-----Original Message-----
From: Justin Ransom Dallas [mailto:justindallas@gmail.com]
Sent: Tuesday, September 23, 2014 4:52 PM
To: users@flex.apache.org
Subject: Re: nativePath
Are you sure you aren't dealing with a null event.target or selectedItem
On Tuesday, September 23, 2014, Trevor Holman <tr...@cqproducts.com> wrote:
> image.source = event.target.selectedItem.nativePath;
>
>
> I’m trying to grab the path of an image file to show a preview when a
> given file is selected from a file tree directory. However I’m getting
> a broken image symbol. This is a learning exercise for me so it’s hard
> for me to tell if the material I’m pulling this from is too outdated or not.
>
> I’ve taken that same image and put it in a asset folder within my
> application just to make sure it will show up (which it does when I
> embed it). So I’m assuming my file path is not complete from the code above.
>
> Trevor
--
Justin Dallas
Phone:814-880-5637
Re: nativePath
Posted by Trevor Holman <tr...@cqproducts.com>.
the url worked perfect, thanks.
On Sep 23, 2014, at 5:42 PM, Subscriptions <su...@leeburrows.com> wrote:
> if event.target.selectedItem is a File object, try event.target.selectedItem.url instead
>
> On 23/09/2014 22:52, Justin Ransom Dallas wrote:
>> Are you sure you aren't dealing with a null event.target or selectedItem
>>
>> On Tuesday, September 23, 2014, Trevor Holman <tr...@cqproducts.com> wrote:
>>
>>> image.source = event.target.selectedItem.nativePath;
>>>
>>>
>>> I’m trying to grab the path of an image file to show a preview when a
>>> given file is selected from a file tree directory. However I’m getting a
>>> broken image symbol. This is a learning exercise for me so it’s hard for me
>>> to tell if the material I’m pulling this from is too outdated or not.
>>>
>>> I’ve taken that same image and put it in a asset folder within my
>>> application just to make sure it will show up (which it does when I embed
>>> it). So I’m assuming my file path is not complete from the code above.
>>>
>>> Trevor
>>
>>
>
> --
> Lee Burrows
> ActionScripter
>
Re: nativePath
Posted by Subscriptions <su...@leeburrows.com>.
if event.target.selectedItem is a File object, try
event.target.selectedItem.url instead
On 23/09/2014 22:52, Justin Ransom Dallas wrote:
> Are you sure you aren't dealing with a null event.target or selectedItem
>
> On Tuesday, September 23, 2014, Trevor Holman <tr...@cqproducts.com> wrote:
>
>> image.source = event.target.selectedItem.nativePath;
>>
>>
>> I’m trying to grab the path of an image file to show a preview when a
>> given file is selected from a file tree directory. However I’m getting a
>> broken image symbol. This is a learning exercise for me so it’s hard for me
>> to tell if the material I’m pulling this from is too outdated or not.
>>
>> I’ve taken that same image and put it in a asset folder within my
>> application just to make sure it will show up (which it does when I embed
>> it). So I’m assuming my file path is not complete from the code above.
>>
>> Trevor
>
>
--
Lee Burrows
ActionScripter
Re: nativePath
Posted by Justin Ransom Dallas <ju...@gmail.com>.
Are you sure you aren't dealing with a null event.target or selectedItem
On Tuesday, September 23, 2014, Trevor Holman <tr...@cqproducts.com> wrote:
> image.source = event.target.selectedItem.nativePath;
>
>
> I’m trying to grab the path of an image file to show a preview when a
> given file is selected from a file tree directory. However I’m getting a
> broken image symbol. This is a learning exercise for me so it’s hard for me
> to tell if the material I’m pulling this from is too outdated or not.
>
> I’ve taken that same image and put it in a asset folder within my
> application just to make sure it will show up (which it does when I embed
> it). So I’m assuming my file path is not complete from the code above.
>
> Trevor
--
Justin Dallas
Phone:814-880-5637
Re: nativePath
Posted by Peter Ginneberge <p....@gmail.com>.
File.nativePath should only really be used for display (e.g. in a tooltip,
etc..). Use File.url to actually load the file.
event.currentTarget is preferred as event.target doesn't always refer to the
component that the event was assigned to.
Then you should also cast the selectedItem to the class you expect it to be.
var f:File = event.currentTarget.selectedItem as File;
if(f != null) {
trace(" - path: ", f.nativePath);
image.source = f.url;
}
regards,
Peter
On 23/09/2014 23:27, Trevor Holman wrote:
> image.source = event.target.selectedItem.nativePath;
>
>
> I’m trying to grab the path of an image file to show a preview when a given file is selected from a file tree directory. However I’m getting a broken image symbol. This is a learning exercise for me so it’s hard for me to tell if the material I’m pulling this from is too outdated or not.
>
> I’ve taken that same image and put it in a asset folder within my application just to make sure it will show up (which it does when I embed it). So I’m assuming my file path is not complete from the code above.
>
> Trevor
>