So, as mentioned I'm doing some Flash this semester...I think I'd know how to do this in Python, with classes and all, but in AS3, everything is just so...detached.
I want to build a short chemistry game. You have 4 elements, fire, earth, wind and spirit, but the water is missing, the point is to make water. So you have on the stage, a fire_mc, a wind_mc, an earth_mc, a spirit_mc and the pot_mc. Clicking them adds a drop of them in the pot.
You have to put elements in there in a very specific order, but if you mess up, the count resets and you have to restart. The order is fire, spirit, earth, fire, spirit, wind. (very arbitrary at the moment, but let's say it's like that)
How would I make that in AS3?
(these tags are there to help people that want to build this specific kind of game)
This is my current code.
stop();
lvln.text="Phase 3 - Bargaining";
import flash.events.MouseEvent;
import flash.display.MovieClip;
import flash.events.Event;
const WIDTH:int=50;
const HEIGHT:int=50;
const SEPX:int=50;
var fireb:firebtn=new firebtn();
var spiritb:spiritbtn=new spiritbtn();
var earthb:earthbtn=new earthbtn();
var windb:windbtn=new windbtn();
var combo:Array=new Array();
var truecombo:Array=[fireb,spiritb,spiritb,windb,earthb];
var lastElm=combo[combo.length-1];
firebb.addEventListener(MouseEvent.CLICK, fire1);
windbb.addEventListener(MouseEvent.CLICK, wind1);
earthbb.addEventListener(MouseEvent.CLICK, earth1);
spiritbb.addEventListener(MouseEvent.CLICK, spirit1);
function add1(clip:DisplayObject)
{
if (combo.length > 6)
{
combo.shift();
combo.push(clip);
reorder();
}
}
function reorder()
{
for(var i:int = 0; i < combo.length; i++)
{
combo[i].x = i * 50;
}
}
function fire1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var fireb:firebtn=new firebtn();
stage.addChild(fireb);
add1(fireb);
fireb.width=WIDTH;
fireb.height=HEIGHT;
fireb.x=lastX;
fireb.y=lastY;
pop.play();
}
function wind1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var windb:windbtn=new windbtn();
stage.addChild(windb);
add1(fireb);
windb.width=WIDTH;
windb.height=HEIGHT;
windb.x=lastX;
windb.y=lastY;
pop.play();
}
function earth1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var earthb:earthbtn=new earthbtn();
stage.addChild(earthb);
add1(fireb);
earthb.width=WIDTH;
earthb.height=HEIGHT;
earthb.x=lastX;
earthb.y=lastY;
pop.play();
}
function spirit1(e:MouseEvent)
{
lastX+=SEPX;
twist.gotoAndPlay(2);
var spiritb:spiritbtn=new spiritbtn();
stage.addChild(spiritb);
combo.push(spiritb);
spiritb.width=WIDTH;
spiritb.height=HEIGHT;
spiritb.x=lastX;
spiritb.y=lastY;
pop.play();
}