How do I change the contents of a string when I click on an image?

I have hundreds of images that need to play a unique sound when clicked.  In order to simplify the building of this flash file I need to streamline it in a way that will allow me to change only one word.  Below is some example code.  I think the reason it doesnt work is that I am declaring "word" twice...any suggestions anybody?  Thanks in advance...
import flash.events.MouseEvent;
stop()
var word:String = "family"
trace (word + "_nv")
this[word+ "_nv"].addEventListener(MouseEvent.CLICK, playaudio);
this[word+"_nv"].buttonMode = true;
var word:String = "grandchildren"
trace (word + "_nv")
this[word+ "_nv"].addEventListener(MouseEvent.CLICK, playaudio);
this[word+ "_nv"].buttonMode = true;
function playaudio (event:MouseEvent):void{
this[word+"_nv"].play()

I don't see where what you show is streamlining anything.  It would save code to just use the strings instead of assigning the string to variables and using the variables.  In any case. yes, you do not want to declare the same variable twice (use "var" only once).  And your playaudio function will only work with whatever the last value of "word" that you assign.
To streamline the code you could name each mc using a numeric increment (mc_1, mc_2, mc_3, etc), and then assign your listener in just a few lines using a loop.  In the play audio function you could use the instance name of the event.currentTarget...
this[event.currentTarget.name].play();
or even
MovieClip(event.currentTarget).play();

Similar Messages

  • How do I change the default software that opens when I click on a document?

    I'm not sure if this is the right neighborhood to post this question, but here goes. How do I change the default software that opens when I click on a document icon. I've been without MSWord for a long while, so all my word processing docs have been written in TextEdit, the stock mini-word processor that comes with OSX. Now I have MSWord and I no longer need TextEdit. Even more importantly, I'd like Word to automatically open when I click on a doc created in TextEdit. Adding ".doc" at the end doesn't do it. It's still refers to TextEdit to open the document.
    Any advice?
    Thanks,
    John

    Select a document of that type in the Finder, choose Get Info from the File menu, change the application under Open With, click on Change All, and confirm your action.
    (23558)

  • Why can't I change the content for some songs when I click the Get Info button?

    Why can't I change the content for some songs when I click the Get Info button?  The information on the song, artist, genre is grayed out and will not allow me to alter the information.

    Hi htechadmin,
    Revcevied your PM and noted all details, Many Thanks.
    Getting this addressed by the team, either they will reply to you, here, or they shall email Or Call you.
    Regards,
    LP

  • How do I change the default folder that opens when uploading a file to the internet from my mac? (at the moment it automatically defaults to 'Downloads' folder)

    How do I change the default folder that opens when uploading a file to the internet from my mac? (at the moment it automatically defaults to 'Downloads' folder)
    For example...
    I am on a webiste and wish to upload a photo.
    I click on select file on the website
    Finder opens and defaults to 'Downloads' folder (it happens with all wesbites)
    How do I change this?

    I am on a webiste and wish to upload a photo.
    I click on select file on the website
    You are attempting to download the picture to your computer not uploading photo to the website if I am understanding you correctly.
    To change the download direction, you must do so through your browser's Preferences.  If you are using Safari, hopefully, someone who uses Safari will help you and/or post over in their forums.  I do not use Safari.
    If using Firefox>Preferences>General>Save Files to:

  • How can I change the proggrams my Mac opens when I start my laptop?

    How can I change the proggrams my Mac opens when I start my laptop? My mac book Air opens Word and Skype automatically and I can´t seem to make not to do this. Help!

    Your Mac will also open anything that was open when it was shut down unless you uncheck this option in the restart and shutdown dialog.

  • How do I change the sound that is played when you iI use the Find my IPhone feature to make it alot louder?  The current sound is very faint, difficult to find as I am hard of hearing.

    How do I change the sound that is played when you I use the Find my IPhone feature to make it alot louder?  The current sound is very faint, difficult to find as I am hard of hearing.

    Hi,
    Tap the iPod icon in the Dock. Then tap the Airplay icon just to the right of the volume slider.
    Make sure the iPad speakers are selected, not your wireless.
    Carolyn 

  • How can I change the country on my account when I still have 11cents on it?

    How can I change the country on my account when I still have 11cents on my account? I lived in the US for 2 years, now that I'm back in France I wanna change it. Please help me.

    Contact itunes support and ask them to remove the balance

  • How do i change the administrator name and password when i forgot both of them

    how do i change the administrator name and password when i forgot both of them?

    Find the user name and then reset the password.
    Start the computer,then press and hold down command and R keys to start into recovery partition.
    When you see the Apple logo, release the keys.
    Wait until  OS X Utilities window shows up.
    Move the mouse to the menubar at the top and click "Utilities", then select "Terminal"
    from the drop down.
    Terminal window will appear.
    Type in   resetpassword   and press enter on the keyboard.
    Leave the Terminal window open.
    Reset Password Utility window will open with Macintosh HD selected.
    Select the user account from the popup menu box under “Select user account”.
    Note down the user account name.
    Enter a new password.
    Reenter the new password for the user.
    Note it down.
    Enter a hint.
    Click the "Save" button.
    Click  in the menubar and select Restart.
    Log in.
    If Keychain dialog box appears, select “Create New Keychain”.

  • When I open "mail" all that opens is the gray ribbon on the top.I have to go to "Mailboxes/inbox" to get it to aspen. What happened? How do I get the full screen to open when I click my "mail" icon like it used to?

    When I open "mail" all that opens is the gray ribbon on the top.I have to go to "Mailboxes/inbox" to get it to aspen. What happened? How do I get the full screen to open when I click my "mail" icon like it used to?

    Move your cursor way over to the right side of the window. There should be a thin bar. when you hover over the left side of the thin bar, the cursor will change to a vertical bar with an arrow sticking out the left. Click and drag to the left.

  • How can I change the content of JTable?

    Dear friends.
    I have an JTable. I create tablemodel for it and fill out it by data.
    In application at the run time I always need to change the content of whole table. For example I have a frame with JTree and JTable. When I click on the tree node I need to retrieve the data about this node in the JTable.
    Advice me please how can I do that and give an example please.
    Thank you.

    SOL I:
    There solution can be simple if u've written a model for it.
    If u are updating the data of the table by the setValueAt() method of the tableModel, in ur calling(mutating code), then just append a sinle line at the end of the method. U just need to fire a data change event corresponding to the event that has happened.
    void setValueAt(Object aValue, int rowIndex, int columnIndex) {
    - - - - - - - ur code
    //then last line can be
    fireTableDataChanged() ;
    OR
    fireTableCellUpdated(int row, int column);
    OR
    fireTableStructureChanged() ;
    depending uopn what has happened.
    SOL II:
    U may also try calling the method fireTableDataChanged(); from the place where the table data is getting mutated.
    like:
    ((AbstractTableModel) table.getModel()).fireTableDataChanged();
    [email protected]

  • HT3069 How can I change the content list when I change residence country?

    I bought an Apple TV in Mexico but came to came to the US to work on a project, so I brought my Apple TV with me. I already changed the credit card to an American one and all the country settings, but it still displays the Mexican list. How can I change the movie content?

    Purchases will be tied to the original account. Your US account will not have access.
    If your Apple TV is not displaying US content make sure the Apple TV location settings are correct. DNS should be on automatic.

  • How do you change the opacity of a button when it is rolled over?

    I have the button created i am not trying to change the background or anything. I wanted to know how do you change the opacity for the over state of a button? by the default i have it set to 70% opacity i want to change the over state to 100%

    You'll need to leave the overall opacity of the button symbol at 100%, then modify the opacity of each state (up, over, down, etc.) individually. The individual states cannot override a symbol setting. For instance, if your symbol was set to 50% opacity, setting the over state to 100% would only give you 100% of 50% opacity.
    Make sense?

  • How do you change the 4 seconds preset duration when selecting clips?

    When you select piece of clip in an event, how do you change the 4 seconds preset duration?

    Hi
    in iMovie'11 (as I don't have any iMovie'13 (v10)) and You note that You also use iM11
    Go up to the top row Menu and select "Setings" (Inställningar)
    and here select Browser (Bläddrare)
    and at bottom of this You got three options
    and can select ALL or up to 10 seconds
    I use click + alt (option-key) to select all of the Clip in Events - then fine tune it in my project.
    Good Luck
    Yours Bengt W

  • HT201320 How do I change the email name that shows when I send an email to someone ? I want it to be called my last name so the receiver can see its from me

    HOw do I change the name that shows to the recipient when I send an email ?

    Settings>Mail, Contacts and Calendars>Select your mail account>tap on your Account
    http://i1224.photobucket.com/albums/ee374/Diavonex/b78349deb233e4831b760140d4b8f 0a7_zps6929538c.jpg

  • How to properly change the content of text item object

    Working in CS3 here.
    I have a collection of text item objects from a grep search.
    I want to iterate through the items and possibly change the values depending on a conditional statement.
    So say I have a collection myTextObject that contains text item objects from a GREP search
    <code>
    for (var i = 0; i<myTextObject.length; i++) {
         if (myTextObject[i].content == "myCondition") {
              myTextObject[i].content = "My New Value";
    </code>
    Once I do that, all the other content values in my collection are one byte off. So I am guessing that when the collection is created, Indesign sets a byte limit on the collection and when content is replaced, it sets everything off.
    I understand that the collection is built from the beginning of the document so possibly iterating backward would solve the problem?
    Any other suggestions here?

    yep. iterating backwards shoud help.

Maybe you are looking for