AnotherArrow Wrote:Going to bed now, but thought i'd take moment to answer a few questions... i'll go deeper into detail tomorrow.
No problem, thanks again! Well, I know Java. I've had lectures about polymorphism, inheritance, overload, aggregation, composite, and design patterns. But I just dont want all that complexity in a medium sized game. I'm making a 8 world game (like Mario classic), and I want to make another one (a parody) of Mario, but using a more isometric view, with 2d tricks. However, I'm so accustomed with 'live placement of objects in the stage' (you must agree it ease the task of aligning assets without having to create a separate level editor), that I also put code inside timelines. But, provided we can place objects in the stage, like a big 'ground' MC, a big 'background 'object, the character, the particles, and make all the code using external files, using tricks like currentlabel to every movie clip, thats fine and a very good approach (modularity!)
But, again, for those cases you have 50 poses (walking, jumping, fleeing, swimming, playing, sleeping...), each one with 10 or more body parts that gets instantiated at runtime, with no instance name (although I can enter in each pose and name each body part instance), in those cases you just prefer to control movieclips putting code inside its timeline, because they have a life on their own. They are the 'masters' of clothing, in the Dress case. However, provided I name every body part, them refer to them using onEnterFrame, events and currentLabel using only external AS files, yes its possible, and maybe faster in CPU resources.
As about in-line code (object code), I'm using that bad practice less and less in AS2. Thats because I use a lot of dialogue scripts. So I will end up creating a big IF or CASE to switch text and code depending on a given level (in AS3, stage.level), place (stage.currentPlace), Puzzle (stage.currentPuzzle) or the name of the character himself as 'if (stage[charName]=="Robert" then dialogScript1() )', in a given AS file , like a 'dialog meeting class'.
AnotherArrow Wrote:Basically, by assigning each symbol to that class, every time that symbol appears on the stage, it will auto construct... no need to "add child" and such.
You say, only this base class (which has the same name as the FLA). Because other classes, even being instantiated as 'extend MovieCip' will need add child. But as about auto construct, you say that, if I have a new moviecilp, say, level, inside Game, is level able to access game variables just because they auto construct? In this case, can we call 'broadcasting variables'?
AnotherArrow Wrote:Because AS3 doesn't use OnEnterFrame like AS2 does... at least not in the traditional sense... I have to create my own OnEnterFrame (in this case DressOnEnterFrame) using EventListener. It does basically the same thing... just coded differently.
But thats an interesting approach. Naming each body part's (instance name) required to have their dress changed accordingly (e.g. Dress class) will make the onEnterFrame act on all of them like magic, as this linking is like as adding an aggregation class, that is, a class that adds function to another one.
AnotherArrow Wrote:I, myself, probably go overboard with creating too many classes, but I feel i have more control over an object. The question is, does the Moviceclip (or Object) require code and special treatment? If so, then most likely you'll need to make a class to automate much of its functions.
I like some complexity, like several character types with several clothing options for each one. That exponential approach requires two kind of body MC's for every body part: the part itself (torso, leg, arm, forearm) and the clothes associated (torso_clothes, leg_clothes, arm_clothes). So I use the body part as the father of clother part.
[o][.][.][.] -> code (only one frame is needed - onenterframe). It uses stage.CharSelect, which is an array of character types.
[X][X][X][X] -> characters - Each frame is a new one.
[X..........] -> Clothes (one filled frame only). Inside it, there is the code I've shown in my first post (DressSel). So father and children are checking everytime for a given change.
I can even optimize this further, putting this below inside children enterframe (to change dress) and a slight different version for the body part itself (to change character), that is, charSel.
(Below, dress code change in AS2):
- Code: Select All Code
if (!once)
{
once=true;
onEnterFrame=function()
{
if (currentlabel!=_root.DressSel[_root.DressNum])
{
if (_root.clothes_vest_remove and _root.DressNum!=3)
gotoAndStop("naked");
else
gotoAndStop(_root.DressSel[_root.DressNum]);
currentlabel=_root.DressSel[_root.DressNum];
}
}
}
So it wont be 'going and stopping' at every frame, but it will be stopped at once until currentlabel changes. I believe this can be done in AS3. And, as I've said before, using currentLabel in AS3 is a really good checking code. It gives resilience to the code (flexibility), once you have all MCs instance names you need.
AnotherArrow Wrote:Also, if I'm understanding what you wrote after that, it sounds like the Game Class and its variable where typed onto the frame 1 of scene 1?... if so, you are treading in territory I've never tried. I've always had my code in external files. (You can simply copy said code into its own Game.as file just like the Dress Code);
Yes, you are using the clean approach. FLA file with only assets and no code. AS files for code. Thats really good for portability and organization. But you will need to know everything about any movie clip, and that can be a real pain in the case of several character poses and clothes.
AnotherArrow Wrote:Check out my game in my sig and let me know if that's the effects you want, otherwise i think i've miss understood you on your goal.
I will check tomorrow (whops today). thanks really!! Java (coffee this time) doesnt work anymore around here.