3 Replies - 2427 Views - Last Post: 02 November 2009 - 02:17 AM

#1 phingko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-November 09

multidimensional array of movie clips in class file

Posted 01 November 2009 - 03:57 AM

Hi guys.
I wonder if anyone familiar with multidimensional array?
I'm doing a tile based game.
I've finished the tile map of the pipe, now i just need to make the water flow in each tile according to the path.
I make a function to check if the first tile finished its animation, the next tile will start the animation and so on until it reach the cup.
Below is part of my problem;

private var flow_order_array:Array = new Array(row1_array[0],row2_array[0],row3_array[0],row4_array[0],row4_array[1],row4_array[2],row4_array[3],
row5_array[3],row6_array[3],row7_array[3],row8_array[3],row9_array[3],row10_array[3],row11_array[3],row12_array[3]);

public function flow():void {
	 //check if flowing
	 if(!isFlowing) {
	 //start the flow
	 var num:int = 0;
	 trace("flow");
	 flow_order_array[num].play();
	 isFlowing = true;
	 }
	 if(isFlowing && ( flow_order_array[num].currentFrame ==  flow_order_array[num].totalFrame)) {
	 //get next segment
	 var segment:MovieClip;
	 trace("next Flow");
	 segment = flow_order_array[num+1];
	 segment.play
	 isFlowing = false;
	 }
}		 




when I debug it; the error is with my flow_order_array[num].play(); code; it said value is not a function.
I want to confirm that when I store the array into the multidimensional array, it is already convert to string?
So when I use it as int or number when I want to play the first index, it won't work.
Is that the cause ? Can anyone tell me a right direction, hint, help to solve this?


Thanks in advanced

Is This A Good Question/Topic? 0
  • +

Replies To: multidimensional array of movie clips in class file

#2 thehat   User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: multidimensional array of movie clips in class file

Posted 01 November 2009 - 05:57 AM

So what exactly is in these rowx_array arrays? If it's not a MovieClip, or a class descended from MovieClip, then it won't play. You can test if something is a MovieClip like this:
if(flow_order_array[num] is MovieClip) {
   //do something
}



or you can find out the className of something like this:
getQualifiedClassName(flow_order_array[num])


Also, in your second function you're missing the (): from the end of segment.play.

This post has been edited by thehat: 01 November 2009 - 05:58 AM

Was This Post Helpful? 0
  • +
  • -

#3 phingko   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 01-November 09

Re: multidimensional array of movie clips in class file

Posted 01 November 2009 - 10:52 PM

hi thehat
thx for the reply
my rowx_array is the tiles map,e.g.

private var row1_array:Array=new 
Array(PIPE_BTM,PIPE_BL,PIPE_BL,PIPE_BTM,PIPE_BL,PIPE_BL,PIPE_BTM,PIPE_BL,PIPE_BL,PIPE_BTM,PIPE_BL,PIPE_BL,PIPE_BTM,PIPE_BL,PIPE_BL,PIPE_BTM);


And I have 12 of them to build my tile map.
And each of them are movieclip itself.


I tried this
if(flow_order_array[num] is MovieClip) {
   //do something
}



but it didn't work as well.
So I tried to trace it

trace(flow_order_array[num] is MovieClip);


And it trace out false.
So does it mean that it's not a movieClip?
What can i do in this stage to get the flow array played?
I've asked around, they said my flow_array has a better way to do it by using coordinate and numbers to define which movie clip will be played. For me, that's sounds more difficult. T.T
And I don't have much time to figure that code again since the due date is closer.

Do you have any suggestion to make the arrays inside my flow_array can be converted to movieClip? beside the 'is MovieClip' code

Thanks a lot :)
Was This Post Helpful? 0
  • +
  • -

#4 thehat   User is offline

  • awake ? web();
  • member icon

Reputation: 106
  • View blog
  • Posts: 951
  • Joined: 28-February 08

Re: multidimensional array of movie clips in class file

Posted 02 November 2009 - 02:17 AM

Use this one to find out what class the items in your array are:
getQualifiedClassName(flow_order_array[num]);


Once we know what they are we can see if something unexpected is going on. Also, where do you create PIPE_BTM?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1