Call methods and properties created onto a MovieClip
hi people!
i've noticed animate cc allows add as3 onto movieclips on stage, in as2 era.
so how correctly declare functions , variables onto movieclip , call them main timeline?
thanks!
if carefully, script adding movieclip going main timeline, @ same level movieclip. it's illusion it's going onto movieclip itself. try script, having selected movieclip instance name of "box":
import flash.events.mouseevent;
var something:* = this
this.addeventlistener(mouseevent.click,clicked);
function clicked(e:mouseevent){
trace(something.name);
}
it trace 'root1', not 'box'.
if put scripts timeline of movieclip itself, call them with:
box.somefunction();
if instance name box. in main timeline:
import flash.events.mouseevent;
var something:* = this
this.addeventlistener(mouseevent.click,clicked);
function clicked(e:mouseevent){
box.somefunction();
trace(something.name);
}
and in movieclip named box:
function somefunction(){
trace("hi");
}
would trace 'hi' , 'root1' when click on box.
More discussions in Adobe Animate CC - General
adobe
Comments
Post a Comment