Just thought I needed a little space of my own.
Published on August 6, 2008 By nimbletongue In DesktopX
Ok, I'll try to keep it simple and to the point, but I do tend to ramble on sometimes

I just started to mess around with widgets/objects. I'm made this wallpaper with hearts that look like gems surrounded by what looks like gold metal. Looks nice and what not but it needed more, so I decided to make widgets/objects to sit over the hearts (made from a screen shot of the desktop so it blends in perfectly) so when you mouse over them the gemmed heart would slide to the side like an elevator door to reveal pictures of loved ones behind it. Ok got that, works nice, I run my mouse over and the door opens and the picture shows, then returns to the static image as soon as its done unless my mouse stays on it. What I want it to do now is if you mouse over (or click it, if thats needed) it, is to have it run the anamaition of the "door" opening then stay on the picture of the person. Then the next time you mouse over (or click) it runs the anaimation in reverse closing the "door" and leaving it as the gemmed heart. Is there a script for doing this?

Comments
on Aug 06, 2008
Moving this so it gets attention from th eDX Gods here.
on Aug 06, 2008
There's a couple ways to do this. Need to clarify a few things first.

Are you just using two images, the heart and the picture? Or is your door an animated png?
on Aug 07, 2008
Thx for the move

There's a couple ways to do this. Need to clarify a few things first.Are you just using two images, the heart and the picture? Or is your door an animated png?


Well, kinda both. The mouse away is a picture of the door closed. Then the mouse over picture is a animated png consisting of the door closed all the way to the picture. I'm sure there are better ways to do what I want it to do, I plan on tweeking as I go along.
on Aug 07, 2008
Create the following four states:
1. open
2. closed
3. aniopen
4. aniclosed

Set "aniopen" state to your animated png and set to forward(assuming forward means open)
Set "aniclosed" state to your animated png and set to backward(assuming backward means close)
Set "open" state to the image when open.
Set "closed" state to the image when closed.
*Note: This could be done with two or three states but, trying to keep this simple.

Here's the script:

The speed of the timers on line 15 and 19 is the speed of your animation. For example this script use a 19 frame png with 25ms per frame for a total of 475ms.

Code: vbscript
  1. Dim blnOpen
  2. 'Called on selected object state changes
  3. Function Object_OnStateChange(state)
  4. If state= "Mouse up" Then
  5. Call Animation(state)
  6. ElseIf state="open" Then
  7. Object.KillTimer 1
  8. ElseIf state="closed" Then
  9. Object.KillTimer 2
  10. End If
  11. End Function
  12. Function Animation(state)
  13. If blnOpen Then
  14. Object.State="aniclosed"
  15. Object.SetTimer 2,480
  16. blnOpen=False
  17. ElseIf Not blnOpen Then
  18. Object.State="aniopen"
  19. Object.SetTimer 1,480
  20. blnOpen=True
  21. End If
  22. End Function
  23. 'Called when the script is executed
  24. Sub Object_OnScriptEnter
  25. Object.State="open"
  26. blnOpen=True
  27. End Sub
  28. Sub Object_OnTimer1
  29. Object.State="open"
  30. End Sub
  31. Sub Object_OnTimer2
  32. Object.State="closed"
  33. End Sub
on Aug 08, 2008
thank you, it's very close to what I wanted. But it is still not quite right as I pictured it. Maybe it something to do with my png's. So I'll upload a basic set of my png's to maybe help.

My open state png


My closed state png


My closed state png


Ok, with the above script, 1st time I click it does this.

This is what happens on 2nd click.

Hope this helps me explain better, and thanks again with all the help so far.

This is what I want it to do.
on Aug 08, 2008
Funny thing is, after I posted the above I decided to mess around with it. I deleted the open and closed state and boom, its just how I wanted it
on Aug 08, 2008
Glad, you worked it out. If the last and first frames are the final respective frames than you do only need the two "ani" states. Since they are only activated on mouse down than they will remain on the ending frame of the animation.