Professional Web Applications Themes

help me please i'm desperate - Macromedia Director Lingo

This is a script tha i can drag a sprite and release is somewhere and check if it is correct how can i force it to be unmoveable the next time i'll try to move it , if it is correct or second wrong Help me please i am desperate ************************************************** ******************************* property pPressed, pClickDiff, pLockToSprite, pOrigLoc, pLockDist, pSnapBack,try, global points on getPropertyDescriptionList me list = [:] addProp list, #pLockToSprite, [#comment: "Lock To Sprite",\ #format: #integer, #default: 0] addProp list, #pLockDist, [#comment: "Maximum Lock Distance",\ #format: #integer, #default: 25] addProp list, #pSnapBack, [#comment: "Snap Back If Not Locked",\ #format: #boolean, ...

  1. #1

    Default help me please i'm desperate

    This is a script tha i can drag a sprite and release is somewhere and check if it is correct
    how can i force it to be unmoveable the next time i'll try to move it , if it is correct or second wrong
    Help me please i am desperate

    ************************************************** *******************************
    property pPressed, pClickDiff, pLockToSprite, pOrigLoc, pLockDist, pSnapBack,try,
    global points

    on getPropertyDescriptionList me
    list = [:]
    addProp list, #pLockToSprite, [#comment: "Lock To Sprite",\
    #format: #integer, #default: 0]
    addProp list, #pLockDist, [#comment: "Maximum Lock Distance",\
    #format: #integer, #default: 25]
    addProp list, #pSnapBack, [#comment: "Snap Back If Not Locked",\
    #format: #boolean, #default: TRUE]
    return list
    end



    on beginSprite me
    pPressed = FALSE
    pOrigLoc = sprite(me.spriteNum).loc
    try=0


    end

    on mouseDown me
    pPressed = TRUE
    pClickDiff = sprite(me.spriteNum).loc - the clickLoc
    end


    on mouseUp me
    release(me)
    end

    on mouseUpOutside me
    release(me)
    end

    on exitFrame me
    if pPressed then
    sprite(me.spriteNum).loc = the mouseLoc + pClickDiff
    end if
    end


    on release me
    pPressed = FALSE
    try=try+1
    if distance(me,sprite(me.spriteNum).loc,sprite(pLockT oSprite).loc)\
    < pLockDist then
    sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    member("lef").text="Well Done"
    sound(1).play(member("correct sound 1"))
    points=points+10
    member("pointss").text=string(points)
    else if pSnapBack then
    if try=1 then
    member("lef").text="Sorry! Wrong answer. Study the words and try again."
    sprite(me.spriteNum).loc =pOrigLoc
    sound(1).play(member("wrong sound 1"))
    else
    sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    member("lef").text="Sorry! Wrong answer again. I'll show you the correct answer."
    sound(1).play(member("wrong sound 2"))
    end if
    end if

    end



    ieraks webforumsuser@macromedia.com Guest

  2. #2

    Default Re: help me please i'm desperate

    All you need to do is add a property to your script - a flag.

    property doneMoving

    then within beginSprite:

    doneMoving = False

    now, in mouseDown before you set pPressed do a check:

    if not(doneMoving) then
    pPressed = True

    Finally, in the spot where you determine if it is in the right spot, and
    increment the points, set doneMoving to true

    --


    Dave
    [url]http://www.blurredistinction.com/director[/url]


    Dave Mennenoh Guest

  3. #3

    Default Re: help me please i'm desperate

    property pPressed, pClickDiff, pLockToSprite, pOrigLoc, pLockDist, pSnapBack,try,
    property pEnabled
    global points

    on getPropertyDescriptionList me
    list = [:]
    addProp list, #pLockToSprite, [#comment: "Lock To Sprite",\
    #format: #integer, #default: 0]
    addProp list, #pLockDist, [#comment: "Maximum Lock Distance",\
    #format: #integer, #default: 25]
    addProp list, #pSnapBack, [#comment: "Snap Back If Not Locked",\
    #format: #boolean, #default: TRUE]
    return list
    end

    on beginSprite me
    pPressed = FALSE
    pEnabled = TRUE
    pOrigLoc = sprite(me.spriteNum).loc
    try=0
    end

    on mouseDown me
    if pEnabled = TRUE then
    pPressed = TRUE
    end if
    pClickDiff = sprite(me.spriteNum).loc - the clickLoc
    end


    on mouseUp me
    release(me)
    end


    on mouseUpOutside me
    release(me)
    end


    on exitFrame me
    if pPressed then
    sprite(me.spriteNum).loc = the mouseLoc + pClickDiff
    end if
    end


    on release me
    pPressed = FALSE
    pEnabled = FALSE
    try=try+1
    if distance(me,sprite(me.spriteNum).loc,sprite(pLockT oSprite).loc)\
    < pLockDist then
    sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    member("lef").text="Well Done"
    sound(1).play(member("correct sound 1"))
    points=points+10
    member("pointss").text=string(points)
    else if pSnapBack then
    if try=1 then
    member("lef").text="Sorry! Wrong answer. Study the words and try again."
    pEnabled = TRUE
    sprite(me.spriteNum).loc =pOrigLoc
    sound(1).play(member("wrong sound 1"))
    else
    sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    member("lef").text="Sorry! Wrong answer again. I'll show you the correct answer."
    sound(1).play(member("wrong sound 2"))
    end if
    end if
    end



    johnAq webforumsuser@macromedia.com Guest

  4. #4

    Default Re: help me please i'm desperate

    Sorry - I hit Send too early

    I've hilited my (untested) additions to the code in bold.

    If it doesn't work, it should be fairly simple to see what is going on, basically I've introduced the property pEnabled which is just a boolean flag which must be TRUE for dragging to commence

    hth

    johnAq


    johnAq webforumsuser@macromedia.com Guest

  5. #5

    Default Re: help me please i'm desperate

    Add a pUsed property, initialize it as FALSE in your beginsprite handler
    then add a conditional statement to your mouseDown handler that checks for
    pUsed to be FALSE. Inside that conditional statement add pUsed = TRUE.
    This way the mouseDown handler won't execute any of it's code inside the
    conditional statement after one click.

    You could also create a switch handler that would reset the property if you
    want to control if you're going to give the user a second chance at some
    point.


    --
    Craig Wollman
    Word of Mouth Productions
    phone 212 724 8302
    fax 212 724 8151
    [url]www.wordofmouthpros.com[/url]


    "ieraks" <webforumsusermacromedia.com> wrote in message
    news:br74il$lnc$1forums.macromedia.com...
    > This is a script tha i can drag a sprite and release is somewhere and
    check if it is correct
    > how can i force it to be unmoveable the next time i'll try to move it ,
    if it is correct or second wrong
    > Help me please i am desperate
    >
    >
    ************************************************** **************************
    *****
    > property pPressed, pClickDiff, pLockToSprite, pOrigLoc, pLockDist,
    pSnapBack,try,
    > global points
    >
    > on getPropertyDescriptionList me
    > list = [:]
    > addProp list, #pLockToSprite, [#comment: "Lock To Sprite",\
    > #format: #integer, #default: 0]
    > addProp list, #pLockDist, [#comment: "Maximum Lock Distance",\
    > #format: #integer, #default: 25]
    > addProp list, #pSnapBack, [#comment: "Snap Back If Not Locked",\
    > #format: #boolean, #default: TRUE]
    > return list
    > end
    >
    >
    >
    > on beginSprite me
    > pPressed = FALSE
    > pOrigLoc = sprite(me.spriteNum).loc
    > try=0
    >
    >
    > end
    >
    > on mouseDown me
    > pPressed = TRUE
    > pClickDiff = sprite(me.spriteNum).loc - the clickLoc
    > end
    >
    >
    > on mouseUp me
    > release(me)
    > end
    >
    > on mouseUpOutside me
    > release(me)
    > end
    >
    > on exitFrame me
    > if pPressed then
    > sprite(me.spriteNum).loc = the mouseLoc + pClickDiff
    > end if
    > end
    >
    >
    > on release me
    > pPressed = FALSE
    > try=try+1
    > if distance(me,sprite(me.spriteNum).loc,sprite(pLockT oSprite).loc)\
    > < pLockDist then
    > sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    > member("lef").text="Well Done"
    > sound(1).play(member("correct sound 1"))
    > points=points+10
    > member("pointss").text=string(points)
    > else if pSnapBack then
    > if try=1 then
    > member("lef").text="Sorry! Wrong answer. Study the words and try
    again."
    > sprite(me.spriteNum).loc =pOrigLoc
    > sound(1).play(member("wrong sound 1"))
    > else
    > sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    > member("lef").text="Sorry! Wrong answer again. I'll show you the
    correct answer."
    > sound(1).play(member("wrong sound 2"))
    > end if
    > end if
    >
    > end
    >
    >
    >

    Word of Mouth Productions Guest

  6. #6

    Default Re: help me please i'm desperate

    Oops, I didn't see Dave's response. Sorry for the redundancy.



    --
    Craig Wollman
    Word of Mouth Productions
    phone 212 724 8302
    fax 212 724 8151
    [url]www.wordofmouthpros.com[/url]


    "ieraks" <webforumsusermacromedia.com> wrote in message
    news:br74il$lnc$1forums.macromedia.com...
    > This is a script tha i can drag a sprite and release is somewhere and
    check if it is correct
    > how can i force it to be unmoveable the next time i'll try to move it ,
    if it is correct or second wrong
    > Help me please i am desperate
    >
    >
    ************************************************** **************************
    *****
    > property pPressed, pClickDiff, pLockToSprite, pOrigLoc, pLockDist,
    pSnapBack,try,
    > global points
    >
    > on getPropertyDescriptionList me
    > list = [:]
    > addProp list, #pLockToSprite, [#comment: "Lock To Sprite",\
    > #format: #integer, #default: 0]
    > addProp list, #pLockDist, [#comment: "Maximum Lock Distance",\
    > #format: #integer, #default: 25]
    > addProp list, #pSnapBack, [#comment: "Snap Back If Not Locked",\
    > #format: #boolean, #default: TRUE]
    > return list
    > end
    >
    >
    >
    > on beginSprite me
    > pPressed = FALSE
    > pOrigLoc = sprite(me.spriteNum).loc
    > try=0
    >
    >
    > end
    >
    > on mouseDown me
    > pPressed = TRUE
    > pClickDiff = sprite(me.spriteNum).loc - the clickLoc
    > end
    >
    >
    > on mouseUp me
    > release(me)
    > end
    >
    > on mouseUpOutside me
    > release(me)
    > end
    >
    > on exitFrame me
    > if pPressed then
    > sprite(me.spriteNum).loc = the mouseLoc + pClickDiff
    > end if
    > end
    >
    >
    > on release me
    > pPressed = FALSE
    > try=try+1
    > if distance(me,sprite(me.spriteNum).loc,sprite(pLockT oSprite).loc)\
    > < pLockDist then
    > sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    > member("lef").text="Well Done"
    > sound(1).play(member("correct sound 1"))
    > points=points+10
    > member("pointss").text=string(points)
    > else if pSnapBack then
    > if try=1 then
    > member("lef").text="Sorry! Wrong answer. Study the words and try
    again."
    > sprite(me.spriteNum).loc =pOrigLoc
    > sound(1).play(member("wrong sound 1"))
    > else
    > sprite(me.spriteNum).loc = sprite(pLockToSprite).loc
    > member("lef").text="Sorry! Wrong answer again. I'll show you the
    correct answer."
    > sound(1).play(member("wrong sound 2"))
    > end if
    > end if
    >
    > end
    >
    >
    >

    Word of Mouth Productions Guest

  7. #7

    Default Re: help me please i'm desperate

    thanks for your help
    thanks a lot but
    the points of this script are still working .
    if i"ll try to drag it , the sprite is unmoveable and this is ok, but
    the points are still going up



    ieraks webforumsuser@macromedia.com Guest

  8. #8

    Default Re: help me please i'm desperate

    Well, add the check into your mouseUp then as well so you don't call
    release...

    --


    Dave
    [url]http://www.blurredistinction.com/director[/url]


    Dave Mennenoh Guest

  9. #9

    Default Re: help me please i'm desperate

    i cant understand you because i am stupid
    can you help me more?



    ieraks webforumsuser@macromedia.com Guest

Similar Threads

  1. Desperate !
    By Kolohei in forum Macromedia Contribute General Discussion
    Replies: 0
    Last Post: March 6th, 05:08 PM
  2. desperate man! Please take a look!
    By quiero mas in forum Coldfusion Database Access
    Replies: 5
    Last Post: July 11th, 05:06 AM
  3. Also Desperate
    By Jazzy in forum Web Design
    Replies: 4
    Last Post: May 2nd, 02:18 PM
  4. I'm DESPERATE...
    By wgold webforumsuser@macromedia.com in forum Macromedia Dreamweaver
    Replies: 3
    Last Post: July 24th, 08:54 PM
  5. Please help, am desperate
    By Adam in forum Macromedia Director Basics
    Replies: 3
    Last Post: July 16th, 02:48 AM

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