A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: 'this' action....

  1. #1
    could someone please clarify when and why someone would use the 'this' action...
    I have a couple of questions:
    -do you only use 'this' when inside of a clip event?
    -is its only purpose so that you don't have to write the whole path to the mc? (this._x; instead of _root.mc._x?
    -can you use 'this' on the root timeline?

    Ive tried looking in the AS manual, but what I've found is pretty foggy.


    I appreciate any respnses
    thanks in advance...

    -jc


  2. #2
    Senior Member
    Join Date
    Apr 2001
    Posts
    175
    "this" is under the target menu. It means that whatever you're targeting from, "this" will be that thing. If you're in the main movie, "this" is the main movie. If you're in an MC, "This" is that MC. You might also notice that if you're in the main movie and you have MC's, there are MC's under "this" in a hierarchy tree.

  3. #3
    Senior Member
    Join Date
    Mar 2001
    Posts
    146
    this refers to the movie clip or object the script is called from, for example...

    you can write a method to find the objects in an movieclip...

    //extending the movieclips prototype object
    //this means all your movieclips now have a method
    //called listObjects()
    Movieclip.prototype.listObjects = function(){
    trace("The objects found in " + this._name + " are:");
    for (var objects in this){
    trace(this[objects]);
    }
    }

    now to find out what exists in a movie clip you can use the syntax...

    yourMovieclip.listObjects();

    if you called the listObjects method from _root you could use the syntax...

    this.listObjects();

    to find out objects in _root...




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center