Skip to main content
Inspiring
March 27, 2014
Answered

How to dedicate certain classes to certain frames?

  • March 27, 2014
  • 1 reply
  • 834 views

I don't go through details at this stage and just explain my issue:

How can I assign different classes to different frames? For example class A to frame 1, classes B & C to frame 2, D to frames 6 and 10...

I'm programming a game by AS3 in Flash CS5  which I want different frames to act as a whole different game level and totally different classes except one, lets say THE HERO:p Which means I don't want to code the frames directly and just want them to read class files and then  they do the job.

You may not need to read the rest but in case you have time:

"The whole game has some pages such as intro, personal profile, options etc and then levels, and all in different frames. Every frame has its own code and the level frames may only share 1 or 2 custom classes. The point is I want to be able to have variables with the same name in different frames but not having the same meaning! var/function "a" is defined in 2 frames but not considered duplicated! And that's the reason i need to read different .as files in different frames and when going to next frame everything from the last one should be vanished, gone (except the user data such score which is saved in a specified class). The main reason I'm currently facing this issue is that I've already coded the whole game in the Main Class and put/removed all the backgrounds, objects, eventListeners as the player goes through levels, dynamically and the variety of values is killing me. So i decided to program every frame as a whole new level and place the visual objects of my scenes by Hand on the screen!"

Please tell me if the path I've taken is totally wrong. This is the first semi-complicated game I'm making and I wish to learn the correct way to program such games having many different levels in the mean of code and visual objects. Any suggestion?

I apologize for my poor grammar and misspellings.

This topic has been closed for replies.
Correct answer kglad

you can create members of class A in frame 1 and members of class B in frame 2, but you can't assign more than one document class to a single fla.

you could create a new fla for each game level.  each fla could then have its own document class.

your main fla would load the different levels so you could load level 1 in frame 1, level2 in frame 2 etc.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 27, 2014

you can create members of class A in frame 1 and members of class B in frame 2, but you can't assign more than one document class to a single fla.

you could create a new fla for each game level.  each fla could then have its own document class.

your main fla would load the different levels so you could load level 1 in frame 1, level2 in frame 2 etc.

Inspiring
March 27, 2014

whould you explain more about "you could create a new fla for each game level".

So for example when the player finishes level 1 another fla is called for level 2?! How?

kglad
Community Expert
Community Expert
March 27, 2014

use the loader class to load the level swfs.