0

I have a public var called monster number in my monster class.

public var monsterNumber:int;

And in my document class, I want to give monsterNumber a number, lets say 5.

It's still tracing monsterNumber as 0 in my monster class, but 5 in my document class. Is there any way to change this var in my document class?

2
  • Do you have an instance of your monster class in your document class ? Commented Sep 23, 2013 at 20:41
  • Yes. this line of code public var grunt:Monster = new Monster(); is in my document class. And the monsterNumber is a public var in the Monster class. Commented Sep 23, 2013 at 20:44

2 Answers 2

1

Here's an example of how you can create a instance of Monster and modify it's property monsterNumber :

// in your document class

var monster:Monster = new Monster();
monster.monsterNumber = 1;
Sign up to request clarification or add additional context in comments.

Comments

0

You can define your variable as a static variable so you can change its value from anywhere you want.

Comments

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.