Hello I am trying to addChild for an array that I have.
I want to make it so if I have values in my database table it displays those values on
the movieclip.
my problem is I don’t want to have to add a line for each addChild, I want it to be based on what is in the database.
Here is what I have sofar
public class shop extends MovieClip
{
public static const shopURL:String = "http://localhost/scripts/shop.php";
public var menu_request:URLRequest;
public var menu_url:URLRequest;
public var _loader:URLLoader;
public function shop():void
{
loadShopMenuData();
}
private function loadShopMenuData():void {
// base section lets get some initial rank data
var randomParam:String = "?p=" + Math.floor(Math.random() * (10000000));
_loader = new URLLoader();
menu_url = new URLRequest(shopURL);
menu_request = new URLRequest(shopURL + "?action=menus");
menu_request.method = URLRequestMethod.POST;
_loader.addEventListener(Event.COMPLETE, onLoadMenuData);
_loader.load(menu_request);
}
public function onLoadMenuData(e:Event):void {
var menu:String = e.target.data;
var menuMC:menuBtn = new menuBtn();
var menuArray:Array=menu.split(",");
for each(menu in menuArray)
{
if(menuArray[1] != null)
{
menuMC.mainMenu.menuName.text = menuArray[1];
menuMC.x = 100;
menuMC.y = 100;
addChild(menuMC);
}
}
}
}
How would I addChild and change its Y position by 25 for each addChild that is to be added?
and also add an incremented value of 1 for each menuArray[] so basically make it so it does an addChild for reach database entry and moves it down appropriately
sorry if my explanation isn’t the best but I am sometimes pretty bad at explaining things haha