Page 1 of 1

Copying referenced images issue...

Posted: Wed Mar 13, 2013 7:26 pm
by PaulMaguire
Hi.

More simple lamer stuff I don't quite understand in Livecode!
This only fails when my image assets are referenced rather than embedded.
I don't want to embed all the assets (they are changing throughout development and I am replacing them). This is ultimately for a mobile app (I have the assets folder in the 'CopyFiles' file path).
Here's how I am getting the image:

Code: Select all

   put image tImageName of cd "Assets01" of stack "AssetsStack" into image "prepImage" of this card
(tImageName is a string eg. "thisImage.jpg"). I am actually taking this prepImage and putting it into a scrollable field - it appears (ie. it has dimensions) but is blank. Am I missing something here (um, clearly)? Any pointers appreciated.

Kind regards, Paul.

Re: Copying referenced images issue...

Posted: Thu Mar 14, 2013 9:58 am
by Klaus
Hi Paul,

you need to "copy" the FILENAME, since "img whatever" is "empty" in this case!

Code: Select all

...
set the filename of img "prepImage" of this card to the filename of image tImageName of cd "Assets01" of stack "AssetsStack"
...
Or if you are not sure if the image is referenced or imported:

Code: Select all

...
if the filename of image tImageName of cd "Assets01" of stack "AssetsStack" = EMPTY then
   ## imported -> copy the image itself
   put image tImageName of cd "Assets01" of stack "AssetsStack" into image "prepImage" of this card
else
  ## only "copy" the filename
  set the filename of img "prepImage" of this card to the filename of image tImageName of cd "Assets01" of stack "AssetsStack"
end if
...
Best

Klaus

Re: Copying referenced images issue...

Posted: Thu Mar 14, 2013 11:07 am
by PaulMaguire
THANK YOU KLAUS!