More Help needed with the randomly falling sprites

Ask a Question related to Macromedia Director Lingo, Design and Development.

  1. #1

    Default More Help needed with the randomly falling sprites

    Eariler I asked for help with randomly falling sprites and I was given the code below. However now I'm getting the following error message when I try to use it,

    Variable used before assigned a value
    Case pMode of?

    Please Can You tell me What to do to correct this.
    Thank you


    property pS, spriteNum, pInterval, pStartPause, pMode, pSpeed

    on beginSprite me
    pS = sprite (spriteNum)
    pInterval = random (3) -- seconds
    pStartPause = the ticks
    pMode = #wait
    pSpeed = random (20) + 5
    pS.locV = - pS.height
    pS.locH = random (the stageRight - the stageLeft)
    end

    on exitFrame me
    case pMode of
    #wait:
    if the ticks > pStartPause + pInterval * 60 then
    pMode = #falling
    end if
    #falling:
    if pS.top < the stageBottom then
    pS.locV = pS.locV + pSpeed
    else
    pMode = #reset
    end if
    #reset:
    pS.locV = - pS.height
    pS.locH = random (the stageRight - the stageLeft)
    pMode = #wait
    pStartPause = the ticks
    end case
    end



    Opyuse webforumsuser@macromedia.com Guest

  2. Similar Questions and Discussions

    1. Legitimate mails falling into Junk folder of Hotmail
      ASP generated e-mails are getting into junk folder of hotmail. I have checked everything on my end like SPF, Reverse DNS lookup, etc. I am not...
    2. Randomly select from xml
      Please excuse my limited knowledge regarding dynamic html, I usually work with standalone flash apps. My situation is as follows; I have set up a...
    3. Randomly Ordered Recordset
      Hello everyone, I'm using MX04, Access, VB Script. I need to select 10 unique records and randomly order them. I've done quite a bit of...
    4. Threads falling apart
      Hi folks, recently my NR often fails to put news threads together. Is it just my NR or is there still something wrong with the News <-> Mail...
    5. Help creating randomly falling sprites with lingo
      Attach the following behavior to each sprite that's to fall. Adjust the pSpeed parameter to make the objects fall faster or slower. Adjust the...
  3. #2

    Default Re: More Help needed with the randomly falling sprites

    Are you sure you've copied the code correctly, including the first line
    below? It works fine on my machine. Do you have it in a behaviour attached
    to the sprite that is moving? You've got to try a few things.

    "Opyuse" <webforumsuser@macromedia.com> wrote in message
    news:bh6at1$4mo$1@forums.macromedia.com...
    > Eariler I asked for help with randomly falling sprites and I was given the
    code below. However now I'm getting the following error message when I try
    to use it,
    >
    > Variable used before assigned a value
    > Case pMode of?
    >
    > Please Can You tell me What to do to correct this.
    > Thank you
    >
    >
    > property pS, spriteNum, pInterval, pStartPause, pMode, pSpeed
    >
    > on beginSprite me
    > pS = sprite (spriteNum)
    > pInterval = random (3) -- seconds
    > pStartPause = the ticks
    > pMode = #wait
    > pSpeed = random (20) + 5
    > pS.locV = - pS.height
    > pS.locH = random (the stageRight - the stageLeft)
    > end
    >
    > on exitFrame me
    > case pMode of
    > #wait:
    > if the ticks > pStartPause + pInterval * 60 then
    > pMode = #falling
    > end if
    > #falling:
    > if pS.top < the stageBottom then
    > pS.locV = pS.locV + pSpeed
    > else
    > pMode = #reset
    > end if
    > #reset:
    > pS.locV = - pS.height
    > pS.locH = random (the stageRight - the stageLeft)
    > pMode = #wait
    > pStartPause = the ticks
    > end case
    > end
    >
    >
    >

    David Downie Guest

  4. #3

    Default Re: More Help needed with the randomly falling sprites

    Your post should be part of the original thread.

    --
    Craig Wollman
    Word of Mouth Productions
    phone 212 724 8302
    fax 212 724 8151
    [url]www.wordofmouthpros.com[/url]
    "Opyuse" <webforumsuser@macromedia.com> wrote in message
    news:bh6at1$4mo$1@forums.macromedia.com...
    > Eariler I asked for help with randomly falling sprites and I was given the
    code below. However now I'm getting the following error message when I try
    to use it,
    >
    > Variable used before assigned a value
    > Case pMode of?
    >
    > Please Can You tell me What to do to correct this.
    > Thank you
    >
    >
    > property pS, spriteNum, pInterval, pStartPause, pMode, pSpeed
    >
    > on beginSprite me
    > pS = sprite (spriteNum)
    > pInterval = random (3) -- seconds
    > pStartPause = the ticks
    > pMode = #wait
    > pSpeed = random (20) + 5
    > pS.locV = - pS.height
    > pS.locH = random (the stageRight - the stageLeft)
    > end
    >
    > on exitFrame me
    > case pMode of
    > #wait:
    > if the ticks > pStartPause + pInterval * 60 then
    > pMode = #falling
    > end if
    > #falling:
    > if pS.top < the stageBottom then
    > pS.locV = pS.locV + pSpeed
    > else
    > pMode = #reset
    > end if
    > #reset:
    > pS.locV = - pS.height
    > pS.locH = random (the stageRight - the stageLeft)
    > pMode = #wait
    > pStartPause = the ticks
    > end case
    > end
    >
    >
    >

    Word of Mouth Productions Guest

  5. #4

    Default Re: More Help needed with the randomly falling sprites

    you are actually going to have more than just the pMode error. After you fix that you the errors are going to acure.
    #reset, and #wait should also cause some kind of error since these are not defined as well


    reasons why...
    pMode is still not set to a varible because your tring to change a predefined command the word wait with to a custom varible #wait so it would mean that #wait would not be defined. I would also suggest leaving alone any words that the text changes it color to anything else other then black. Meaning if the string of text that your going to use as a varible or custom handler is not black, then don't use it. Here are a couple of hints.

    a. if you need a varible to rember itself throughout the behaviour script or movie script then the varible needs to be placed at the top of the script before any handlers are created and any varibles that need to be assigned to. These kind of varibles are called global varibles, and varibles that only need to be known inside a handler are called local varibles.

    b. For global varibles that need to be remebered in a behaviour script then you can use property, and if it is a movie script then you use global. for example, for a behaviour script you would type in "property myVarible" without the quotes, and for a movie script you would type in "global myVarible" without the quotes.

    c. When you define global varibles, I allways put a "p" or a "g" in front of the word to remind myself that this is a global varible, and it also gets rid of not worrying if I am using a predefined word that Director already uses. So you can use #pWait which reminds you that it is a global varible and still makes it understandable to what that varible stands for.

    so in the case that you want to do a "case of situation", the varible cases need to be defined as global varibles as well before you can assign pMode. Meaning even though you set pMode in the global area you still cant say pMode = cat or what ever you want it to equal to without assigning that varible first. My sugestion would be to do it this way....

    property pWait, pReset, pFalling
    property pMode

    on beginSprite
    pWait = 1
    pReset = 2
    pFalling = 3
    pMode = pWait
    end beginSprite

    then you can use these varibles in the case of situation you have.

    I hope this makes things more clearer for you.
    regaurds,
    Bob


    Roofy webforumsuser@macromedia.com Guest

Posting Permissions

  • You may not post new threads
  • You may 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