Jump to content
php.lv forumi

Recommended Posts

Posted

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.

Posted

nu, ja tev nevajag, vari iztikt. es vnk. nezināju, ka tiem MovieClip'iem arī linkage klases piesaistītas.

es vispār savādāk tur visu ko definētu, tāpēc arī, paraduma pēc, piemetu to klāt.

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...