_parentの用法

有名なのかもシレンが。。

例えば、あるムービークリップ(my_mc)で
this.fnc1 = function() {
  trace("fnc1 is called.");
};
my_btn.onRelease = function() {
  _parent.fnc1();
  trace("this:"+this);
  trace("parent:"+_parent);
};
としてボタンをクリックすると、
this:_level0.my_mc.my_btn
parent:_level0

という訳で、修正版。
this.fnc1 = function() {
  trace("fnc1");
};
my_btn.onRelease = function() {
  this._parent.fnc1();
  trace("this:"+this);
  trace("parent:"+this._parent);
};
これで
fnc1 is called.
this:_level0.my_mc.my_btn
parent:_level0.my_mc
こうなる。愛でたし。

as

— posted by たか at 02:19 pm   pingTrackBack [0]

この記事に対するコメントはありません

T: Y: ALL: Online:
ThemeSwitch
Created in 0.8117 sec.
prev
2025.5
next
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
 
blogBar
Firefox3 Meter