Scripts, tutorials, and general Desktop X help
Published on June 19, 2006 By sViz In Object Desktop
My object has 2 states. There's a different picture for each state. How do I remotely change the picture for each state keeping in mind that each state has a different picture assigned to it. I have tried: DesktopX.Object("myob").State("state1").Picture = "mypic.png" DesktopX.Object("myob").State("state2").Picture = "mypic2.png" but that did not work. Am I missing something? Any suggestions are greatly appreciated. Thank you.
Comments
on Jun 20, 2006
Any suggestions are greatly appreciated.
on Jun 20, 2006
Grr. These forums are eating my responses. I even copied my first one this time, but in trying to ensure I didn't double post, lost it from clipboard.
Anyway. The only way I know to change the Picture (or any state depandant attribute) for a certain state is to have the object in that state, then set the attribute.
This leads to complications, as you must know what state an object is in before you can set the proper image, and since you must place an object iun a state to change that state's image, the initial image will show briefly! I usually avoid using States if things are going to be changing a lot, but that is just me. You can build in error checking and additional commands to avoid the trouble, but I usually find a non-state solution becomes easier in such situations.
so you have to use at least two lines, as far as Iknow: DesktopX.Object("sampleObject").State = "StateB"
DesktopX.Object("sampleObject").Picture = "StateB.png"
will change StateB image only (and leave the object in StateB)
on Jun 20, 2006
I got nothing. I can't script anything yet - haven't learned how yet. But I have created simple shortcut objects with 2 diffent states (mouse away & mouse over) using 2 diffent pictures - just using the state/appearance options built in. But that's not what you're looking for, huh?    So just think of this as a long winded *bump*    off topic - just now got to see the smiley drop down list    I like it T-Man!  
on Jun 20, 2006
Thanks for the replies, you two!   I went back and read, re-read and re-read the Developer's Guide and I got it! [[[DesktopX.Object("obj1").States("state1").Picture= "pic1.png"]]] [[[DesktopX.Object("obj1").States("state2").Picture= "pic2.png"]]] That's "States" with an 's' at the end. I was doing it without the 's' at first and that's why it didn't work. (It's always the little things that cause big problems.) Anyways, thanks again kind fourmers!
on Jun 20, 2006
Hey cool! Thanks for the update, that's good to know!
on Jun 20, 2006
I also found that you can't change the default picture remotely. You have to rename that state something else.
on Jun 20, 2006
The scripting is driving me nuts. Half the time I figure stuff out by accident and then don't know what I did to do it again. I'm working on my first Theme, and I can't figure out how to use a button on one object to open another while closing the first. (The second is just a smaller version of the first and I don't want both of them open at the same time) I am trying to set them so you can clock on 'A' to open 'B' and have 'A' close at the same time and vice-versa.
on Jun 20, 2006
I'm learning as I go as well! It can be frustrating at times. Hmm, try this: [[[1.Set Object B's visible to "NO" ]]] [[[2.Insert script below in object A]]] [[[3.Insert script below in object B but change desktopx.Object("B") to desktopx.Object("A")]]] ****************** If object.Visible= True Then desktopx.Object("B").visible= False ElseIf object.Visible= False Then desktopx.Object("B").visible= True End If Sub Object_OnLbuttonUp(x,y,dragged) If Not dragged Then desktopx.Object("B").visible= True object.visible = False End If End Sub **************** I'll keep trying to streamline the code to see if there's a more efficient script. Hope this helps. 
on Jun 20, 2006
EDIT: I've create a post in response to your Q at WinCustomize DX forums because this forum squeezes the sentences together, making copying and pasting the script useless.