Page 1 of 3
Rename an Icon?
Posted: Mon Mar 25, 2024 4:41 am
by pugalug
Hello,
I have imported as control some image files and saved them to a separate card in my stack. I want to use these images as button icons. I am making a spinner game and the id of the images keeps changing. For example, my image is called horse and it's ID is 210041 in the icon menu. I go into my code and change it to reflect the ID 210041 and go back and find it is now changed to 210053 (or something similar) I have looked at the remote control tutorial and it mentions going to the "player card" and also the "property inspector" and select "icons." The latest liveCode version doesn't have these and I don't know how to rename the images so that they don't keep changing numbers. I would like to name them "horse" etc. without a number if possible but if I do need to use a number, how do I get an icon number that won't change? Thank you!
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 9:43 am
by stam
The latest livecode has all the stuff you say it doesn’t… but I suppose that’s an indictment of the IDE more than anything else.
The “numbers” you mention are (or should be) the “id” which all controls and visible constructs have. The name is independent of this and. You can carnage the names without consequence.
Be aware the id will change if you copy/past the image however - it’s allocated by the IDE.
The are are multiple nuances to “name”.
The name as such includes the class (ie image <myImage>)
The short name is the purr name (ie <myImage>)
The long name fully qualifies full ownership of the control (ie image <myImage> of card <myCard> of stack <myStack>)
OR you can refer to it by id, which is unique to the stack (ie image id 10024)
Likewise the long id fully qualifies ownership (ie image id 12345 of card 43435 of stack )
The inspector appears any time you double click on a control. In contrast to older tutorials, the various sections in the PI are now tiny icons at the top of the inspector. If you open the PI for a button you will see a section for icons…
Hope this answers your questions?
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 10:02 am
by richmond62
You can, obviously, name all the images you use as icons.
If you want to give your images numbers, then to avoid the problem with the IDE mucking around with image ID numbers surely the best thing to do is name the images with numbers?
This will mean that the image you name "27" will still be called "27" if the IDE for some reason changes image "27"'s ID from 2013 to 2078.
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 10:43 am
by bn
richmond62 wrote: ↑Mon Mar 25, 2024 10:02 am
You can, obviously, name all the images you use as icons.
If you want to give your images numbers, then to avoid the problem with the IDE mucking around with image ID numbers surely the best thing to do is name the images with numbers?
This will mean that the image you name "27" will still be called "27" if the IDE for some reason changes image "27"'s ID from 2013 to 2078.
Please do not use numbers to name an object.
From the user guide
Avoid using numbers as object names
search for that string in the user guide for an explanation.
Also you should avoid using numbers as first character of an object name. It is ok to use numbers in object names like "myButton2"
Kind regards
Bernd
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 10:44 am
by stam
GUYS - the OP never stated (s)he was using numbers as names. Quite the opposite...
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 10:59 am
by richmond62
True.
Personally I always do THIS sort of thing when I want numbered image sequences:
'X1', 'X2', 'X3' . . .
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 11:13 am
by bn
Hi Pugalug,
I have imported as control some image files and saved them to a separate card in my stack. I want to use these images as button icons. I am making a spinner game and the id of the images keeps changing
You could name your images like "horse1", "horse2" etc. and then
Code: Select all
set the icon of button "myHorseButton" to the short id of image "horse1" of card "myImages"
Code: Select all
set the icon of button "myHorseButton" to the short id of image "horse2" of card "myImages"
Kind regards
Bernd
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 11:26 am
by richmond62
Yeeeeees: I got hold of the wrong end of the stick: Sorry.
-
-
https://www.dropbox.com/s/kzcrkbqsyfzej ... e.zip?dl=0
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 12:21 pm
by stam
The OP's issue was that the ID he was using appears to be changing. The naming is a different issue.
I'm not aware this can happen unless the image has been duplicated/pasted - but perhaps I'm wrong.
S.
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 12:38 pm
by richmond62
Once an image has been imported into a stack its ID should never change.
The only way I can see someone thinking this is happening is if they are copy-pasting and/or duplicating the image onto different cards.
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 2:47 pm
by dunbarx
I imported an image onto a card and recorded the ID that LC assigned to it: 1003
I then cut the image and immediately pasted it. The ID of that image was 1006.
This all makes sense to me. The IDE creates ID's as controls are created, without any thought to maintaining their original assignments. It obviously keeps track of previous assignments, and cares nothing about the fact that it is the very same control put back in the very same location. But is that sort of thing the issue is here?
Craig
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 2:55 pm
by dunbarx
Comforting is the fact that all other properties, like the control name, are held constant. The ID is therefore a different kind of property than any other, pertinent to the ongoing development of the controls comprising a stack, as opposed to any information about the controls themselves.
I suppose one could conceivably keep track of all the ID's ever created in a stack, and find a use for that number in some way. My test stack had just one control, but two historical ID's.
Craig
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 7:02 pm
by pugalug
stam wrote: ↑Mon Mar 25, 2024 9:43 am
The inspector appears any time you double click on a control. In contrast to older tutorials, the various sections in the PI are now tiny icons at the top of the inspector. If you open the PI for a button you will see a section for icons…
Hope this answers your questions?
Thank you for your reply. I double clicked on the button with my icon on it and sure enough, it opened the project browser for that icon and now it shows a different id for it. Last night this icon id was 210041 and today it is 210052. I don't understand why and how I can keep it the same so I can code properly.
(I'm still studying everything else you and the others mentioned but this stuck out as applying perfectly to my problem) Thank you so much!
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 7:13 pm
by pugalug
richmond62 wrote: ↑Mon Mar 25, 2024 10:02 am
You can, obviously, name all the images you use as icons.
If you want to give your images numbers, then to avoid the problem with the IDE mucking around with image ID numbers surely the best thing to do is name the images with numbers?
This will mean that the image you name "27" will still be called "27" if the IDE for some reason changes image "27"'s ID from 2013 to 2078.
Thank you for the reply! No, I don't want to give them numbers for names. I am just trying to figure out how to keep their id the same so I can code my statements properly. I am not understanding why the icon id is changing. Maybe I don't need to worry about the id name? I am still learning - and enjoying doing so.
Re: Rename an Icon?
Posted: Mon Mar 25, 2024 7:18 pm
by pugalug
stam wrote: ↑Mon Mar 25, 2024 12:21 pm
The OP's issue was that the ID he was using appears to be changing. The naming is a different issue.
I'm not aware this can happen unless the image has been duplicated/pasted - but perhaps I'm wrong.
S.
Yes. This is what is happening. I haven't duplicated or pasted the icon BUT I did duplicate the three buttons. Could that have something to do with the icon names changing?