This is a discussion on Dynamically Make Multiple Buttons From 1 Symbol with Only Actionscript AS3 within the Flash English forums, part of the Flash CS3 - CS4 - CS5 category; Hey guys... I have a goodie to give to any noobies out there. I'm kind of new to Object Oriented ...
Hey guys...
I have a goodie to give to any noobies out there. I'm kind of new to Object Oriented Programming, and AS3 myself...
I made a flash application that gets an array from a php variable and back to flash to create dynamic buttons, with only actionscript 3. To edit the behavior of the button, all you have to do is edit 1 Symbol... Which is really nice.
The reason I'm posting this is to get some input on possibly a better way to do this thats more reliable? This application breaks when it is opened on two browsers at once (on Win7 64 Bit). How would I go about fixing that? In order to make it work again, I have to wait for the cache to fully renew, or change the name of the swf file. Any suggestion would be awesomely appreciated.
And this is free :-DCode:import flash.events.MouseEvent; var currentTarget:String; //========================================================== // Create A new URLVariables instance to store the variable var myVariables:URLVariables = new URLVariables(); myVariables.sendRequest = "get_nav_variables"; var myRequest:URLRequest = new //Change the url to the location of your php script. May be on your website. URLRequest("http://localhost/class/data_control.php"); myRequest.method = URLRequestMethod.POST; myRequest.data = myVariables; var myLoader:URLLoader = new URLLoader; myLoader.dataFormat = URLLoaderDataFormat.VARIABLES; myLoader.load(myRequest); myLoader.addEventListener(Event.COMPLETE, loadComplete); function loadComplete(evt:Event):void { var nameArray:Array = evt.target.data.navNames.split(","); //Split Variable Into Array... trace(nameArray[1]); //=============================================================== function clickedNav (e:MouseEvent):void { stageTxt.text = e.currentTarget.name; } var i:Number = 0; var xPos:Number = 100; var yPos:Number = 50; while(i<=nameArray.length-1) { var my_mc = new BlueShoe(); if (i == 0) { stageTxt.text = nameArray[i]; } my_mc.name=nameArray[i]; my_mc.targetName.text = nameArray[i]; my_mc.x = xPos; my_mc.y = yPos; my_mc.addEventListener(MouseEvent.CLICK, clickedNav); addChild(my_mc); xPos = xPos + 100; trace(i); i++; } }
NOTE : SCRIPT ONLY RUNS ON PHP ENABLED SREVERS... LIKE XAMP.
Bookmarks