all groups > flash actionscript > june 2005 >
You're in the

flash actionscript

group:

attach buttons and titles with delay


attach buttons and titles with delay dilbertje
6/9/2005 10:27:12 PM
flash actionscript:
hello

i have this little problem

let me draw a picture:

i've got 3 categories: fruit, meat, vegies

each cat is subdevided in other arrays, created as below


projects["fruit"][0],projects["fruit"][1],projects["fruit"][2],projects["fruit"]
[3]

projects["meat"][0],projects["meat"][1],projects["meat"][2],projects["meat"][3]

projects["vegies"][0],projects["vegies"][1],projects["vegies"][2],projects["vegi
es"][3]

now, i have a button, with an textfield inside. I need to attach this button
and fill in this textfield with the corresponding item
(worked so far)

I used an setinterval to create a delay so that the button appear not all
together.
but my prob is, there have to be a line between. This line is also a MC

so, this is the situation.

numButton = 0;
maxButtons = 3;

function attachButton() {
numButton++;

FRUIT
--------------------
fruititems
fruititems
....

MEAT
---------------------
meatitems
meatitems
....

VEGIES
-------------------


etc......

if(numButton == maxButtons) clearInterval(attachInterval);
}

attachInterval = setInterval(attachButton,1000);


the setinterval is needed to create a step by step appear of the buttons.

anybody an id?

thanks you guys (and girls ) so much!
Re: attach buttons and titles with delay mandingo
6/10/2005 12:52:23 AM
You will need to change this to suit exactly what you need but this should get
you off in the right direction...

myFood = new Array();

category = new Object();
category.foodId = "FRUIT";
category.edibles = new Array("Apple","Banana","Orange");

myFood.push(category)

category = new Object();
category.foodId = "MEAT";
category.edibles = new Array("Beef","Lamb","Pork");

myFood.push(category)

category = new Object();
category.foodId = "VEGETABLES";
category.edibles = new Array("Brussell Sprout","Carrot","Potato");

myFood.push(category)

imageLoader = function(incomingArray,clip){
counter = (typeof(counter) == "undefined") ? 0: counter;
if(incomingArray[counter] != "lineClip"){
numImage++;
trace(incomingArray[counter])
clip.attachMovie(incomingArray[counter],incomingArray[counter],100+counter);
clip[incomingArray[counter]]._x = 20 + 20*numImage;
clip[incomingArray[counter]]._y = 20 + 20*numRow;
}else{
numRow++
trace("this trace is recording the instances of " + incomingArray[counter])
clip.attachMovie("lineClip","line"+numRow, 100+counter);
numImage = 0;
}
counter++
if(counter ==incomingArray.length){
clearInterval(setup);
}
}
constructor = function(){
constructionArray = new Array();
for(var k=0; k<myFood.length; k++){
constructionArray.push(myFood[k].foodId)
for(var j=0; j<myFood[k].edibles.length; j++){
constructionArray.push(myFood[k].edibles[j]);
}
constructionArray.push("lineClip");
}
setup = setInterval(imageLoader,500,constructionArray,this);
}
constructor();


If you put that code in a fresh movie and test it, you should see what is
happening... I have taken the liberty of re-organising some of your data
structure to make it a little easier for me to read back...

I hope this helps
cheers,
AddThis Social Bookmark Button