1 Reply Latest reply on Apr 19, 2016 5:09 AM by ddhayles

    How can I make a Team Generator?

    shawnh86766391

      Hello. I am looking to create a simple team generator app. I'd like to enter 4 names, click a button and have it give me a random 2 vs 2 matchup. Any idea on how to accomplish this using Edge Animate?

        • 1. Re: How can I make a Team Generator?
          ddhayles Level 3

          First create a symbol on the stage called 'Teams' and inside that symbol create a text layer and call it 'TeamName'.

           

          Back on the stage duplicate the 'Teams' symbol four times and rename them on your timelines as Team1, Team2, Team3, Team4

           

          Now create a button on the stage and put the following code on button click:

           

          var numberOrder = []

          while(numberOrder.length < 4){

            var randomnumber=Math.ceil(Math.random()*4)

            var found=false;

            for(var i=0;i<numberOrder.length;i++){

            if(numberOrder[i]==randomnumber){found=true;break}

            }

            if(!found)numberOrder[numberOrder.length]=randomnumber;

          }

           

          Team1 = sym.getVariable("Team"+numberOrder[0]);

          Team2 = sym.getVariable("Team"+numberOrder[1]);

          Team3 = sym.getVariable("Team"+numberOrder[2]);

          Team4 = sym.getVariable("Team"+numberOrder[3]);

           

          sym.getSymbol("Team1").$("TeamName").html(Team1);

          sym.getSymbol("Team2").$("TeamName").html(Team2);

          sym.getSymbol("Team3").$("TeamName").html(Team3);

          sym.getSymbol("Team4").$("TeamName").html(Team4);

           

          Lastly you need to set a list of variables with the team names that you need, in document.compositionReady put the following code:

           

          sym.setVariable("Team1", "Team 1 Name");

          sym.setVariable("Team2", "Team 2 Name");

          sym.setVariable("Team3", "Team 3 Name");

          sym.setVariable("Team4", "Team 4 Name");