0

I can access the targetObj instance inside the document class,but when I try to access it in another .as class,get this error:

Access of undefined property targetObj. 

Anyone can help?

2 Answers 2

0

First of all read this.

As you have not mentioned where the 'targetObj' is located, I'll take a guess that you are probably talking about a movieclip instance in the flash stage.

If you have other classes (.as files) and want to allow them to have access to the big family (of you sprites & MC's) then you may :

  • Initialize them in document class
  • Have them inherit document class
  • Have movieClips extended with a base class

In short you will have to link the document class to other classes to be able to access classes in the flash IDE or the stage itself, as document class is the entry point to all you custom classes.

Sign up to request clarification or add additional context in comments.

1 Comment

thanks !But my class already extends a base class:` extends VideoPlayerClient, and I refer to it this way in the document class:VideoPlayer.netStreamClientClass = TsVideoClient;`. I can't put it in the document class otherwise will get a nested class error...
0

Create a class, for example called resource. For each item on stage that you want to access, create a public static class member variable in the resource class. In your document class assign the stage item to this public static variable in the resource class. In your other classes you now can access your instances on stage through the references in the resource class.

1 Comment

@ollydbg - sorry I didn't see this comment. I think cuz the @ was missing. Anyway see this question and my answer for it, I go into a bit more detail stackoverflow.com/questions/4340391/…

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.