How to variables


I was wondering about how variables would work in wick. And does it work the same in Actionscript 3.0? I used variables once in Adobe Animate but then I forgot.


Hey @AJ_Thefiremaster, This is a GREAT question. Variables in Wick act the same as variables in JavaScript! Fair warning, this is a pretty long explanation but I’d be more than happy to give you some more help if you need :slight_smile: .

You can declare a variable inside a wickObject in a few different ways

var myVariable = 'value'; // Way number 1 (only usable within your function)

myOtherVariable = 'otherValue'; // Way number 2 (Usable throughout your project BUT a little dangerous)

The differences between these two are pretty subtle, but this will allow you to store values. (here’s a technical explanation you shouldn’t have to worry about unless you’re curious)

But what if I want to store a value in a wickObject so I can access it from somewhere else safely?

this.variableName = 'value'; // Way number 3

This stores the value in the object itself as a “property” so it’s accessible from other objects that are loaded within the same frame. I can access this property by saying objectname.variableName. You can set object names from your inspector by changing it’s default name (like ‘New Clip’ or ‘New Path’) to something else!

42 PM


Thanks @Luxapodular. I’m also wondering if I can access variables though “if” statements. If it’s possible, can you explain?


@AJ_Thefiremaster Sorry about the late response. You can use variables in conditionals (like if and else statements) like this.

if (myVariable === myCondition) {
  //do Stuff