+ Reply to Thread
Results 1 to 1 of 1

Dynamically Make Multiple Buttons From 1 Symbol with Only Actionscript AS3

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

  1. #1
    Junior Member Settled In hooddaniel is on a distinguished road
    Join Date
    Jun 2011
    Posts
    1
    Rep Power
    0

    Lightbulb Dynamically Make Multiple Buttons From 1 Symbol with Only Actionscript AS3

    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.

    Code:
    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++;
    }
    }
    And this is free :-D

    NOTE : SCRIPT ONLY RUNS ON PHP ENABLED SREVERS... LIKE XAMP.
    Attached Files

+ Reply to Thread

Similar Threads

  1. Multiple Buttons Linking to Same Frames
    By Flyingfish in forum Actionscript 3.0 newbies
    Replies: 2
    Last Post: 18-12-10, 02:59
  2. Multiple Gallery in Actionscript
    By Orlandomac in forum Flash English
    Replies: 0
    Last Post: 25-01-10, 17:52
  3. Replies: 0
    Last Post: 14-10-08, 05:26
  4. Replies: 1
    Last Post: 23-08-08, 07:48
  5. Urgent Help - Using a movie symbol with a preloader
    By cgswami in forum Actionscript 3.0 newbies
    Replies: 5
    Last Post: 04-09-07, 06:44

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts