Library items to the Stage


i have tomatoes in library named "tomato01" thru "tomato07".  have array of names in it.  have random function pics 1 of names @ time.  want able place specific tomato on stage.  ex if random number 7 put tomato07 on stage @ specific location , size. 

 

do tomato items in library have ot have same class assigned it?  not sure code.

 

can help? 

 

this code have far 1 specific tomato. in advance.

 

code:

var tomatoarray:array = ["tomato01","tomato02","tomato03","tomato04","tomato05","tomato06","tomato07"];

var randomnumber:number = math.floor(math.random() * tomatoarray.length) + 0;

trace(randomnumber);

trace(tomatoarray[randomnumber]);

 

 

function main()

{

          var newtomato:tomatosample = new tomatosample();

          this.addchild(newtomato);

          newtomato.x = 25;

          newtomato.y = 45;

}

main();

if want able load 1 of tomatoes library, each need have unique class designation, such tomato01, tomato02, etc...

 

if want use string instantiate class instance, need use code such as...

 

var classref:class = class(getdefinitionbyname("classname"));

var classinstance:* = new classref();

addchild(classinstance);

 

where "classname" tomato01, tomato02, etc...



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

How to change text Component easybook reloaded *newbee* - Joomla! Forum - community, help and support

PProHeadless.exe has stopped working error when opening projects in Adobe Media Encoder CS6

Preconditions Failed. - Joomla! Forum - community, help and support