Ask a Question related to Macromedia Director Lingo, Design and Development.
-
mrsr84 #1
multiple mouse clicks
I want to be able to code a sprite change based on 2 mouse clicks. The sprite changes on the first mouse click and on a 2nd mouse click it would change again.
I have already tried with if then logic but...it didn't work.
Thanks in advance.
Nancy
mrsr84:)
mrsr84 Guest
-
director and FLASH mouse clicks with touchscreens
hi, If anyone else knows about the bug in director and a possible solution please let me know! Basically, if you have a flash movie, with... -
FLASH mouse clicks on touch screen
noboddy got any ideas still ? why u need to double click on a touchscreen on a flash sprite? -
FLASH MX mouse clicks in Director
Hi, I've imported my MX swf as a sprite. The problem is, with the MX swf, a button with a simple on ( release) action doesn't work anymore on my... -
Sprites, Accessibility Speech behaviors, and Mouse Clicks.
Does anyone know why a spirite with an attached accessibility behavior will "speak" when clicked on by a mouse. I thought the accessibily speech... -
Sprites with Accessibility Speech behaviors and Mouse Clicks
Does anyone know why a spirite with an attached accessibility behavior will "speak" when clicked on by a mouse. I thought the accessibily speech... -
Leo Prendergast #2
Re: multiple mouse clicks
On 31/8/03 8:58 pm, in article biu5k0$3i0$1@forums.macromedia.com, "mrsr84"
<mrsr84@yahoo.com> wrote:
Do you mean that you want the sprite to change (it's member) when you click> I want to be able to code a sprite change based on 2 mouse clicks. The sprite
> changes on the first mouse click and on a 2nd mouse click it would change
> again.
it and then change back to the first image or move on to a next? Either way
is relatively simple. To do the first you can simply test to see what the
currently associated member is:
-- behavior script attached to sprite
on mouseUp me
if sprite(me.spriteNum).member = "originalMember" then
sprite(me.spriteNum).member = "alternativeMember"
else
sprite(me.spriteNum).member = "originalMember"
end if
end
If you plan on using three different images and then preventing any further
changes you could do something like this:
on mouseUp me
if sprite(me.spriteNum).member = "origninalMember" then
sprite(me.spriteNum).member = "secondMember"
else
sprite(me.spriteNum).member = "thirdMember"
end if
end
(note that I'm just typing these code samples directly and not testing them
- I am liable to typos and brain malfunctions).
On the other hand, if you want to cycle through a longer series of cast
members then this way of working is quickly going to become unwieldly and
also quite difficult to edit. In that case there are, again, a variety of
solutions that I won't go into unless you need them.
Hope this helps,
--
Leo Prendergast | mngatleoprendergastdotcom
Interactive Designer / Developer
Team Macromedia Volunteer
[url]http://www.macromedia.com/go/team[/url]
Leo Prendergast Guest
-
Roofy webforumsuser@macromedia.com #3
Re: multiple mouse clicks
you could put a counter on the mouse clicks. For example...
1. add a property varible in the global section like this...
property pCounter
2. inside your beginSprite handler, set the pCounter to 0 like this...
on beginSprite
pCounter = 0
-- plus your other initializers if you have any others
end beginSprite
3. make the mouse event handler to decide whether the counter is 1 or 2 like this...
on mouseUp me
pCounter = pCounter + 1
if pCounter = 1 then
do your first sprite change
else
do your second sprite change
pCounter = 0 -- reset the counter to 0 after the sprite has done its second job
end if
end mouseUp
Roofy webforumsuser@macromedia.com Guest
-
rick@mcorp webforumsuser@macromedia.com #4
Re: multiple mouse clicks
-- put this code behind the sprite. The code assumes that your members are
named "shape1", "shape2", "shape3" etc. (the first member must be named "shape1", the second "shape2" etc.)
-- This code will allow you to have as many different members as you wish, set pmax to the max number of clicks (2 in your case)
hope this helps,
good luck !
property pcount -- keep track of number of mouse clicks
property pmax -- max number of clicks allowed before returning to first member
on beginsprite me
pmax = 2
pcount = 1
setmember me
end
on setmember me
sprite(me.spritenum).member = member("shape"&pcount)
end
on mouseUp me
pcount = pcount + 1
if pcount > pmax then pcount = 1
setmember me
end
rick@mcorp webforumsuser@macromedia.com Guest
-
Roofy webforumsuser@macromedia.com #5
Re: multiple mouse clicks
-- put this code behind the sprite. The code assumes that your members are
named "shape1", "shape2", "shape3" etc. (the first member must be named "shape1", the second "shape2" etc.)
-- This code will allow you to have as many different members as you wish, set pmax to the max number of clicks (2 in your case)
hope this helps,
good luck !
property pcount -- keep track of number of mouse clicks
property pmax -- max number of clicks allowed before returning to first member
on beginsprite me
pmax = 2
pcount = 1
setmember me
end
on setmember me
sprite(me.spritenum).member = member("shape"&pcount)
end
on mouseUp me
pcount = pcount + 1
if pcount > pmax then pcount = 1
setmember me
end
Rick & Leo,
The only problem is we don't know what Nancy means by changing the sprite. Yes this is one method but it only changes the sprite's member. Changing sprites could mean....
1. change the sprites member
2. change the sprites location
3. change the sprites blend
4. change the sprites ink
5. change the sprites size
.... and I could go on and on and on etc.
Thats why I didn't put to much explaing in my script example...
Roofy webforumsuser@macromedia.com Guest
-
mrsr84 #6
Re: multiple mouse clicks
I tried using the coding you wrote for 3 images but...it went directly from the 1st to the 3rd. Would it be easier to use markers? Your advice is appreciated.
mrsr84:)
mrsr84 Guest
-
Roofy webforumsuser@macromedia.com #7
Re: multiple mouse clicks
I tried using the coding you wrote for 3 images but...it went directly from the 1st to the 3rd. Would it be easier to use markers? Your advice is appreciated.
Well since you haven't explained what you mean by changing the sprite, and as to me giving you an example of what are some possiblitities to what changing sprites could mean, I am going to assume that you mean changing the sprite's member. Though, for what ever your doing, changing sprites doesn't mean you need to have different markers. You can use a counter, however you need the counter to go up to 3 because you have your original member plus the 2 other members. You can do this one of the 2 ways.
1. is you can have the sprite go back to the original member after the 2nd click by doing it this way...
on beginSprite me
pMax = 3
pCount = 1
setMember me
end
on mouseUp me
pCount = pCount + 1
if pCount > pMax then pCount = 1 --this will bring the member back to shape 1
setMember me
end
on setMember me
sprite(me.spriteNum).member = member("shape"&pCount)
end
or
2. You can have the sprite go back to the second shape member after the 2nd click by doing it this way...
on beginSprite me
pMax = 3
pCount = 1
setMember me
end
on mouseUp me
pCount = pCount + 1
if pCount > pMax then pCount = 2 -- this will bring the member back to shape 2
setMember me
end
on setMember me
sprite(me.spriteNum).member = member("shape"&pCount)
end
Roofy webforumsuser@macromedia.com Guest



Reply With Quote

