Scripting help needed... switching layers?

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

Scripting help needed... switching layers?

Post by AndrewWickliffe » Tue Jul 11, 2006 7:51 pm

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
Location: Ostenfeld germany
Contact:

Post by malte » Tue Jul 11, 2006 8:28 pm

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 » Tue Jul 11, 2006 8:33 pm

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
Location: Ostenfeld germany
Contact:

Post by malte » Tue Jul 11, 2006 8:47 pm

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 » Tue Jul 11, 2006 8:50 pm

great, thanks!

Post Reply

Return to “Talking LiveCode”