Professional Web Applications Themes

Need help with registerForEvent and #animationEnded - Macromedia Director 3D

I am trying to watch for the completion of an animation and use it to trigger an event. When my 3D object is done animating, I?d like the play head to advance in the timeline. Currently it is stopped with a Hold On Current Frame behavior. My code is attached. Any help is appreciated. member("BlueMan").registerForEvent(#animationEnded {#animationEnded, "DefaultMotion", 100}, play(), member("BlueMan").model("BlueMan"))--Error: Comma Expected...

  1. #1

    Default Need help with registerForEvent and #animationEnded

    I am trying to watch for the completion of an animation and use it to trigger
    an event. When my 3D object is done animating, I?d like the play head to
    advance in the timeline. Currently it is stopped with a Hold On Current Frame
    behavior.

    My code is attached. Any help is appreciated.

    member("BlueMan").registerForEvent(#animationEnded {#animationEnded,
    "DefaultMotion", 100}, play(), member("BlueMan").model("BlueMan"))--Error:
    Comma Expected

    adam@blueapplestudio Guest

  2. #2

    Default Re: Need help with registerForEvent and #animationEnded

    Try:
    myModel=member("BlueMan").model("BlueMan")
    myModel.registerForEvent(#animationEnded, #play, me)

    this will look for a handler named play() in the same script as this statement
    If you are intending to get the bluemans bonesplayer to play you will have to
    specify that in your play() handler

    on play me
    myModel=member("BlueMan").model("BlueMan")
    myModel.bonesPlayer.play()
    end

    not that director wont confuse play with bonePlayer.play() due to scope of the
    registerforevent call, but to keep yourself from getting confused you should
    probably name the handler something other than play() like playBlueMan() and
    then change the registerforevent to call #playBlueMan

    _eyesonly Guest

  3. #3

    Default Re: Need help with registerForEvent and #animationEnded

    Thanks for the guidance, _eyesonly. I am getting a "Handler not found in
    object" error now. I am new to this, so please bear with me. #playBlueMan is
    the handler, right? How do I apply this to my object?


    --This is in a Behavior Script on frame 1.
    on exitFrame me

    myModel=member("BlueMan").model("BlueMan")
    myModel.registerForEvent(#animationEnded, #playBlueMan, me)--Handler not
    found in object

    on playBlueMan me

    myModel=member("BlueMan").model("BlueMan")
    myModel.keyframePlayer.play()

    end

    end

    adam@blueapplestudio Guest

  4. #4

    Default Re: Need help with registerForEvent and #animationEnded

    dont put the script in a frame, rather try dragging it onto the sprite
    make sure in the property inspector that the script says its type is behavior or scriptType=#score

    _eyesonly Guest

  5. #5

    Default Re: Need help with registerForEvent and #animationEnded

    I made the changes you suggested (applied script to the sprite on stage) and am
    still getting the error. Below is what I am using. Am I missing something
    incredibly obvious here?

    --Below is a Lingo behavior script named ?registerForEventTest?
    --This script is on the 3D sprite on the stage


    on beginsprite me

    myModel=member("BlueMan").model("BlueMan")
    myModel.registerForEvent(#animationEnded, #playBlueMan, me)

    end beginsprite

    on playBlueMan me

    myModel=member("BlueMan").model("BlueMan")
    myModel.keyframePlayer.play()

    end


    --This returns the below error:
    --Script error: Handler not found in object
    --myModel.registerForEvent(#animationEnded, #playBlueMan, me)
    --#registerForEvent

    adam@blueapplestudio Guest

  6. #6

    Default Re: Need help with registerForEvent and #animationEnded

    Oh sorry, registerforevent() is tied to a 3d member not a model so you should substitute registerScript() instead

    _eyesonly Guest

  7. #7

    Default Re: Need help with registerForEvent and #animationEnded

    I substituted registerScript() for registerForEvent() but now nothing happens.
    The model plays its animation once and stops. I want to get the playhead to
    advance after the animation has finished playing.

    --This is in aBehavior script applied to the 3d sprite BlueMan
    on beginsprite me

    myModel=member("BlueMan").model("BlueMan")
    myModel.registerScript(#animationEnded, #playBlueMan, me)

    end beginsprite

    on playBlueMan me

    myModel=member("BlueMan").model("BlueMan")
    myModel.keyframePlayer.play()

    end

    adam@blueapplestudio Guest

  8. #8

    Default Re: Need help with registerForEvent and #animationEnded

    The file animationEndTest.dir found at http://blueapplestudio.com/Director/ is the file I am having trouble with.
    adam@blueapplestudio Guest

  9. #9

    Default Re: Need help with registerForEvent and #animationEnded

    queueing the motion solves the problem:



    on playBlueMan me

    myModel=member("BlueMan").model("BlueMan")
    myModel.keyframeplayer.queue("BlueManKey")
    myModel.keyframePlayer.play()


    end

    _eyesonly Guest

  10. #10

    Default Re: Need help with registerForEvent and #animationEnded

    I tried what you suggested but now the play head just blasts along, never
    pausing. I was supposed to put your code into the Behavior script applied to
    the 3D sprite, correct?

    What I would like is to have the play head pause on frame 6 until the 3D
    animation has finished playing its animation once. Were you able to get this
    to work in the .dir file I posted?


    adam@blueapplestudio Guest

  11. #11

    Default Re: Need help with registerForEvent and #animationEnded

    Yep, it works, you must be doing something wrong.
    See the file for yourself:
    http://www.filemonster.net/en/file/9224/animationEndTest-zip.html
    _eyesonly Guest

  12. #12

    Default Re: Need help with registerForEvent and #animationEnded

    Downloaded your file and had the same problem... clicked on play and the
    playhead just trucks along without pausing. Then I thought that perhaps the
    movie had to be published first. The published movie indeed behaves as you
    said it would. Does registerScript or animationEnded require that the movie is
    first published to work?

    Thanks again for your help and patience with this.

    -Adam

    adam@blueapplestudio Guest

  13. #13

    Default Re: Need help with registerForEvent and #animationEnded

    thats indeed strange behavior, It may be since you have the sprite starting on
    frame 1 which director uses for all sorts of things so the first exitframe or
    beginsprite handler gets missed. I always have a loop on the 2nd frame that
    checks to see if the 3d member.state = 4 before proceeding. On the other hand
    are you on a mac? Im not sure if dmx2004 is certified to run on the intel macs
    except in Shockwave. ( I believe the intel macs run Shockwave in Rosetta
    mode). This allegedly will be fixed if Adobe actually updates Director some day.

    _eyesonly Guest

  14. #14

    Default Re: Need help with registerForEvent and #animationEnded

    I'm on a PC, but you were correct in suggesting the sprite's presence on frame
    1 was the culprit. I slid the sprite's start point to frame 2 and it works
    fine.

    Thank you very much for all of your assistance and sticking with this until it
    was solved. Take care.



    adam@blueapplestudio Guest

Similar Threads

  1. 158400 polygones and registerForEvent (read/demo/source)
    By hondo3000 in forum Macromedia Director 3D
    Replies: 14
    Last Post: June 9th, 02:50 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