Action Script and "this"
- Started
- Last post
- 5 Responses
- CyBrainX0
Guys, thanks a ton. I will read up on _global. I've never used it before.
This is what I was working on. It's a preloader that will work in Flash 5 or later. Let me know what you think.
- atomica0
theres a chapter in Flash to the Core by Josh Davis I thought summed it up real well for me, in fact a lot of that book puts flash into common sense, thank the lord.
- zack270
"this" literally means *this*... the object that you're currently scripting. So if you're inside a movieclip "_root.myclip" and you say "this.gotoAndPlay(1);
you will go to frame 1 of "_root.myclip".
Just dont forget to assign instance names, that kills me every time.
- MACAS00
OK, if the target is more than 1 month old is a _Parent, the ones around it that came after him are _child, if you see the _parent with another old target then it's _this, you know "this is my girlfriend, this is my bike etc, etc, etc.
- MACAS00
Ok, out with the jokes:
So, what about _root?
You use _root when it's on reference to the main timeline._root.variable.target whatever
_parent is when you want to refer to another timeline, that means another clip.
_parent.variable
Is like the ball object is on the timeline, and you want to target the ball then you use _root, cause it's on the timeline, right, but then you have a variable or another object "on" the ball timeline, then you can use _parent.theVariable
If you want to make it easier then you can name your objects or variables _global, and then target it using the reference to any timeline.
Same can happen with levels
_level0.ball
_level3.ballEtc, etc.