Global variables and more


(Michael) #1
  1. Global variables
  2. OnDoubleClick
  3. OnKeyUp/Down
  4. OnScroll
  5. Scroll to
  6. Paste as vectors

If you, of course, intend this to be also a UI prototyping tool…


(stephen) #2

Thanks for the suggestions!

In the scene inspector we do have OnKeyUp/Down actions. You can also create global variables using standard javascript by doing things like:

window.myAwesomeGlobalState = 5;

(Michael) #3

Thanks, Stephen!

I did find KeyUp and KeyDown.

Global variables (excuse my total JS ignorance): if I specify it in one javascript, will it propagate to others? How about using Persistent Symbols’ values for that? One can put them outside the canvas for example.


(stephen) #4

Any javascript that shares the same window object will have access to the variable (this generally means anything in the same page that isn’t in an iframe).

Persistent symbols are a nice way to share state between scenes, but not across documents.


(Michael) #5

Thanks! Both approaches worked, i.e. I’ve loaded globals on Scene Load, but then I have to specify them as “var myVar1 = window.myGlobal” in every inside script. Persistent symbols’ values worked too. It’s a good way, if you want to keep project globals “visible”.

Of course, they wouldn’t work across documents. For that you’ll need to implement such thing as “project” (as Flash did at the end, but it didn’t save it…).