So I’m building a website that entirely in Flash. Basically just trying to plan out my class structure as this is the first AS 3 class based website I’m creating.
I have all my assets located inside my index.fla library. The website has a basic page building transition. First I attach my background asset and preform and function, on complete I attach my menu and preform a transition function so on an so forth.
Is it bad practice to have my page building transition inside my document class? Or should I build a something like a buildPage class so I can also build and unBuildPage class, other wise it seems I will have all my transition code inside my document class.
To get a grasp of what I am talking about here’s some code from my document class.
package {
import flash.display.*;
import flash.events.*;
import flash.utils.*;
import caurina.transitions.*;
public class Main extends Sprite {
private var fullScreenHeight;
private var fullScreenWidth;
private var mainStageScope;
public var counter;
public var myBase:Base;
public var myBaseMask:baseMask;
public var myMenuClip:menuClip;
public function Main () {
addEventListener (Event.ADDED_TO_STAGE, init);
}
private function init (e:Event):void {
mainStageScope = this.parent;
// Set my pattern properties and add it to the stage
fullScreenHeight = stage.stageHeight;
fullScreenWidth = stage.stageWidth;
var myPattern:Pattern = new Pattern();
mainStageScope.addChild (myPattern);
myPattern.height = fullScreenHeight;
myPattern.width = fullScreenWidth;
// Now we can add our main layout
myBase = new Base();
mainStageScope.addChild (myBase);
// We need to center the movieclip
myBase.x = (stage.stageWidth - myBase.width) / 2;
myBase.y = (stage.stageHeight - myBase.height) / 2;
// we need to add the base mask
myBaseMask = new baseMask();
mainStageScope.addChild (myBaseMask);
myBaseMask.x = myBase.x;
myBaseMask.y = myBase.y;
myBase.mask = myBaseMask;
// Now we start out menu transition
counter = 1;
showBase ();
}
public function showBase () {
Tweener.addTween (myBaseMask, {
width: myBase.width,
height: myBase.height,
time: .99,
rotation: 0,
onComplete: attachMenu
});
}
public function attachMenu () {
myMenuClip = new menuClip();
mainStageScope.addChild (myMenuClip);
myMenuClip.x = myBase.x;
myMenuClip.y = myBase.y + myMenuClip.height;
menuMover();
}
public function menuMover () {
Tweener.addTween (myMenuClip["menuItem_" + counter] , {
x:myMenuClip["menuItem_" + counter].x,
y:-50,
time: .22,
rotation: 0,
onComplete: moveNextMenuItem
});
}
public function moveNextMenuItem () {
counter ++;
if (counter <= 5) {
menuMover ();
} else {
trace ("Start next animation");
}
}
}
}
TIA for any advice, as I said this is my first time building a class based flash site with transitions and such so if I am way off please let me know