Skip to main content
Participating Frequently
April 19, 2020
Question

Variables calling

  • April 19, 2020
  • 1 reply
  • 235 views

Hi all,

How to call a variable on the main stage from a code inside a movieclip and vice versa?

Thanks in advance..

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 21, 2020

    Hi.

     

    HTML5 - Canvas - use the automatically generated global variable exportRoot.

    Examples:

    console.log(exportRoot);
    console.log(exportRoot.yourProperty);
    exportRoot.yourMethod();

     

    AS3 - use the root property. But you have to cast it to MainTimeline or to MovieClip first.

    Examples:

    trace(MainTimeline(root));
    trace(MainTimeline(root).yourProperty);
    MainTimeline(root).yourMethod();
    
    //OR
    trace(MovieClip(root));
    trace(MovieClip(root).yourProperty);
    MovieClip(root).yourMethod();

     

    I hope these help.

     

     

    Regards,

    JC

    fminawiAuthor
    Participating Frequently
    April 23, 2020

    Thanks I will try