Professional Web Applications Themes

multiple mouse clicks - Macromedia Director Lingo

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:)...

  1. #1

    Default 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

  2. #2

    Default Re: multiple mouse clicks

    On 31/8/03 8:58 pm, in article biu5k0$3i0$1forums.macromedia.com, "mrsr84"
    <mrsr84> wrote:
    > 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.
    Do you mean that you want the sprite to change (it's member) when you click
    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

  3. #3

    Default 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

  4. #4

    Default 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

  5. #5

    Default 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

  6. #6

    Default 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

  7. #7

    Default 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

Similar Threads

  1. director and FLASH mouse clicks with touchscreens
    By lynne sheldon in forum Macromedia Director Basics
    Replies: 10
    Last Post: February 3rd, 11:14 AM
  2. FLASH mouse clicks on touch screen
    By lynne sheldon in forum Macromedia Director Basics
    Replies: 0
    Last Post: January 29th, 04:54 PM
  3. FLASH MX mouse clicks in Director
    By lynne sheldon in forum Macromedia Director Basics
    Replies: 4
    Last Post: January 22nd, 09:59 AM
  4. Sprites, Accessibility Speech behaviors, and Mouse Clicks.
    By ForeverTangent webforumsuser@macromedia.com in forum Macromedia Director Basics
    Replies: 1
    Last Post: December 19th, 10:22 PM
  5. Sprites with Accessibility Speech behaviors and Mouse Clicks
    By ForeverTangent webforumsuser@macromedia.com in forum Macromedia Director Lingo
    Replies: 0
    Last Post: October 10th, 06:54 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139