开发者

Add symbol to stage without exporting for actionscript?

I'm making a game in flash, and I want to have a whole bunch of different rooms that I can make and delete with c开发者_Python百科ode. Ordinarily I'd just use something like:

var room:Sprite = new room1();
game.main.addChild(room);

...but I'd have to export every room for actionscript. Is there a way to get them made just being symbols? If nothing else, I could layer all the rooms on top of each other in one symbol and set all but one invisible, but I'd prefer doing it this way with getDefinitionByName().


What distinguishes one room from another? What is different about them? Ideally, you would group those "differences" into a hierarchy of classes. As a simple example, if some rooms were blue, some rooms were red you might create the following classes:

Room
ColoredRoom

Where Room is the parent of ColoredRoom. Then, you'd give colored room a property like:

var color:Color;

And set that property to create three different rooms:

var redRoom:ColoredRoom = new ColoredRoom();
var greenRoom:ColoredRoom = new ColoredRoom();
var blueRoom:ColoredRoom = new ColoredRoom();

redRoom.color = new Color(255,0,0);
greenRoom.color = new Color(0,255,0);
blueRoom.color = new Color(0,0,255);

Once you "group" your classes, you shouldn't have to export more than a couple "types" of rooms. Each will have it's own set of properties that make it different from the other (perhaps different source image files or movieclips).

The basic point is, approaching your problem in terms of Objects should make things easier. Figure out:

if you had to lump your rooms into 2 or 3 different categories, what would they be?

and go from there. I hope that helps in some way,

--gMale


I think that you do have to export each for AS, but I'm not sure... however, if you do go the route of putting them all in one symbol, it will be much easier to make it a MovieClip, and put each on a different frame; you can then switch between rooms by going to the appropriate frame.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜