Simple AS2 Problem

I have: (1)

this["btn_a"].onRelease = function (){
    this._parent[up_mc]._visible = true;
    this._parent[add_mc].num = random(10)+190;
    trace(this._parent);
}   

and I change it to (2)

function click1(){
    this._parent[up_mc]._visible = true;
    this._parent[add_mc].num = random(10)+190;
    trace(this._parent);
}
this["btn_a"].onRelease = function (){
    click1();
}  

When I press the button in (1), it shows "_velvel9", but when I press the button in (2), it shows "undefined". I don't know anything about AS2, so please help me and explain in detail. Thank you very much.

+3
source share
1 answer

sightseeing ....

in the first, you call the function belonging to the button. in the second, you declare a function at a level (your case: level9), and then call it where it sits.

I think.

this["btn_a"].onRelease = function (){
    trace(this._parent+" "+this); // traces: _level0 _level0.btn_a
}

function click1(){
    trace(this._parent+" "+this); // traces: undefined _level0
}
this["btn_b"].onRelease = function (){
    click1();
}
+3
source

Source: https://habr.com/ru/post/1710458/


All Articles