Jump to content
php.lv forumi

Recommended Posts

Sveiki, šeit ir mans kods:

 

package

{

 

import flash.display.MovieClip;

import flash.display.DisplayObject;

 

 

public class Package extends MovieClip

{

var Height:int;

 

var Water:water;

var Dirt:dirt;

 

public function Package()

{

Water = new water();

Dirt = new dirt();

 

var level:Array = [[Water,Water,Dirt,Water,Water],

[Water,Dirt,Dirt,Water,Water],

[Dirt,Dirt,Water,Water,Water],

[Water,Water,Water,Water,Water]];

 

for (var row:int = 0; row <= 3; row++)

{

for (var column:int = 0; column <= 4; column++)

{

trace( row, column, level[row][column] );

 

switch (level[row][column].toString()){

case "[object water]":

Water = new water();

addChild(Water);

Water.x = column * level[row][column].width;

Water.y = row * level[row][column].width;

 

case "[object dirt]":

Dirt = new dirt();

addChild(Dirt);

Dirt.x = column * level[row][column].width;

Dirt.y = row * level[row][column].height;

}

}

}

}

}

 

}

 

Es gribētu saprast to, kā var addChild iedarbināt tur neizmantojot switch(). Jo ko es darītu tad, ja man būtu kādi 500 objekti, tad vajadzētu taisīt 500 switch casus, kas visticamāk reāli nobremzētu. Noteikti ir kāda labāka metode tam visam, tādēļ gaidu kādu ieteikumu, palīdzību.

Link to comment
Share on other sites

 

Tikmēr, kamēr es neizņemu šīs rindas:

 

tile.row = row;

tile.column = column;

 

tikmēr parādās šāds error:

 

ReferenceError: Error #1056: Cannot create property row on water.

at Package()

 

bet kad tās izņemu, tad darbojas. Priekš kā īsti tās divas rindas ir paredzētas?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...