Skip to main content
Known Participant
January 27, 2023
Question

Simple button to Image Display

  • January 27, 2023
  • 2 replies
  • 436 views

Hi,

 

I swear if Fireworks were still around I'd already be done. I'm not a programmer, little experience with Animate, not even sure if this is the right application. I want to have eleven buttons, names of men killed in WWI on a plaque in my church, and when the user clicks on the button, the man's photo is displayed. 

 

I can get Animate to briefly display the photo but not hold the photo until the next button click. Or the photo is stuck and won't go away.

 

I'm really frustrated. I need to get this done for the upcoming anniversary of the plaque installation...any help would be appreciated. Thanks!

    This topic has been closed for replies.

    2 replies

    Known Participant
    February 4, 2023

    What ended up doing is avoiding programming altogether. I have a series of buttons, one for each poster. The user has to click and hold to see the poster but so far nobody complained. I'm not a programmer so I couldn't figure out how to get the scripts suggested to be modified to work. I appreciate the time everyone took to answer the question and it was helpful to conceptually think about the answer. I learned a lot and will take more time to do a project like this in the future. Thanks!

    kglad
    Community Expert
    Community Expert
    February 5, 2023

    you're welcome.

    kglad
    Community Expert
    Community Expert
    January 27, 2023

    html5/canvas or as3.?

    Known Participant
    January 27, 2023

    HTML5 please

    kglad
    Community Expert
    Community Expert
    January 27, 2023

    create an array of the 11 vet names:

     

    var vetA = ["Sam Gold", "Robert Alprin", etc ];

     

    import all 11 images corresponding to the vets and assign links to each pic using the following convention, firstname_lastname.  eg, Sam_Gold, Robert_Alprin etc

     

    create a movieclip with a textfield wide enough to accomodate the longest vet name without a line break.  assign an instance name of tf to the textfield and assign a linkage id of tf_mc to the movieclip.

     

    use the following script:

     

    var vetA = ["Sam Gold", "Robert Alprin", etc ];

    // pick whatever initial values suits your esthetics

    var mcY = 50;  // first vet name y

    var mcX = 30; // all vet names y position

    var picX = 300;  // all pics x

    var picY = 50;  // all pics y

     

    /////////////////////////////////////////////////

    // end user defined variables //

    ////////////////////////////////////////////////

     

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

    this["mc"+i] = new lib.tf_mc();

    this["mc"+i].x = mcX;

    this["mc"+i].y = (i+1)*mcY;

    this.addChild(this["mc"+i]);

    this["mc"+i].name = i.toString();

    this["mc"+i].addEventListener("click",clickF.bind(this));

     

    this["pic"+i] = new lib[vetA[i].split(" ").join"(_")];

    this["pic"+i].name = "pic_"+i;

    this["pic"+i].x = picX;

    this["pic"+i].y = picY;

    }

     

    function clickF(e){

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

    if(this.getChildByName("pic_"+i).stage){

    this.removeChild(this.getChildByName("pic_"+i));

    break;

    }

    }

    this.addChild(this.getChildByName("pic_"+e.currentTarget.name));

    }