This content has been marked as final. Show 2 replies
it sounds like you missed out when movieScripts were mentioned :)
Create a script with Ctrl-Shift-U and place the 'global'
function/handler in there.
Creating a script with that key-combo makes the script a moviescript.
Any other script can be converted to a movieScript through the script
tab in the property inspector and the 'Type:' pulldown there.
That script can remain in the cast (it can't even be placed in the
score) for it to work. All behaviors that don't have that specific
function/handler-name in their own script will look in moviescripts if
it can be found there. (and now they will)
Dread Pirate Pete wrote:
> I am developing a simple game that among other things, needs to accept user
> names for an indefinite amount of players. I have everything working how I'd
> like except that, for example when the user inputs their name they can click
> "add player" button, or choose to press enter. For whatever reason, both of
> these actions (key down for text box, and mouseUp for button) call the same
> function. However, I seem to have to have this function on both the textBox and
> on the button. Long story short, how / where do you define a global function? I
> tried on the first frame of my movie where other global variables are
> initialized, but that just returns an error that the mouseUp or keydown don't
> know where the handler is. Appreciate the help in advance.
I knew it was that easy. All of my scripts were showing as behaviors, and I tried the "global" drop down to no avail. It was not obvious to me how to use the movie script, but thanks so much for the help. Works like a charm, now only 1 function to update :D