1 Replies - 2000 Views - Last Post: 25 November 2009 - 12:17 AM

#1 raisdead   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-November 09

Add movieclip to stage from class

Posted 24 November 2009 - 05:48 PM

I am trying to draw to the stage from an external class. When I move the drawCell's functions content to the main file it works, but it does not like this.. Thanks.



Cell.as
package Maze{
	import flash.display.MovieClip;
	
	public class Cell extends MovieClip{
		public var visited:Boolean;
		public var walls:Array;
		
		public function Cell() {
			visited = false;
			walls = [true,true,true,true];
		}
		public function drawCell(xx:int,yy:int) {
				var line:MovieClip = new MovieClip();
				line.graphics.beginFill(0x000000);
				line.graphics.drawRect(20,20,20,20);
				line.graphics.endFill();
				addChild(line);
		}
	}
}
 


Maze.as
package Maze{
	import Maze.Cell;
	
	public class Maze {
		public var sizex:int;
		public var sizey:int;
		private var counter:int;
		public var mazeData:Array = new Array();
		
		public function Maze(six:int=22,siy:int=22) {
			sizex = six;
			sizey = siy;
			for(var i:Number=0;i<sizex+1;i++) {
				mazeData[i] = new Array();
				for(var j:Number=0;j<sizey+1;j++) {
					mazeData[i][j] = new Cell();
				}
			}
			genMaze();
			drawMaze();
		}
		
		private function genMaze(startx:int=1,starty:int=1,method:int=1) {
			//taken out for space
		}
		private function drawMaze():void {
			for(var i:int=0;i<=sizex;i++)
				for(var j:int=0;j<=sizey;j++)
					mazeData[i][j].drawCell(i,j);
		}
	}	
		
}



Frame 1 Script
import Maze.*;

//Setup
	var maze1:Maze = new Maze();
	var player1:Player = new Player();




Thanks

Attached File(s)

  • Attached File  Maze.zip (8.49K)
    Number of downloads: 111


Is This A Good Question/Topic? 0
  • +

Replies To: Add movieclip to stage from class

#2 raisdead   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 6
  • Joined: 24-November 09

Re: Add movieclip to stage from class

Posted 25 November 2009 - 12:17 AM

Well Both my maze and my cell needed to extend MovieClip then I needed to addChild the maze and the cell...

If you need assistance with the same problem just post.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1