I’ve used this site as a resource leading up to this, not particularly sure if I worded this correctly, hopefully someone can help.
I have a class “Block” which is just a square (will be something else later on in the process) I want each block to have controls to add an additional block in either direction so I have another class BlockButtons which has my buttons for each direction.
And another class GlobalVar where I keep all my variables for funsies
Here is my Code
// Main Block function in Block Class
public function Block()
{
this.x = GlobalVar.nPW
this.y = GlobalVar.nPH
this.addEventListener(MouseEvent.CLICK, BlockSelected);
//Adds Controls to Block
var NewBlockButtons:BlockButtons = new BlockButtons();
addChild(NewBlockButtons);
//Buttons which create new blocks
NewBlockButtons.Mright.addEventListener(MouseEvent.CLICK, NewBlockFunction);
NewBlockButtons.Mup.addEventListener(MouseEvent.CLICK, NewBlockFunction);
NewBlockButtons.Mleft.addEventListener(MouseEvent.CLICK, NewBlockFunction);
NewBlockButtons.Mdown.addEventListener(MouseEvent.CLICK, NewBlockFunction);
//Creates NewBlocks
public function NewBlockFunction(event:MouseEvent):void
{
GlobalVar.oPW = GlobalVar.nPW
GlobalVar.oPH = GlobalVar.nPH
GlobalVar.nPW = event.target.x;
GlobalVar.nPH = event.target.y;
var NewBlock:Block = new Block();
addChild(NewBlock);
}
Ok this next bit is in the BlockButtons Class
public class BlockButtons extends MovieClip{
public function BlockButtons()
{
this.x = 0
this.y = 0
trace(1);
}
}
The buttons themselves are inside the movieclip BlockButtons.
So what I need is a way to hide all BlockButtons Except for the selected block. and also make the most recently created block THE selected block.
I had this working somewhat when I had the buttons inside the Block MC and was turning them off with .visible=false and true. however I could not find a way to turn off any that weren’t turned off by creating a new block.