0

Here's the code

Document class:

menu.more.addEventListener(MouseEvent.CLICK, More_func)
function More_func (e:MouseEvent):void
{
    showmore.visible = true;
}

menu is the instance name of the movieclip in the document class. more is the instance name of a button inside the movieclip. And showmore is the instance name of another movieclip.

I want to transfer this code into the menu class. I just simkply copy/paste. But i recieve a message saying: 'Access of undefined property showmore.'.

So i am asking how i can use external object (in this case showmore) into another movieclip class (in this case menu).

The code works fine if it's in the document class.

1 Answer 1

1

Sounds like you just needs to go up to the parent for showmore. if you copy this code into the menu class, then referencing showmore looks for it in the menu class.

You need to be able to reference your document class from the menu class. You could do this a few different ways:

  1. (if menu and showmore are both children of the document class on the display list and showmore is public object) You'll need to cast the parent property or you'll get a compile error.

    DocumentClassName(parent).showmore.visible = false;

  2. Create a static variable on document class you can tap into IN YOUR DOCUMENT CLASS:

    public static var me:DocumentClassName;

IN YOUR DOCUMENT CLASS CONSTRUCTOR:

me = this;

IN YOUR MENU CLASS More_func:

DocumentClassName.me.showmore.visible = false;
Sign up to request clarification or add additional context in comments.

1 Comment

Tnx, mate. I tried second way and it work fine. Thanks again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.