I need to build a series of blocks. When the user clicks on the block, the block changes color. Each block changed is stored into a boolean. (Eventually if the user clicks the correct combination, trace "Correct").
Baby steps. How do I get the blocks to appear on screen from an external .as file? Here is the main.as, and below the "blocks.as"
Code:
package
{
import flash.display.Sprite;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.SpreadMethod;
public class Main extends Sprite
{
var myBlocks:Blocks;
public function Main()
{
myBlocks = new Blocks;
addChild(myBlocks);
myBlocks.x = 0;
myBlocks.y = 0;
}
}
}
Code:
package
{
import flash.display.Sprite;
import flash.ui.Mouse;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.SpreadMethod;
public class Blocks extends Sprite
{
public var myRedBlock:Sprite;
public var myOrangeBlock:Sprite;
public var myBlueBlock:Sprite;
public var myPurpleBlock:Sprite;
public function Blocks()
{
myRedBlock = new Sprite();
addChild(myRedBlock);
myRedBlock.graphics.beginFill(0xFE0000);
myRedBlock.graphics.drawRect(10,stage.stageHeight/2,100,100);
myRedBlock.graphics.endFill();
myOrangeBlock = new Sprite();
addChild(myOrangeBlock);
myOrangeBlock.graphics.beginFill(0xFF7F00);
myOrangeBlock.graphics.drawRect(120,stage.stageHeight/2,100,100);
myOrangeBlock.graphics.endFill()
myBlueBlock = new Sprite();
addChild(myBlueBlock);
myBlueBlock.graphics.beginFill(0x00ADEF);
myBlueBlock.graphics.drawRect(230,stage.stageHeight/2,100,100);
myBlueBlock.graphics.endFill();
myPurpleBlock = new Sprite();
addChild(myPurpleBlock);
myPurpleBlock.graphics.beginFill(0xFF0066);
myPurpleBlock.graphics.drawRect(340,stage.stageHeight/2,100,100);
myPurpleBlock.graphics.endFill();
}
}
}