user648244
user648244

Reputation: 1278

ActionScript 3 - objects?

I'm new to Flash AS3. I started making a game and I am a bit confused. Let's assume that I want to create a game that has multiple levels/modes, how can I do this in an object orientated way?

When i create games in other languages e.g. XNA C#, i create a separate class then create an object of that class within the main class and run the game based on a simple statement.

if(player picks second option)
object2.start_level
else
object1.start_level 

How can this be done is AS3? Are there any Tutorials I could read on, please? Thanks.

Upvotes: 0

Views: 112

Answers (2)

Kodiak
Kodiak

Reputation: 5978

You may create your levels and attach them onto the main scene dynamically

if(player picks second option)
  addChild(object2);
else
  addChild(object1);

In your objects you can link the initialization of the level when the event Event.ADDED_TO_STAGE is distpached.

Cheers

Upvotes: 1

Eugeny89
Eugeny89

Reputation: 3731

Hm, if I understood correctly your question, you should behave just as you used to in XNA C#: two instances(object1 and object2) of class Level and

if(player picks second option) object2.start_level else object1.start_level

If I understood you incorrectly feel free to reask and specify your question.

P.S.: you can read about how to create classes in AS3 here

Upvotes: 0

Related Questions