Scripting help needed... switching layers?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
AndrewWickliffe
Posts: 12
Joined: Tue Jun 20, 2006 8:11 pm

Scripting help needed... switching layers?

Post by AndrewWickliffe »

Is it possible to get the layer # of an object and use it in scripting.

Or, simplier, is it possible to switch the layers of a couple objects?

TIA
malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte »

Hi,

you are almost there.

script snippets:

get the layer of btn "myButton"
set the layer of grc "myGraphic" to 1
set the layer of img "myImage" to the number of layers

Hope that helps,

Malte
AndrewWickliffe
Posts: 12
Joined: Tue Jun 20, 2006 8:11 pm

Post by AndrewWickliffe »

Thanks.

if I use the "get the layer" command, can I save that data so I can set another image to that layer?

get the layer of btn "myButton"
(new command here)
set the layer of btn "myNewButton" to (the result of that command)

Thanks again,
Andrew
malte
Posts: 1098
Joined: Thu Feb 23, 2006 8:34 pm
Contact:

Post by malte »

If you use get the result is stored in the it variable.

get the layer of btn "myButton"
set the layer of btn "myOtherButton" to it

You could also use a temporary var like this.

put the layer of btn "myButton" into tOldLayer
set the layer of btn "myOtherButton" to tOldLayer

All the best,

Malte
AndrewWickliffe
Posts: 12
Joined: Tue Jun 20, 2006 8:11 pm

Post by AndrewWickliffe »

great, thanks!
Post Reply