Page 1 of 1
Embedding linked images, and general mobile workflow...
Posted: Sat Feb 16, 2013 1:51 am
by PaulMaguire
Hi again.
Quite simply - how do I embed a linked image? Say I wanted to wrap the whole thing up for iOS but I had a few linked images. How do I embed them after I have linked them? I have been linking images from development media folders thinking I could embed them all once done (I sometimes do this in Director). But when I publish to iOS the links break and the media doesn't appear so I can't preview my work. Still trying to get to grips with Livecode workflow (coming from Director). Not too sure in Livecode how to best organise media eg. large maps which don't need loaded unless used.
Any wisdom appreciated.
Kind regards, Paul.
Re: Embedding linked images, and general mobile workflow...
Posted: Sat Feb 16, 2013 11:44 am
by Klaus
Hi Paul,
basically you "put" the imagefile (the fielname) of that image INTO that image

I have a little script which does it for me, so I can use (and modify) referenced
images and before deployment I "import" then into the stack.
It just loops through the stack and all cards, and "imports" every referenced image.
Code: Select all
on mouseUp
## This line is optional
set the defaultstack to "name of your stack here"
lock screen
lock messages
repeat with i = 1 to the num of cds
set cursor to busy
repeat with k = 1 to the num of images of cd i
put the filename of image k of cd i into tImageFileName
## Only process referenced images!
if tImageFileName = empty then
next repeat
end if
## Import the file into stack
put url("binfile:" & it) into image k of cd i
end repeat
end repeat
unlock screen
unlock messages
answer "Done!" & CR & "Don't forget to save stack" && QUOTE & auswahl & QUOTE & "!"
end mouseUp
Best
Klaus
Re: Embedding linked images, and general mobile workflow...
Posted: Mon Feb 18, 2013 7:21 pm
by PaulMaguire
Excellent Klaus - danke sehr!
Re: Embedding linked images, and general mobile workflow...
Posted: Mon Feb 18, 2013 11:16 pm
by PaulMaguire
Ok so I can't in fact get this to work - it doesn't embed the file but just loses the reference. It has to do with the fact the following I think:
put the filename of image 1 of cd 1
./Media/bg01.png
put the defaultFolder
/Applications
Your routine has the following line:
put url("binfile:" & it) into image k of cd i
The documentation says (about binfile):
"The binfile scheme indicates a binary file which is located on the user's system. The file is specified by either a full path starting with "/", or a relative path starting from the defaultFolder."
The documentation also says (about defaultFolder):
"When a LiveCode application starts up, the defaultFolder initially contains whatever the working directory was at the time the application was launched. Typically this is the folder that the application resides in, however this is not always the case and shouldn't be relied on. It is best always to set the defaultFolder before using relative paths.
...
If you specify a file without giving its full path, LiveCode looks for the file in the defaultFolder. If you specify a relative path, the defaultFolder is prepended to it to create the full path."
So I'm creating a bad path. I have a folder called Media next to my Livecode source file. How do I point to this directory? In Director I use 'the moviePath" which returns the directory of the authoring file, then append the local directory. Sorry - still getting to grips with the syntax...
Kind regards, Paul.
Re: Embedding linked images, and general mobile workflow...
Posted: Mon Feb 18, 2013 11:31 pm
by PaulMaguire
I have resolved this. It was to do with the 'it' keyword as the filename in the line:
url("binfile:" & it)
I replaced 'it' with tImageFileName and it works. This slightly modified script now works for me:
Code: Select all
on doEmbedLinkedMedia
lock screen
lock messages
repeat with i = 1 to the num of cds
set cursor to busy
repeat with k = 1 to the num of images of cd i
put the filename of image k of cd i into tImageFileName
## Only process referenced images!
if tImageFileName = empty then
next repeat
end if
## Import the file into stack
put url("binfile:" & tImageFileName) into image k of cd i
put "card"&&i&&"image"&&k&&"embedded!"
end repeat
end repeat
unlock screen
unlock messages
answer "Done!" & CR & "Don't forget to save stack!"
end doEmbedLinkedMedia
Kind regards, Paul.
Re: Embedding linked images, and general mobile workflow...
Posted: Tue Feb 19, 2013 6:38 pm
by Klaus
Hi Paul,
ah, oh, yes, the script is from a time, where Livecode did not support relative filenames of images
Best
Klaus