Press button to show random image

Hello,
I'm used to working with the timeline and don't often go into the actionscript side of things.
I've created a 60 second animation of an hourglass timer counting down, and next to it, is a card showing a word. I need this whole animation to play when you hit a 'start game' button and also I need the word on the card to be a random word. All of the words are saved as separate vector files for now.
What is the best way to manage this on the timeline, and what would be the code to make a random image appear?
The only discussions I've found on this are for memory games and they're over complex for what I need!

I just thought I'd put the answer incase anyone else needs help with this.
In the end I added each image as an individual frame on the same layer within a movie clip and added a stop(); action to each frame.
I added this line of code to the key frame with the movieclip on the timeline:
this.MovieClipName.gotoAndPlay(Math.round(Math.random()* 4));   //change 4 to the number of frames you have in the movieclip
Works great so far - I'll let you know if it throws up extra problems

Similar Messages

  • Why item button only show #APP_IMAGES# image but not #WORKSPACE_IMAGES#?

    Hi All, I have a item button with Button display attributes - Style as Image. I don't know how come it can only display #APP_IMAGES# image but not #WORKSPACE_IMAGES# image. Please help... Thank you in advance. :)
    Chris

    Hi All, I have a item button with Button display attributes - Style as Image. I don't know how come it can only display #APP_IMAGES# image but not #WORKSPACE_IMAGES# image. Please help... Thank you in advance. :)
    Chris

  • How do I get a "transfer images" button to show up in the solution center?

    How do I get a "transfer images" button to show up in the solution center for my officejet 6500 709a on XP?
    Scan buttons are displayed and work, as does print.

    What installing the twain plug-in, you mean? Go to your applications folder. Find the Adobe Photoshop Elements 11 folder. Look in there for a folder called support files, then for a folder called optional plugins. In the Optional Plugins folder, there should be a folder called ImportModules. Just drag that from the Optional Plugins folder to the regular Plugins folder.
    This will be infinitely easier to do if you put your applications folder window into list view, not the default icon view. To do that, click this button at the top of the window:

  • Resizing JFrame on button click to show an image on the JFrame

    Dear All,
    I have a JFrame which has an empty label. On button click I want to set an icon for the label and want the JFrame to be resized to show that icon. I am using frame.pack() and I am not using any other sizing function. The code that I have right now, prints the image on the panel, but does not resize the frame to show the image. Pleae could someone help.package gui;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.Toolkit;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.ItemEvent;
    import java.awt.event.ItemListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    public class ComponentDemo extends JPanel implements ActionListener,
    ItemListener, MouseListener, KeyListener {
         private JTextArea textarea;
         private JButton button;
         private final static String newline = "\n";
         private JLabel imageIcon;
         public ComponentDemo() {
              button = new JButton("JButton welcomes you  to CO2001");
              button.addActionListener(this);
              add(button);
              textarea = new JTextArea(10, 50);
              textarea.setEditable(false);
              addMouseListener(this);
              textarea.addKeyListener(this);
              JScrollPane scrollPane = new JScrollPane(textarea);
              add(scrollPane);
              imageIcon = new JLabel();
              add(imageIcon);
              setBackground(Color.pink);
              new JScrollPane(this);
          * Create the GUI and show it. For thread safety, this method should be
          * invoked from the event-dispatching thread.
         private static void createAndShowGUI() {
              // Create and set up the window.
              JFrame frame = new JFrame("Simple FrameDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
              frame.setLocation(700, 200);
              // get the content pane and set the background colour;
              frame.add(new ComponentDemo());
         //     frame.setSize(screenSize);
              // frame.getContentPane().setBackground(Color.cyan);
              // Display the window.
              frame.pack();
              frame.setVisible(true);
              frame.setResizable(true);
         public static void main(String[] args) {
              // Schedule a job for the event-dispatching thread:
              // creating and showing this application's GUI.
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        createAndShowGUI();
         @Override
         public void actionPerformed(ActionEvent e) {
              // TODO Auto-generated method stub
              if (e.getSource() instanceof JButton) {
                   // System.out.println(e.getSource());
                   String text = ((JButton) e.getSource()).getText();
                   textarea.append(text + newline);
                   textarea.setBackground(Color.cyan);
                   textarea.setForeground(Color.BLUE);
                   textarea.setCaretPosition(textarea.getDocument().getLength());
                   imageIcon.setIcon(createImageIcon("SwingingDuke.png",
                   "Image to be displayed"));
         @Override
         public void itemStateChanged(ItemEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseClicked(MouseEvent arg0) {
              textarea.append("A Mouse click welcomes you to CO2001" + newline);
              textarea.setBackground(Color.green);
              textarea.setCaretPosition(textarea.getDocument().getLength());
         @Override
         public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void keyPressed(KeyEvent e) {
              System.out.println(e.getKeyChar());
              textarea.append("The key " + e.getKeyChar()
                        + " click welcomes you to CO2001" + newline);
              textarea.setBackground(Color.YELLOW);
              textarea.setFont(new Font("Arial", Font.ITALIC, 16));
              textarea.setCaretPosition(textarea.getDocument().getLength());
         @Override
         public void keyReleased(KeyEvent e) {
              System.out.println(e.getKeyChar());
              // textarea.append("The key "+
              // e.getKeyChar()+" click welcomes you to CO2001" + newline);
              // textarea.setBackground(Color.green);
              // textarea.setCaretPosition(textarea.getDocument().getLength());
         @Override
         public void keyTyped(KeyEvent e) {
              // TODO Auto-generated method stub
              System.out.println(e.getKeyChar());
              // textarea.append("The key "+
              // e.getKeyChar()+" click welcomes you to CO2001" + newline);
              // textarea.setBackground(Color.blue);
              // textarea.setCaretPosition(textarea.getDocument().getLength());
         /** Returns an ImageIcon, or null if the path was invalid. */
         protected ImageIcon createImageIcon(String path, String description) {
              java.net.URL imgURL = getClass().getResource(path);
              if (imgURL != null) {
                   System.out.println("found");
                   return new ImageIcon(imgURL, description);
              } else {
                   System.err.println("Couldn't find file: " + path);
                   return null;
    }

    myJPanel.setPerferredSize(new Dimension(new_width, new_hight));
    myJFrame.pack();

  • Hello! I have the Acrobat XI test version installed, got the registration Mail and confirmed it. When i have the program opened and try to convert the file from a pdf to a word and press the convert button, it shows a the message "application failed" (in

    Hello! I have the Acrobat XI test version installed, got the registration Mail and confirmed it. When i have the program opened and try to convert the file from a pdf to a word and press the convert button, it shows a the message "application failed" (in german "Fehler bei der Anmeldung"). I hope have explained the issue on the right way with my bad english. Do you have a solution for it?? Best regards, Marcus Wenk

    yes, you are right. it is the adobe reader via exportPDF. but it should be the acrobat. it was written on the internetpage...

  • Button to show images side-by-side missing from Photoshop CS6 toolbar

    In Photoshop CS6, a very important button is missing from the toolbar — the one to show two images side-by-side or above-and-below, and multiple images in other arrangements.  I need this button — it’s an important part of my.  (BTW, the button is still in Illustrator CS6.)

    MikeKPhoto wrote:
    the changes have negatively impacted productivity
    I'm not seeing that, and I can't agree with your assessment.  In using it all day every day since the public beta was made available, Ps CS6 has clearly improved my ability to go from raw file to finished product more quickly and reliably, and with better results at the end.  It's not THAT hard to re-learn where to find the window arrangement functions - give it a week.  Positionally the menu is almost in the same place the button used to be.
    MikeKPhoto wrote:
    By the way, do we not have a Customer Advocate, that is supposed to be on our side, notably absent from many, if not all, of these threads
    What gave you this idea?  I've never heard of such a person.  User forums are just full of other users trying how best to use the software, occasionally trying to help others do the same...
    -Noel

  • GIF image as a press button icon

    How can I apply a gif image on press button as icon, in oracle 10g forms.

    Hello,
    please do a search in the "Forum search" dialog box.
    This question has been posted hundred of times.
    Francois

  • Show waiting image on button click till response comes

    Hi All,
    I want to show waiting image on button click in a jsff page till response comes from back-end.
    For this I am using following code in button :-
    <af:commandButton text="Submit" id="cb1"
    actionListener="#{RegistrationManagedBean.onRegisterClick}"
    binding="#{RegistrationManagedBean.registerButton}"
    inlineStyle="width:65px; height:34px; font-size:11px; font-family:verdana; color:#fff; border-color:Gray; border-style:solid; border-width:1px; background-image:url(&quot;images/template-related/template_new/ButtonEnabledBG.png&quot;); background-repeat:repeat-x; float:right;"
    styleClass="button">
    <af:clientListener method="enforcePreventUserInput" type="action"/>
    </af:commandButton>
    enforcePreventUserInput is written inside on .js file.
    js code is :-
    function enforcePreventUserInput(evt) {
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('pt1:r1:p1');
    if (popup != null){
    AdfPage.PAGE.addBusyStateListener(popup,handleBusyState);
    evt.preventUserInput();
    function handleBusyState(evt){
    var popup = AdfPage.PAGE.findComponentByAbsoluteId('pt1:r1:p1');
    if(popup!=null){
    if (evt.isBusy()){ 
    popup.show();
    else if (popup.isPopupVisible()) {
    popup.hide();
    AdfPage.PAGE.removeBusyStateListener(popup,handleBusyState);
    Popup code is :-
    <af:popup id="p1" contentDelivery="immediate">
    <af:dialog id="d2" type="none" closeIconVisible="false"
    inlineStyle="background-color:none !important; width:54px; height:55.0px;">
    <af:image source="/images/template-related/LoadingCircle.gif" shortDesc="Loading" id="i7"/>
    </af:dialog>
    </af:popup>
    This is working and image is also being shown but this image is not shown as transparent(where as image is transparent) and also image is having top and bottom shading which is because of dialog or popup. But i dont want this shadow. Also inline style is not working for this popup.
    If there is any other way to solve this purpose please suggest.
    Thanks
    Edited by: 915148 on Jun 4, 2012 1:19 AM

    Ok, we will use a movieclip button but is there a tutorial somewhere on how to display the image when the button is clicked?

  • Make a button hide and show an image

    I want a button to hide and then show an image, basically an on/off switch.  I tried accomplishing this using multipl slides that jump around but even after removing all transitions, you can still tell that the slides are changing instead of just the image appearing and disappearing.  I have seen some posts about advanced actions but it's reading clear as mud.

    Christina,
    If you want a toggle button, that can be done with advanced actions. What did you read already? And which version of Captivate are you using?
    The idea is that:
    You create the image, but set its visibility unchecked in the Properties panel
    You create a user variable, will label it v_visib that has a start value of 0, will be set to 1 when the image is visible
    You create a conditional advanced action, that will check the value of v_visib:
    IF v_visib is equal to 0
        Show Image
         Assign v_visib with 1
    ELSE
        Hide Image
        Assign v_visib with 0
    I blogged several times about toggle buttons:
    http://lilybiri.posterous.com/toggle-shape-buttons      for Captivate 6 only
    http://lilybiri.posterous.com/toggle-button
    Lilybiri

  • Show random all images in a repeat region

    Hello,
    I have a repeat region that shows images from a db in
    ascending order.
    Is it possible to show the images random on another place?
    Example: you have image "A" - "B" - "C" after a refresh page
    you have "C"-"A"-"B"
    or "B" - "C" - "A"
    Is this possible or is there a good extension out there?
    Thanks in advanced,
    Sam

    No that would not work in Access.
    As it happens I offer a code snippet: Access db randomizer
    for aspVB.
    Email me directly if you'd like to hear more.
    emichael brandt
    michael -> valleywebdesigns.com
    SamDesign.be wrote:
    > Can I use this for asp vb with a access table ?
    > SELECT *
    > FROM qry_pub_rechts
    > ORDER BY naam_bedrijf ASC
    > Thanks in advanced
    >
    > "geschenk" <[email protected]> a
    écrit dans le message de news:
    > evgm55$34t$[email protected]..
    >> that´s how you can alter a MySQL query to give
    random results:
    >>
    >> SELECT * FROM your_table ORDER BY RAND()
    >
    >

  • I have to press F11 to get the Send button to show on Office 365 since their upgrade. Any work arounds besides pressing f11

    The send button used to show up on Outlook 365. Now I have to press f11 to get the send button to show up. This is a new problem, it used to work until about a week ago.

    I think Outlook 365 had an update. When I open Outlook in Explorer, and click reply to a message, the Send, Discard, Insert buttons appear like normal. However, when I click reply in Firefox, the buttons scroll up and aren't visible until I press f11 to see them. It just started doing this.

  • My volume doesnt work and when i press the volume button it shows the headphones volume on the screen without any headphones being plugged in. what can i do to fix this?

    My volume on my iPad doesnt work, when I press the voulme button it shows the headphones volume on the screen without any headphones being plugged in. Is there a fix for this?

    Try going to settings> general > reset> reset all settings. If that doesn't work. Place a headphone jack in there and just pull it out a couple times. The problem is either your iPad setting is stuck or there is actually a hardware problem and moving the jack in and out might fix it

  • Running gif animation and a random image output from an html button, HELP!!

    Trying to click (onClick) an animated gif image of an on/off switch to start a second animation which is located on a different location on the web-page (a 7-frame animation of a generator with moving parts) immediately followed by a random image selection function placing an image in a 3rd location on the page (next to the generator image). The random images are supposed to look like the result of the generator animation---the item that “pops out” of the generator.
    We thought the process to achieve this would be an “OnClick” on the on/off switch-animated-gif to start two javascript functions (generato animation function & random image function).
    To further complicate matters, we are doing this website in iWeb. We’re using iWeb SEO Tool to add the javascript to the header and HTML snippet in iWeb to place the HTML code. Not sure we’re actually doing the snippet right though---is it supposed to relate to the images---or is it separate? When the gifs are place on the iweb page, they work in the browser upon page load---the “on-click” & the random image function are NOT working...so we know we’ve done something(s) wrong.
    We’re thinking that we’re probably missing some code that describes where the 3 different image-spots are on the page (image #1 is the on/off switch gif, image#2 is the generator gif, image#3 is the generator output.png)....or just aren’t coding the string of functions correctly---or maybe our strategy for achieving this is just no correct (?).
    Here is the code we have tried that didn’t work. We desperately need a solution quickly and are open to any/other ideas for how to accomplish this. THANKS YOU in advance for your help!!!:
    script language = JAVASCRIPT>
    <!-- Hide script from old browsers
    function gif_animation(){
    if (document.images)
    generator = new Image
    generator_on = new Image
    generator.src = "christmassweatergenerator-offswitch.gif"
    generator_on.src = "christmassweater_generatoron-offswitch.gif"
    // Stop hiding script from older browsers -->
    Random Image Link Script
    By Website Abstraction (http://www.wsabstract.com)
    and Java-scripts.net (http://www.java-scripts.net)
    function random_imglink(){
    var myimages=new Array()
    //specify random images below. You can have as many as you wish
    myimages[1]="christmassweater_GENERATOR_files/cotton_candy_christmassweater.png"
    myimages[2]="christmassweater_GENERATOR_files/eiffel_tower_christmassweater.png"
    myimages[3]="christmassweater_GENERATOR_files/kitty_litter_christmassweater.png"
    myimages[4]="christmassweater_GENERATOR_files/spatula_christmassweater.png"
    <!--//specify corresponding links below
    var imagelinks=new Array()
    imagelinks[1]="#<a class="jive-link-external-small" href="http://www.christmassweaterfun.com/christmassweater_GENERATOR">http://www.christmassweaterfun.com/christmas_sweaterGENERATOR</a>"
    imagelinks[2]="#<a class="jive-link-external-small" href="http://www.christmassweaterfun.com/christmassweater_GENERATOR">http://www.christmassweaterfun.com/christmas_sweaterGENERATOR</a>"
    imagelinks[3]="#<a class="jive-link-external-small" href="http://www.christmassweaterfun.com/christmassweater_GENERATOR">http://www.christmassweaterfun.com/christmas_sweaterGENERATOR</a>"
    imagelinks[4]="#<a class="jive-link-external-small" href="http://www.christmassweaterfun.com/christmassweater_GENERATOR">http://www.christmassweaterfun.com/christmas_sweaterGENERATOR</a>"
    -->
    var ry=Math.floor(Math.random()*myimages.length)
    if (ry==0)
    ry=1
    document.write('<a href=''"'+imagelinks[ry]+'"''>')
    random_imglink()
    //-->
    </script>
    <!--the HTML:
    <a href="#" onclick="function gif_animation(); function random_imglink();">

    What's the URL of your site so we can examine it first hand? When you added the code to your post the servers messed it up and tried to render it on the page. We can get the code if we can get to your site.
    OT

  • Show an image on button click

    We need the button to display an image on a button when clicked for a tic tac toe game.  Any help would be helpful.

    Ok, we will use a movieclip button but is there a tutorial somewhere on how to display the image when the button is clicked?

  • Trouble showing different images. Some of them appear, others don't

    I'm using socket connection to transmit images from a computer to another. Sometimes it shows the image, sometimes it doens't.
    Here is the code that i'm using:
    SERVER SIDE:
    Archivo = new File("C:/Documents and Settings/Pedro/Desktop/Prueba2.JPG");
    Entrada = new FileInputStream(Archivo);
    salida = cliente.getOutputStream();
    longitud = (int)Archivo.length(); //File length;
    int longitud2 = 0;
    // Here i pass the file length trough the socket
    // salida tells me if the file y larger than 127 bytes or not.
    // if the file is larger than 127 bytes then i divide / (1024*1024)+1
    if(longitud < 129024){
    longitud2 = (longitud/1024)+1;
    salida.write(1);
    else if(longitud > 129024){
    longitud2 = (longitud/(1024*1024))+1;
    salida.write(2);
    salida.write(longitud2);
    int c =0;
    //The array is longitud length of bytes.
    arreglo = new byte[longitud];
    while(((c = Entrada.read(arreglo)) != -1))
    salida.write(arreglo);
    socket.close();
    cliente.close();
    Entrada.close();
    salida.close();
    //THE CLIENT SIDE (A METHOD called byte[] getArreglo() OF A
    //CLASS CALLED CClienteSocket)
    //returns: an array of bytes that is going to be used to show the image.
    // Cual tells me if the length is larger or not than 127.
    int cual = entrada.read();
    int longitud = entrada.read();
    if(cual == 1){
    longitud = longitud * 1024;
    else if(cual == 2){
    longitud = longitud * 1024 * 1024;
    byte arreglo[] = new byte[longitud];
    try
    int c = 0;
    while((c = entrada.read(arreglo)) != -1)
    socket.close();
    entrada.close();
    salida.close();
    return arreglo;
    FROM ANOTHER CLASS I DO: (PRESSING A BUTTON)
    void Boton_Foto_actionPerformed(ActionEvent e)
    try
    ClaseArreglo = new CClienteSocket();
    byte[] arreglo = ClaseArreglo.getArreglo();
    Icon Foto = new ImageIcon(arreglo);
    Label_Foto.setIcon(Foto);
    catch(IOException ex1){
    System.out.println(ex1.getMessage());
    catch(Exception ex5){
    System.out.println(ex5.getMessage());
    I get no exception during this operation. I want to know why it sometimes shows the image with no problem a sometimes it shows the image in half, or it doesn't show the image at all!!
    What should i do to warranty that the image is going to be shown???

    You can use this button to go to the currently used Firefox profile folder:
    *Help > Troubleshooting Information > Profile Directory: Show Folder (Linux: Open Directory; Mac: Show in Finder)
    See also:
    *http://kb.mozillazine.org/Profile_folder_-_Firefox

Maybe you are looking for

  • Remote app and ATV (shortcut to STANDBY)

    It would be nice if the Remote app had a direct "STANDBY" button you could hit no matter where you are in the menu structure and your ATV will enter into standby mode. Unfortunately there's not. So you have to turn on your TV, step through the menus

  • Trying to set up encrypted mails but I'm confused about certificates and keys

    Hello all, My first foray into encrypted emails and I'm already confused! To begin with, I'm trying to exchange mails with one other person, who I believe uses Outlook. So far: He's sent me his certificate (although I thought I would receive his publ

  • How come my premiere pro is not downloading

    I downloaded creative cloud for my mac pro and now the premiere pro is not downloading

  • Parallel printer to iMac or Time Capsule

    We just traded in an old PC for a new iMac running Lion.  We still have an old HP laserjet 4L that has been a trouble free workhorse, and would like to keep it if possible.  It only has one output, a standard parallel printer cable.  Is there a way t

  • Set Caption as File Name?

    Sometimes people send me photos I want in my library, and those images are named with a string of text that would be a suitable caption. I've got a fair number of these images now, and I'd like to know if there is a batch way of changing the caption