This content has been marked as final. Show 10 replies
If you look up “registerScript” in the online documents ( http://livedocs.adobe.com/director/mx2004/release_update_en/wwhelp/wwhimpl/js/html/wwhelp. htm?href=03_part_.htm) it states the following regarding the eventName parameter:
“The event can be any of the following predefined events, or any custom event that you define“
I have figured out a solution to my problem already. I am looping a check to see if the playList is empty. Once the animation is complete, the playList count is 0. However, I would still like to know how to make these “custom events.”
Has anyone got any experience with this, or am I misinterpreting what a custom event is?
If I understand it correctly...
a custom event is similar to what you are doing already. You would instead use registerScript to register the name #animationComplete event and an associated script to run with the event occurs. Then when your condition is met (playlist empty) the script associated with the animationComplete event is called. You still have to have a variable or property to check (like playlist) and you still have to check it periodically (like in a frame script). As far as I understand it, it is not like a primary event (i.e. keypress) with all this built in. You still have to define it all with Lingo.
Anyone out there understand this differently?
Thanks for your response. Could you post a code example of what you are suggesting? Does it go inside of a Movie or Behavior script?
Here is a link to the file I am working on ( http://www.blueapplestudio.com/Director/ and select the file registerSript_customEvent.dir.zip.) On one of the behavior scripts you can see that I am using registerForEvent with animationEnded as the event.
If you could crack this open and insert your custom event, I'd appreciate it. I just can't get my head around this one.
If you reset the world the animationFinished event only triggers once. Try removing the frame script on "loop1" and changing the behaviour to the following;
McFazstp, thanks for the response. Your code works well, and the event only fires once as you stated. However, I am still trying to figure out the writing of custom events. In your code, #animationEnded is still the event that is triggering the custom handler #playBlueMan.
How does one write a custom event that could replace #animationEnded in this example?
I'm hardly an expert on this. The first time I tried or even heard of this was when I read your post. As far as I can tell the custom event is assigned to the member, not the model, and it is called by using sendEvent. I'm not sure if it can be triggered by the animation itself.
member( "BlueMan" ).registerForEvent( #custom_event, #doCustomEvent, me )
member( "BlueMan" ).sendEvent( #custom_event )
Thanks, McFazstp. I guess I am still looking for how to craft the actual #custom_event in your example. I have gone through the Director livedocs and not come up with anything.
In the sendEvent entry in the livedocs they refer to an event called #jump. This appears to be a custom event, but I don't know how the event is written. Does anyone out there have some experience with this that they could share?
For example, let’s say that you have a 2D sprite onstage, and it is rotating through a script. Could you create a custom event that will detect when its rotation is greater than 270? Can one write a custom event that detects when a 3D cast member changes from a “playing” state to a “paused” state? I understand how to register the event, it’s actually writing the event that I am lost on.
> For example, let?s say that you have a 2D sprite onstage, and it is rotating
> through a script. Could you create a custom event that will detect when its
> rotation is greater than 270? Can one write a custom event that detects when a
> 3D cast member changes from a ?playing? state to a ?paused? state? I
> understand how to register the event, it?s actually writing the event that I am
> lost on.
I think you're expecting something more than exists.
You *the programmer* has to determine when to fire the event. It's not
something you can ask to have automatically calculated for you. You have
to write code to detect when the rotation goes beyond 270 degrees, or
when a 3D sprite's state changes. All of this will involve you polling
for information required from a regular event like #exitFrame or a
When you detect that it's time to fire the event you use
S. Wilson, you are probably right. It sounds like the place where you actually declare your custom event's name is within sendEvent. This is what I was looking for but probably didn't realize it until now. Thanks for everyone's help and patience.