Page 1 of 1
DoMenu woes
Posted: Fri May 12, 2017 3:55 pm
by sbonham
I'm stuck...
Code: Select all
on mouseUp
select img "girl.png"
doMenu "Duplicate Objects" of Menu "Edit"
put "GHOST" & the short name of the selected image into NewShortName
set the short name of the selected image to NewShortName
set the ink of img NewShortName to "blend"
set the blendLevel of image NewShortName to 50
show image "GHOSTgirl.png" at the loc of image "girl.png"
hide image "girl.png"
end mouseUp
The code above selects the image "girl.png" and NOTHING else...
suggestions?
Re: DoMenu woes
Posted: Fri May 12, 2017 4:25 pm
by Klaus
Hi Steve,
your script does not even compile. Here some reasons for the failing:
1. there is nothing like "the selected image" only "the selectedobject"
2. From the dictionary about "doMenu":
...
The doMenu command is not implemented for all menu items. This command is included in LiveCode for compatibility with imported HyperCard stacks.
...
So "Duplicate Objects" obviously is not supported, that's why you only have ONE image in the end.
3. You cannot "set the short name of img xyz" only "set the name of img xyz". Illogical but true
This does work, and don't forget to LOCK SCREEN, so the user will not see what is going on:
Code: Select all
on mouseUp
lock screen
## This is what the "Duplicate Objects" menu actually does:
clone img "girl.png"
put "GHOST" & the short name of last img into NewShortName
## New and cloned objects always have the highest layer number:
set the name of last img to NewShortName
set the ink of img NewShortName to "blend"
set the blendLevel of image NewShortName to 50
## "show xyz AT..." does not work -> error
## show image "GHOSTgirl.png" at the loc of image "girl.png"
## You want to:
set the loc of last img to the loc of image "girl.png"
hide image "girl.png"
unlock screen
end mouseUp
Best
Klaus
Re: DoMenu woes
Posted: Fri May 12, 2017 6:58 pm
by sbonham
Thank-you Klaus!
I'll try this now!
Re: DoMenu woes
Posted: Fri May 12, 2017 7:03 pm
by sbonham
I didn't know about the "CLONE" option!
That's Awesome! Worked beautifully!!!
Re: DoMenu woes
Posted: Sun May 14, 2017 4:56 pm
by sbonham
Problems with delete image VarName...
Klaus, I've got the Ghosts coming in fine and now want to delete them by gradually deleting them as their trail lengthens...
Here's what my code looks like - but it is not working properly I'm thinking it's because I'm using a variableName (Ghost2Delete)...
Field "Ghosts" contains the file names of the images that were cloned... so that they can be deleted after they have left a "trail" of images... -- after 10 are displayed in slightly different locations (a path) the first - (and successive ones eventually) disappear(s)...
but - nothing is disappearing... since this is not a "last image" case I'm wondering what the solution might be...
Code: Select all
put 1 into lineNo
put the number of lines of fld "ghosts" into Reps
repeat Reps
put 1 into itemNum
put the number of items of line LineNo of fld "Ghosts" into Reps2
repeat Reps2
put item itemNum of line LineNo of fld "Ghosts" into Ghost2Delete
delete image Ghost2Delete
put itemNum
add 1 to ItemNum
end repeat
add 1 to lineNo
end repeat
put empty into fld "Ghosts"
Re: DoMenu woes
Posted: Sun May 14, 2017 6:32 pm
by Klaus
Hi Steve,
do you want to delete the GHOST images or the original images?
I guess the GHOST images, right? Then you need to:
Code: Select all
...
LOCK SCREEN
...
repeat Reps2
put item itemNum of line LineNo of fld "Ghosts" into Ghost2Delete
put "GHOST" & Ghost2Delete into img2Del
if there is an img img2Del then
delete image img2Del
end if
...
UNLOCK SCREEN
...
Not?
Best
Klaus