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 :) .
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!
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
}