Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help please with swapping sprites 1

Status
Not open for further replies.

fjp476

Technical User
Dec 28, 2001
113
US
Hi, can anyone please help me with the mouseUp script for swapping sprites? I have a pause button named pause I would like to swap to a resume button named resume on mouseUp. So far I have cursor change and rollover change behaviors from the library for the Pause button as well as this behavior that controls the pause:
on mouseUp me
go to the frame
if sound(1).status = 3 then
sound(1).pause()
else
sound(1).play()
end if
if sound(2).status = 3 then
sound(2).pause()
else
sound(2).play()
end if
end

Thanks in advance for any help.

Cheers~Frank
 
The following code is a simple button behaviour, which toggles between the
Code:
sound(1)
to play/pause. Button rollovers, swaps, and cursor changes are all handled. Best to avoid using Library items if possible - usually they are too heavy handed and not very flexible.

Create 4 buttons: "resume", "resume rollover", "pause", and "pause rollover". Place them in the Cast - make sure the normal button and rollover button are placed next to each other. Place the "pause" button on the Stage and attach this behaviour.

Code:
--
on mouseEnter me
  sprite(me.spriteNum).memberNum = sprite(me.spriteNum).memberNum + 1
  cursor 280
end mouseEnter

on mouseLeave me
  if sprite(me.spriteNum).member.name contains "rollover" then
    sprite(me.spriteNum).memberNum = sprite(me.spriteNum).memberNum - 1
  end if
  cursor 0
end mouseLeave

on mouseUp me
  case sound(1).status of
    3: 
      sound(1).pause()
      sprite(me.spriteNum).member = member("resume")
    4: 
      sound(1).play()
      sprite(me.spriteNum).member = member("pause")
  end case
end mouseUp

on mouseWithin me
  if not (sprite(me.spriteNum).member.name contains "rollover") then
    sprite(me.spriteNum).memberNum = sprite(me.spriteNum).memberNum + 1
  end if
end mouseWithin
--

 
Thanks a million, I'll go give it a shot. Is that true for all library items or just button behaviors?

Cheers~Frank
 
Usually you can do the same thing using your own Lingo, which is much shorter and efficient because you only need to cater one particular situation - as opposed to the pre-written Library scripts, which need to cover every possible situations.

Still, Library is very useful as you can write your own Library item and use it again and again!
 
Hey, thanks again! Your script woked like a charm. I really appreciate the help. I'm trying to learn Lingo on my own but have decided to invest in some training as soon as I finish this current project. I save scripts in a folder on my HD all the time, do you mean that I can actually add them to my Library within Director? Once again, thank you.

Cheers~Frank
 
Director Library items are nothing more than normal Lingo scripts stored in external Casts. They are in "Libs" directory in the application folder. All you need to do is put your custom Cast in this directory.

If you use
Code:
getPropertyDescriptionList, isOKToAttach, getBehaviourDescription[code] and [code]getBehaviourTooltip
in your script, it will work just like a built-in Library item - just drag and drop it onto a Sprite/Score.
 
Wow, very cool, thanks again!

Cheers~Frank
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top