Reputation: 694
I'm working on a little project right now in ActionScript 3. The project is almost finished, but i want to add an intro frame. And then i get a problem.
I have 2 .as file with code. One is called Game, and the another is called intro. Game is the document class.
I have 2 frames and when i start the game, Game class is applied to both of them. So how can i apply Game class to 2nd frame and Intro class to the 1st.
The code is a little bit too long, so wouldn't upload it. Here is some part of it. Also code works perfectly so ai don't have problem with it.
Game.as
package {
public class Game extends MovieClip {
public function Game () {
//constructor
}
// some other functions
}
}
Intro.as
package {
public class Introextends MovieClip {
public function Intro() {
//constructor
}
// some other functions
}
}
Upvotes: 0
Views: 326
Reputation: 43842
You cannot dynamically change the Document Class in AS3, nor would it make any sense from an OOP perspective to be able to. You have three options:
Game
and have the Game
class load in Intro
before it starts the main code.Intro
and load in the Game
class after the intro has finished.Intro
and Game
individually.I would go with Option 3, since it's probably the easiest to implement and it makes the most sense. You can move all the frames from your old main timeline into a new MovieClip, then link that MovieClip to the Game
class. Make a similar MovieClip for the Intro
class. Use your new class to create new instances of each at appropriate times programmatically.
Upvotes: 3