6 Replies Latest reply on May 22, 2008 8:54 PM by Newsgroup_User

    Handler being ignored...

    Level 7
      This is driving me nuts. I've got a behavior for some numbers which appear
      and fade, using imaging lingo to build them from source members. Nothing
      fancy, except I'm having problems testing it, because every time, the second
      time I try to run the handler, I get a "Handler not found in object" error,
      which I can't get to go away except by quitting Director and restarting it.
      Here's the code, in case it matters (which I don't think it does because
      it's obvious that the code never even executes, let alone gets a chance to
      error):

      property my
      on beginSprite me
      my = sprite(me.spriteNum)
      my.blend = 0
      end
      on show me,num,col
      str = string(num)
      oSet = integer((6-str.char.count) * 9.5)
      sRect = rect(0,0,19,25)
      my.member.image.fill(0,0,114,25,rgb(0,0,0))
      repeat with i = 1 to str.char.count
      dRect = rect((i-1)*19+oSet,0,(i*19)-1+oSet,25)
      my.member.image.copyPixels(member(col & "Num" &
      str.char ).image,dRect,sRect)
      end repeat
      my.blend = 99
      end
      on exitFrame me
      if my.blend > 0 then
      my.locV = my.locV - ((100 - my.blend) / 10.0)
      if my.blend < 3 then my.blend = 0
      else my.blend = my.blend - 3
      end if
      end

      I basically have a bunch of bitmaps for my numbers, of various colors to
      indicate different things. All named something like "aNum0", "aNum2",
      "bNum0", etc. I hand this script a number and a single character indicating
      which number set to use, and it should do the rest. For some reason, the
      first time after loading up the movie, I can run this script fine from the
      message window. But the second time, it claims there is no handler. I've
      put breakpoints into both the beginSprite and exitFrame handlers, and
      they're both running fine. But my "show" handler doesn't exist the second
      time (and subsequent) around. I have to save/quit/reload every time I want
      to change something. Any ideas what could be causing this?


        • 1. Re: Handler being ignored...
          fazstp Level 2
          How are you running the script? I tried it and it worked fine apart from an error if the member didn't exist. Plus you need to reset the loc with the blend for the next number.

          • 2. Re: Handler being ignored...
            Level 7
            > How are you running the script? I tried it and it worked fine apart from
            > an error if the member didn't exist. Plus you need to reset the loc with
            > the blend for the next number.

            Actually, the script now seems to function fine when called by other
            scripts - but when called from the Message Window, it fails every time.
            Well, not every time, but every time after the first time. I finally got
            the effect to work the way I wanted, but I had to shut down and restart
            Director about 12 times in order to do it. It's annoying testing it via
            scripts, because I have less control over where and when it happens, since
            the numbers are all calculated elsewhere. For example, this thing is
            designed to handle as many as 6 digits, but so far nothing in the game
            produces numbers that high (even 4 digits is rare), so at this point I just
            have to assume it will work, because it's hard to test things like that
            without messing up a lot of other code.

            (For the record, the loc is set elsewhere before the function is called, as
            the number needs to appear in different locations depending on what's going
            on - there can actually be as many as 20 of these visible at once, called as
            needed.)


            • 3. Re: Handler being ignored...
              fazstp Level 2
              I called it with a sendSprite in the message window. Were you doing something different?

              • 4. Re: Handler being ignored...
                Level 7
                >I called it with a sendSprite in the message window. Were you doing
                >something different?

                I did this:

                sprite("Such-and-such").show(12345,"a")

                Should be about the same, I'd think?


                • 5. Re: Handler being ignored...
                  fazstp Level 2
                  quote:


                  I did this:
                  sprite("Such-and-such").show(12345,"a")

                  Should be about the same, I'd think?



                  Yeah, that worked ok for me too.

                  • 6. Re: Handler being ignored...
                    Level 7
                    > Yeah, that worked ok for me too.

                    Yeah, I was pretty sure nothing was wrong with the script itself. It seems
                    like it's something ELSE that's causing the script to be ignored when called
                    from the Message Window. Unfortunately, I can't even begin to think what it
                    could be - there's so much stuff going on in this project, it'd be hard to
                    pin it down without some sort of clue where to look. I'm just wondering if
                    anyone else has ever run into a problem where a behavior just refused to be
                    called from the Message Window more than once per session? I've got the
                    script working the way I want it now, so I shouldn't need to edit it much
                    anymore. But the bug persists - I still can't call it from the Message
                    Window more than once. Weird.