Hierarchy
This keyword
This… is this. In ActionScript and in many other programming languages as well it means "object I am working on right now" or "object I am currently inside". It's like "myself". To refer to "this" symbol – simply use the keywore this before calling the method or reading the property.- Create any movie symbol and drag an instance on the stage. In our example it's a red ball. You don't need to give an instance name to it for this exercise.
- Extend the timeline of the movie symbol up to 12 frames (to make it's lifespan 1 second).
- Enter the following code to the first frame of the symbol's timeline
if(this._width<200){ this._width +=10; this._height +=10; } else { this._width = 20; this._height=20; } - Test your movie. Your symbol should increase the size every second and when reaching 200px start again.
What is good about this kind of code notation – it is universal. You may place it in any movie symbol timeline and it will work perfectly since another symbol also will be "this" from itself