Current location: Hot Scripts Forums » General Web Coding » Flash & ActionScript » Color Change and Booleans


Color Change and Booleans

Reply
  #1 (permalink)  
Old 03-16-11, 12:19 PM
CEinNYC CEinNYC is offline
Newbie Coder
 
Join Date: Dec 2010
Posts: 10
Thanks: 4
Thanked 0 Times in 0 Posts
Color Change and Booleans

Hey all. First, Thank you for any help!

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();
			
		}	
		
	}
}
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 06:59 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.