How to use the same keypair for both encrypt/decryprt-SunPKCS#11

Dear All,
Subject: To access iKey 2032 token, to retrieve public/private key from iKey 2032 token using pkcs#11 in sdk1.5, to encrypt/decrypt files.
When I separate the encrypt and decrypt part of java program, encryption program works well, whereas decryption program does not decrypt anything in the decrypt file (But there is no error). I printed out the public and private key in both encrypt and decrypt part of java program, its displayed differently::
Encrypt program:
SunPKCS11-rainbow_token RSA public key, 1024 bits (id 10, session object)
modulus: 114338469922835728259534620463489934081917342509275191892563243582065
74380495029336519036972702864998634664269499641616889325482699399559620370181624
72068116957594402738459932902481604823224406859575930392708524033619120886256353
58738237376491107769961041015109436347533548940674900728805627968145581222172729
public exponent: 65537
SunPKCS11-rainbow_token RSA private key, 1024 bits (id 11, session object, sensi
tive, unextractable)
Decrypt Program::
SunPKCS11-rainbow_token RSA public key, 1024 bits (id 12, session object)
modulus: 138556361758970660122782926386849783732271581948935425587968692317930
09262429353977097956605140384961825974398004270547046620971835394362397699233738
54481804748731546655197744692886754946373745924825650876065903334173666990347814
83727290962956934521650035029131176614982652900659797194703065074407857754883163
public exponent: 65537
SunPKCS11-rainbow_token RSA private key, 1024 bits (id 13, session object, sensi
tive, unextractable)
I suspect that every time program generates different set of key, therefore we need to store the generated key during encryption part (i believe it is to be in the keystore) and to use the same for decryption part. Could you please give me a tips how to do this?
Encrypt Program ::
import java.io.*;
import java.util.*;
import java.lang.*;
import java.sql.*;
import java.text.*;
import java.math.*;
import java.security.*;
import java.security.cert.*;
import java.security.interfaces.*;
import javax.crypto.interfaces.*;
import javax.net.ssl.*;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import java.security.KeyStore.*;
* A class of Encrypt.
public class Encrypt
public Encrypt(){}
public void loginToken() {
     Provider p = new sun.security.pkcs11.SunPKCS11(MQConfig.getvalue("SecurityPropertyPath"));
     Security.addProvider(p);
     KeyStore ks = null;
     try{
          String password = General.ReadFiles(MQConfig.getvalue("logFilePath"),"Simple");
          password = password.trim();
          char pin[] = password.toCharArray();
          ks = KeyStore.getInstance("pkcs11");
          ks.load(null,pin);
     KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA",p);
          KeyPair kp = kpg.genKeyPair();
          kpg.initialize(1024, new java.security.SecureRandom());
          FileInputStream in = new FileInputStream("C:\\ReportDBBE.properties");
          FileOutputStream out = new FileOutputStream("C:\\ReportDBAE.properties");
          Cipher cp=Cipher.getInstance("RSA/ECB/PKCS1Padding", p);
          cp.init(cp.ENCRYPT_MODE,kp.getPublic());
          CipherOutputStream cout=new CipherOutputStream(out,cp);
          byte[] input=new byte[8];
          int byteread=in.read(input);
          while(byteread!=-1){
               cout.write(input,0,byteread);
               byteread=in.read(input);
          cout.flush();
          in.close();
          cout.close();
     catch(NoSuchAlgorithmException nsae)
     System.out.println("No Such Algorithm Exception " + nsae.getMessage());
     catch(NoSuchPaddingException nspe)
     System.out.println("No Such Padding Exception " + nspe.getMessage());
     catch(InvalidKeyException ike)
     System.out.println("Invalid Key Exception " + ike.getMessage());
     catch(IllegalStateException ise)
     System.out.println("Illegal State Exception " + ise.getMessage());
     catch(KeyStoreException kse)
     System.out.println("Key Store Exception " + kse.getMessage());
     catch(CertificateException ce)
     System.out.println("Certificate Exception " + ce.getMessage());
     catch(IOException ioe)
     System.out.println("IO Exception " + ioe.getMessage());
public static void main (String args[]) throws Exception {
     try{
     Encrypt tl = new Encrypt();
     tl.loginToken();
     }catch(Exception e){
     e.printStackTrace();
Decrypt Program ::
import java.io.*;
import java.util.*;
import java.lang.*;
import java.sql.*;
import java.text.*;
import java.math.*;
import java.security.*;
import java.security.cert.*;
import java.security.interfaces.*;
import javax.crypto.interfaces.*;
import javax.net.ssl.*;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import java.security.KeyStore.*;
* A class of Decrypt.
public class Decrypt
public Decrypt(){}
public void loginToken() {
     Provider p = new sun.security.pkcs11.SunPKCS11(MQConfig.getvalue("SecurityPropertyPath"));
     Security.addProvider(p);
     KeyStore ks = null;
     try{
          String password = General.ReadFiles(MQConfig.getvalue("logFilePath"),"Simple");
          password = password.trim();
          char pin[] = password.toCharArray();
          ks = KeyStore.getInstance("pkcs11");
          ks.load(null,pin);
     KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA",p);
          KeyPair kp = kpg.genKeyPair();
          kpg.initialize(1024, new java.security.SecureRandom());
          FileInputStream in1 = new FileInputStream("C:\\ReportDBAE.properties");
          FileOutputStream out1 = new FileOutputStream("C:\\ReportDBAD.properties");
          Cipher cipher=Cipher.getInstance("RSA/ECB/PKCS1Padding", p);
          AlgorithmParameters algParams = cipher.getParameters();
          cipher.init(Cipher.DECRYPT_MODE,kp.getPrivate(),algParams);
          CipherInputStream cin1=new CipherInputStream(in1,cipher);
          byte[] input1=new byte[8];
          int byteread1=cin1.read(input1);
          while(byteread1!=-1){
               out1.write(input1,0,byteread1);
               byteread1=cin1.read(input1);
          out1.flush();
          in1.close();
          out1.close();
          cin1.close();
     catch(NoSuchAlgorithmException nsae)
     System.out.println("No Such Algorithm Exception " + nsae.getMessage());
     catch(NoSuchPaddingException nspe)
     System.out.println("No Such Padding Exception " + nspe.getMessage());
     catch(InvalidKeyException ike)
     System.out.println("Invalid Key Exception " + ike.getMessage());
     catch(IllegalStateException ise)
     System.out.println("Illegal State Exception " + ise.getMessage());
     catch(InvalidAlgorithmParameterException iape)
     System.out.println("Invalid Algorithm ParameterException " + iape.getMessage());
     catch(KeyStoreException kse)
     System.out.println("Key Store Exception " + kse.getMessage());
     catch(CertificateException ce)
     System.out.println("Certificate Exception " + ce.getMessage());
     catch(IOException ioe)
     System.out.println("IO Exception " + ioe.getMessage());
public static void main (String args[]) throws Exception {
     try{
     Decrypt tl = new Decrypt();
     tl.loginToken();
     }catch(Exception e){
     e.printStackTrace();
Configuration file::
name = rainbow_token
library = c:\winnt\system32\dkck201.dll
attributes(*,CKO_PRIVATE_KEY,*) = {
CKA_SIGN = true
attributes(*,CKO_PRIVATE_KEY,CKK_DH) = {
CKA_SIGN = null
attributes(*,CKO_PRIVATE_KEY,CKK_RSA) = {
CKA_DECRYPT = true
}

Hi all,
Now i manage to use the same keypair for both encrypt/decryprt-SunPKCS#11. Below is my code woks well. In my code i hard coded alias name of certificate, did anyone knows how to read alias name of certificate from iKey token 2032??
import java.io.*;
import java.util.*;
import java.lang.*;
import java.sql.*;
import java.text.*;
import java.math.*;
import java.security.*;
import java.security.cert.*;
import java.security.interfaces.*;
import javax.crypto.interfaces.*;
import javax.net.ssl.*;
import javax.crypto.*;
import javax.crypto.spec.DESKeySpec;
import java.security.KeyStore.*;
* A class of Encrypt.
public class Encrypt
public Encrypt(){}
public void loginToken() {
     Provider p = new sun.security.pkcs11.SunPKCS11(MQConfig.getvalue("SecurityPropertyPath"));
     String myAlias = "349eefd1-845b-4ba4-9f88-06e9f5cb82f6";
     /** to view alias name
     keytool -list -v -keystore NONE -storetype PKCS11 -storepass PASSWORD
     Security.addProvider(p);
     KeyStore ks = null;
     PrivateKey privKey = null;
     PublicKey pubKey = null;
     try{
          String password = General.ReadFiles(MQConfig.getvalue("logFilePath"),"Simple");
          password = password.trim();
          char pin[] = password.toCharArray();
          ks = KeyStore.getInstance("pkcs11");
          ks.load(null,pin);
          java.security.cert.Certificate cert = ks.getCertificate(myAlias);
          Key key = ks.getKey(myAlias, pin);
          if(key != null) {
               System.out.println("key class: " + key.getClass().getName()); // -> sun.security.pkcs11.P11Key$P11PrivateKey
               System.out.println("key bytes: " + key.getEncoded()); // -> null!!!!!!!
     if(PrivateKey.class.isInstance(key)) {
     privKey = (PrivateKey)key;
     System.out.println("algo: " + privKey.getAlgorithm()); // -> RSA
     //Signature rsasig = Signature.getInstance("SHA1withRSA");
     //rsasig.initSign(privKey);
     //rsasig.update(data.getBytes());
     //byte[] sigBytes = rsasig.sign();
     pubKey = cert.getPublicKey();
     //System.out.println("signed bytes: " +sigBytes);
     //return sigBytes;
     //KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA",p);
          //KeyPair kp = kpg.genKeyPair();
          //KeyPair kp = kpg.generateKeyPair();
          //kpg.initialize(1024, new java.security.SecureRandom());
          FileInputStream in = new FileInputStream("C:\\ReportDBBE.properties");
          FileOutputStream out = new FileOutputStream("C:\\ReportDBAE.properties");
          Cipher cp=Cipher.getInstance("RSA/ECB/PKCS1Padding", p);
//cp.init(cp.ENCRYPT_MODE,kp.getPublic());
          cp.init(cp.ENCRYPT_MODE,pubKey);
          CipherOutputStream cout=new CipherOutputStream(out,cp);
          byte[] input=new byte[8];
          int byteread=in.read(input);
          while(byteread!=-1){
               cout.write(input,0,byteread);
               byteread=in.read(input);
          cout.flush();
          in.close();
          cout.close();
     catch(NoSuchAlgorithmException nsae)
     System.out.println("No Such Algorithm Exception " + nsae.getMessage());
     catch(NoSuchPaddingException nspe)
     System.out.println("No Such Padding Exception " + nspe.getMessage());
     catch(InvalidKeyException ike)
     System.out.println("Invalid Key Exception " + ike.getMessage());
     ike.printStackTrace();
     catch(IllegalStateException ise)
     System.out.println("Illegal State Exception " + ise.getMessage());
     catch(KeyStoreException kse)
     System.out.println("Key Store Exception " + kse.getMessage());
     catch(CertificateException ce)
     System.out.println("Certificate Exception " + ce.getMessage());
     catch(IOException ioe)
     System.out.println("IO Exception " + ioe.getMessage());
     catch(UnrecoverableKeyException unrke)
     System.out.println("Unrecoverable Key Exception " + unrke.getMessage());
public static void main (String args[]) throws Exception {
     try{
     Encrypt tl = new Encrypt();
     tl.loginToken();
     }catch(Exception e){
     e.printStackTrace();
Your help is very much appreciated!!!!

Similar Messages

  • How to Use the same iview for both KM End User and the KM Administrator

    Hi friends,
    *This is my scenario :* How to Use the same iview for both KM End User and the KM Administrator but with different Context
    Menu Options.
    i followed these steps but im getting same context menu for both KM End User and the KM Administrator .
    Assign the role Content Administrator to the user km_admin. This is needed so that km_admin can change
    the presentation settings for the KM Folder u201EReports_kmFolder‟.
    Now, login with user km_admin. Navigate to the Km Folder reports_kmFolder through Content Administration
    -> Km Content. Click on Details link of the folder reports_kmFolder.
    Go To Settings -> Presentation. Click on the tab u201ESettings for You‟-> Click on button u201ESelect Profile‟.
    Select the radio button corresponding to u201Elayout Set‟, and choose u201EConsumerExplorer‟ from the dropdown.
    Click u201EOK‟.
    Select both the check boxes corresponding to Items Affected as shown above, and click u201ESave‟
    Now, remove the u201ESuper Administrator‟ role from the user km_admin and login with this user.
    How rto resolve this????
    Regards,
    Prasad.

    Hello Prasad,
    Most likely the user km_admin still has system principal roles assigned, even though you removed the Super Admin role, you should check that this user doesn't have any other admin roles, otherwise it will be considered a System Principal user and will therefore still have access to all content. For more information see http://help.sap.com/saphelp_nw70/helpdata/en/19/56f28fbd4e11d5993b00508b6b8b11/frameset.htm
    Try creating a new user with just read access to the content and you should see that it will not be able to make any changes etc.
    Regards,
    Lorcan.

  • HT4314 I have a iPad and iPhone with the same Apple ID, but on Game Center I have used the same id for both devices and they are two different profiles and I was wondering how to have one of the accounts on both devices.

    I have a iPad and iPhone with the same Apple ID, but on Game Center I have used the same id for both devices and they are two different profiles and I was wondering how to have one of the accounts on both devices.

    Hi Jamesdwills,
    Welcome to the Support Communities!
    If you are using the same Apple ID on both devices, the Game Center profile should be the same.
    Check out this information from the iPad User Guide.  Try signing out of the Game Center on both devices and then sign back in with the correct Apple ID:
    Using Game Center
    http://support.apple.com/kb/ht4314
    Game Center settings - iPad User Guide
    http://help.apple.com/ipad/7/#/iPad9a13d039
    Game Center settings
    Go to Settings > Game Center, where you can:
    Sign out (tap your Apple ID)
    Allow invites
    Let nearby players find you
    Edit your Game Center profile (tap your nickname)
    Get friend recommendations from Contacts or Facebook
    Specify which notifications you want for Game Center. Go to Settings > Notifications > Game Center. If Game Center doesn’t appear, turn on Notifications.
    Change restrictions for Game Center. Go to Settings > General > Restrictions.
    Cheers,
    - Judy

  • My Itouch 3rd gen can't be recognize by my computer but when I put my iphone4 its can be recognize I use the same cable for both of them.

    My Itouch 3rd gen can't be recognize by my computer but when I put my iphone4 its can be recognize I use the same cable for both of them.

    Does it charge?
    - Reset the iOS device. Nothing will be lost      
    Reset iOS device: Hold down the On/Off button and the Home button at the same time for at
    least ten seconds, until the Apple logo appears.
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store.
      Apple Retail Store - Genius Bar

  • Why is my user id/pw not accepted by ICloud on my iPad but it is accepted by iCloud on my computer?  I am using the same password for both.

    Why is my user id/pw not accepted by ICloud on my iPad but it is accepted by iCloud on my computer?  I am using the same password for both.

    Rebooting your iDevice
    Hold down the Sleep (On-Off) and Home buttons together for about 10-15 seconds or until the Apple Logo appears - ignore the red slider if it appears - then let go of the buttons. The device should begin to start up.
    Now try entering the information again. See if it works now.

  • I am using the same account for both my Apple TVs but not able to open the movie I purchased on both tvs?

    I have two Apple TV's one in my living room and one in our bedroom. I purchased a movie series on the tv in the living room but was not able to open on the tv in the bedroom. I am using the same account for both Apple TV's. Can anyone assist?

    Wecome to the Apple Community.
    For the avoidance of doubt, are you able to play the TV show on the Apple TV on which you bought it and it is a TV show and not a movie is it.
    What do you mean can't open it, what exactly happens.

  • When I down load books, can I read them on my iPad and iPhone? I went to open a book on my phone but I got a message that aid something about the bill already associated with an appleid. I use the same id for both devices.

    When I down load books, can I read them on my iPad and iPhone? I went to open a book on my phone but I got a message that aid something about the bill already associated with an appleid. I use the same id for both devices.

    All I can suggest is that you open that file on the MBA and save it as a new file, then see if you can open the new one on the iMac.

  • MDT Console with more then 15 machines, How to use the same drivers for more machines.

    Hello,
    I'm am looking for a solution to make our MDT design as effective as possible(as small as posible).
    The Situation:
    The company has more then 15 different computers added to the MDT console for the automated installation of Windows 7. The installations are done in 2 different ways, 1 with a local USB key installation (with the deployment folder on the USB key) and the other
    installation is a network USB key installation (with the deployment folder on the server).
    The local USB key exists for offices in parts of the world where the internet connection is poor.
    The problem:
    We have machines which can use the same driver for different kinds of hardware functions (LAN, WLAN, etc..)
    If we add a new machine to the MDT and we don't check the box for "Import drivers even if they are duplicates of an existing driver" we will automatic use the driver which already exists in the deployment folder. If say half a year
    later we stop using an older machine which "may" have drivers that are being used for other machines and we delete the machine from MDT we should
    NOT check the box "Completely delete these items, even if there are copies in other folders". The problem is that this can also lead to a lot of unused drivers in the deployment folder also because we do not know exactly how many
    computers are using a certain driver.
    At the moment we have another deployment share with for each machine its own drivers installed (so some drivers will be multiple times in the deployment folder) as you can guess this becomes really big.(deployment folder of more then 24 GB). The advantage
    of this is that we can delete a machine from the MDT list without having to worry if the drivers for that machine might be used by other machines. It is now just becoming to big in size(GB).
    The Question:
    Is there not an option within MDT that checks automatically if the drivers connected to a certain machine in MDT are being used by other machines? In this case we would check the box "Completely delete these items, even if there are copies in other folders"
    and MDT would not delete the drivers which are still used for the installations of other computers.
    Thanks in advance.
    Greets,
    Arie

    Arie,
    I think you are over-complicating this. Basically using drivers that already exist is the way to go. Otherwise drivers will be imported a second, third or fourth time. Which also takes up allot of disk space. If you're concerned about driver management,
    then I would suggest to drop your concerns, since there is nothing to less you can do about this particular issue. As long as you don't delete the driver that's been imported earlier by another machine there is nothing to worry.
    Ask yourself:
    - how long am I going to support model x
    - how many times do I want to update drivers
    With selection profiles you can easily target which content needs to go where (on your USB drive of-course)
    I can imagine that managing 25 shares for 25 different models, just because you 'refuse' to have old drivers in your share, or have removed support for some hardware models, isn't really time and energy efficient too.
    If you take a look in your deploymentshare\control folders you will see some XML files. These XML files hold all the entries in your deploymentshare. So your drivers.xml and drivergroups.xml (depending on the number of groups you have) are going to be very
    big XML files. These XML files are read by MDT to identify the objects in MDT and under which folder the objects are located.
    It's not possible to create or have an dependency between driver files and hardware models, other then creating groups under "Out-of-box Drivers" and using selection profiles.
    Another suggestion would be to decrease your number of hardware models drastically. On the other hand, having 25 Gb of offline media isn't really a big deal either. Portable and removable media of those sizes (32 and 64 Gb) isn't that expensive as it used
    to be 5 years ago.
    Don't get me wrong, I perfectly understand your desire to manage this, but MDT doesn't provide any other way, then the things I have pointed out to you here.
    Good luck! :)
    If this post is helpful please click "Mark for answer", thanks! Kind regards

  • How do use the same crop for multiple images.

    I have a number of images that I want to use the same crop on. Instead of go through the whole slow process for each image is there a way to use the same crop for all of the images?
    And in iPhoto there was a way to copy the adjustment settings to multiple images, I can't see how to do that in aperture.

    Use the "Lift&Stamp" tool:
    Crop one image.
    Lift the crop using the "Lift" tool.
    Select the other images.
    Stamp the crop adjustment to all of them.
    But caution: By default "Lift" will copy all Metadata tags and all adjustments, but the gps data. If you only want to transfer the cropping rectangle, deselect all lifted items but the crop adjustment before stamping.
    Regards
    Léonie

  • My iPod won't charge on a wall charger, only on the computer. I used the same cord for both though. I used to be able to charge it with a wall charger, but now suddenly I can't. I've even used other wall pieces. Nothing seems to work.

    My iPod will no longer charge with a wall charger, only the computer. I know it's not becuase of the wall piece or my cord, since I also use the same cord for computer charging, and the wall piece seems to work with others devices. It worked a couple of weeks ago, then suddenly quit. I think it may be something to do with the inside of my iPod where the charger goes. I find it really inconvient to always have to use the computer to charge my iPod. I believe I have a three year warrenty on my iPod, but I wouldn't think it would cover this problem. Is there anything I can do to fix it?

    Not Charge
    - See:    
    iPod touch: Hardware troubleshooting
    iPhone and iPod touch: Charging the battery
    - Try another cable.
    - Try another charging source
    - Inspect the dock connector on the iPod for bent or missing contacts, foreign material, corroded contacts, broken, missing or cracked plastic.
    - Make an appointment at the Genius Bar of an Apple store. Bring the wall charger
      Apple Retail Store - Genius Bar
    If you have a three-year warrany it is not from Apple. The standare Apple warrantyis 1 year and y can purchas an extended warranty that give y a total of two years. You can check your Apple warranty coverage hee:
    Check Your Service and Support Coverage

  • Using the same client for both regfree and out-of-proc COM

    Hi,
    Here is the context:
    1. We have the same set of COM objects that can be deployed as in-proc COM servers (dlls) or out-of-proc COM servers (exe).  In-proc servers are called through regfree COM.
    2. We have test projects that use the in-proc COM servers through regfree COM.
    I would like to use the same test client projects for both regfree and out-of-proc COM servers (but not at the same time). For example, I would like to first run the client using regfree COM, then delete the in-proc dll and register the out-of-proc com server,
    and then run the client again without having to recompile.  But I have not found a way to do this.
    Instead, what I have to do is modify the project settings of the test client project, removing the regfree stuff (the manifest dependencies) before I can use the test client project with the out-of-proc server.
    Is there a way to do this without recompiling?
    FYI, I have tried regfree COM by changing the client project's Project->Properties->Linker->Manifest file->Additional Manifest Dependencies, or by changing the client project's Project->Properties->Manifest Tool->Input and Output->Additional
    Manifest Files.  Either way works with regfree COM.  And either way I have to remove those settings before making it work with out-of-proc COM (and hence recompiling, which is what I am trying to avoid).
    Thanks,
    Nick

    Try Manifest Tool > Input and Output > Embed Manifest = No, and change Linker > Manifest File > Manifest File to drop ".intermediate" in the middle (or just rename the file after the build).
    A manifest doesn't have to be embedded into the executable, it could be a standalone file named like ApplicationName.exe.manifest and sitting in the same directory next to the .EXE. Then you can simply delete or rename it back and forth to switch between
    registered and reg-free COM.
    Igor Tandetnik

  • How do I use the same Itunes for both my IPOD and IPAD?

    How do i use itunes for both my ipod and ipad? and have everything on both of them.

    You can connect one of them to your computer's iTunes, select it on the left-hand side of iTunes, and then on the right-hand side select the Music tab and choose what to sync to that device - you can then connect, select and sync the same content to your other device.

  • How to use the same script for multiple buttons

    Hi,
    I've only just started using flash so any help would be great!
    I'm creating a blockbusters type game, I have a grid of 20 buttons and I need  them (individually) to turn blue on click and red on double click. I've managed to do it with the first one using this code;
    var clicked:Boolean = false;
    bn1.addEventListener(MouseEvent.CLICK, bn1click);
    function bn1click(event:MouseEvent):void {
        clicked = true;
        var newColorTransform:ColorTransform = bn1.transform.colorTransform;
        if(clicked){
        newColorTransform.color = 0x064258;
        bn1.transform.colorTransform = newColorTransform;
    bn1.doubleClickEnabled = true;
    var doubleclicked:Boolean = false;
    bn1.addEventListener(MouseEvent.DOUBLE_CLICK, bn1dclick);
    function bn1dclick(event:MouseEvent):void {
        doubleclicked = true;
        var newColorTransform:ColorTransform = bn1.transform.colorTransform;
        if(clicked){
        newColorTransform.color = 0xac1e23;
        bn1.transform.colorTransform = newColorTransform;
    Now I'm having trouble getting the same to work for the rest of the buttons, they are each named bn2, bn3 etc. They need to work individually and remain blue/red once clicked. I've tried listing them as addEventListener commands but not having a great deal of success!
    Any help would be greatly appreciated, thanks!
    Tomo

    One way to do this is to use arrays to keep track of the buttons and their properties.
    var buttonList:Array = new Array(bn1,bn2,bn3);
    var clickedList:Array = new Array();
    var doubleClickedList:Array = new Array();
    //then use a for loop to assign the functions and properties for each button:
    var thisMany:int = buttonList.length; // this will give you the number of items in the buttonList array
    for(var i:int = 0; i<thisMany; i++) {
         buttonList[i].addEventListener(MouseEvent.CLICK,btnClick); // assign the click function to each button
         buttonList[i].addEventListener(MouseEvent.DOUBLE_CLICK,btnDClick); // assign the double click function
         clickedList.push(false);  // add a false value for each button to this array
         doubleClickedList.push(false);
               buttonList[i].doubleClickEnabled = true; // set the double click property for each button
    function btnClick(event:MouseEvent):void {
              var thisButton:int = buttonList.indexOf(event.target);  // figure out which button was clicked as an item in the array
              clickedList[thisButton] = true;  // change the value in the array
               var newColorTransform:ColorTransform = buttonList[thisButton].transform.colorTransform;
        if(clickedList[thisButton]){
        newColorTransform.color = 0x064258;
        buttonList[thisButton].transform.colorTransform = newColorTransform;
    function btnDClick(event:MouseEvent):void {
              var thisButton:int = buttonList.indexOf(event.target);
              doubleClickedList[thisButton] = true;
        var newColorTransform:ColorTransform = buttonList[thisButton].transform.colorTransform;
        if(doubleClickedList[thisButton]){
        newColorTransform.color = 0xac1e23;
        buttonList[thisButton].transform.colorTransform = newColorTransform;
    Now you can have any number of buttons, just add their instance names to the array at the top.

  • HT204053 I have an Apple ID set up for my daughters I POD / I just purchased an I pod fro myself can I use the same ID for both

    I hava an Apple ID which I set up for my daughter when she received her I Pod, I now have an I pod and want to set it up to purchase music, How do I add this to My Apple ID when I already have an I pod associated with my e-mail address?

    http://www.youtube.com/watch?v=gmOmd_WFp6o
    This was helpful for getting icloud set up from my pc...but someone said that they had it on their pc and then it disappeared. Fun! Fun! Fun!

  • How do I use the same profile for two users on the same computer

    I use my laptop both at home and at work. And in each venue I use a different user log on. But I wish to have firefox use the same profile for each user log on. How can I get firefox to point to the same profile for each user?

    Note that only one user (Firefox instance) can use a profile folder at the time, so if you would switch the Windows user to another account then you would first have to close Firefox.
    * http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    * http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    * http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox
    * http://kb.mozillazine.org/Bypassing_the_Profile_Manager

Maybe you are looking for

  • What's the simplest way to export a single frame from an animated gif as gif?

    i have an animated gif and wish to save a single frame as a non-animated gif. in the past i've been achieving this by deleting all the frames i don't wish to export and deleting them before exerting, this seems very clumsy though so i figure there's

  • Display artist and title of japanese and chinese songs in itunes?

    hi, does anyone know how i can display the artist and title of japanese and chinese songs in itunes? thanks. it used to work on my old computer on old itunes but when i moved it to my new computer, also dell, it comes up with some gibberish squares.

  • BI Contents of Standard LIS Datasources are not unique in diff R/3 systems

    Hi All, We have two R/3 Systems with the config's and SP's as Version - 4.7 SP 27 ---> fields not found Version - 4.7 SP 28 - > fields found When we go into LBWE of first one, i have only 22 fields but whn i go to second system data fields are 66. Da

  • Alternatives for one-way pager?

    Hi, This is not a question about a programming problem, but more about directions to search for. Hope you don't mind. At my company we use pagers to get informed about states of systems we monitor.Sending a pager message costs money. I am asked to lo

  • Runtime Error When Using Recovery CDs

    Hi. I had a HDD failure on this notebook. I got a SSD to replace it with (on my own) and got the recovery DVDs from HP. After 3 hours of trying to install the recovery DVDs to the SSD only to have it fail in the last seconds because it couldn't write