How to Cycle Through ArrayCollection?

I have two datagrids and would like to move items from on datagrip and populate the other.  Here is a screen shot for a visual.
In the screenshot about I can add names/sex to the datagrid on the left by using the text entry and Add button.  I can select the check boxes for each name ros as well. What I want to do is move the check names in the datagrid on the left to the datagrid on the right.  4 max.  But if I only selected 2 name, two names would be added to the Racer 1 and Racer 2. Racer 3 and Race 4 would be left empty.  If I check new names and submitted them it would go into a new row on the left datagrid.
What I can figure out is how to cycle through the left datagrid and find only the check rows.  Adding them to the right datagrid is easy enough as soon as I figure how to identify what is checked and what is not checked.
Here is the datagrid on the right.
<mx:DataGrid x="10" y="76" height="337" id="roster" editable="false" dataProvider="{rosterArray}">
<mx:columns>
<mx:DataGridColumn headerText="" width="30">
   <mx:itemRenderer>
      <mx:Component>
         <mx:CheckBox />
      </mx:Component>
   </mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="Name" dataField="name" width="200" editable="false" />
<mx:DataGridColumn headerText="Sex" dataField="sex" width="40" editable="false" />
<mx:DataGridColumn headerText="Time" dataField="time" width="45" editable="false" />
</mx:columns>
</mx:DataGrid>
The function to add to my rosterArray (left datagrid) is below.
private function rosterAdd():void
     rosterArray.addItem({name:addName.text,sex:sexGroup.selectedValue.toString()});
     addName.text = ""; // empty the text entry field.
I guess I need to cycle through the datagrid and not the rosterArray since I don't have a place for the check marks in the rosterArray.
Any help idetifying what rows are checked in the left data grid would be much appreciated.
Thanks.

This code is not production-level, but it should answer your question.
If this post answers your question or helps, please mark it as such.
Greg Lafrance - Flex 2 and 3 ACE certified
www.ChikaraDev.com
Flex / AIR Development, Training, and Support Services
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
  <mx:Script>
    <![CDATA[
      import mx.collections.ArrayCollection;
      [Bindable] private var rosterArray:ArrayCollection = new ArrayCollection();
      [Bindable] private var eventArray:ArrayCollection = new ArrayCollection();
      public var num:uint = 0;
      public function processRoster():void{
        eventArray = new ArrayCollection();
        var cnt:uint = 1;
        var race:Object = new Object();
        for each(var obj:Object in rosterArray){
          if(obj.selected){
            switch(cnt++){
              case 1:
                race["col1"] = obj.name;
                break;
              case 2:
                race["col2"] = obj.name;
                break;
              case 3:
                race["col3"] = obj.name;
                break;
              case 4:
                race["col4"] = obj.name;
                continue;
                break;
        eventArray.addItem(race);         
      private function addParticipant():void{
        rosterArray.addItem({selected: false, name: participant.text, sex: gender.selectedValue, time: null});
        participant.text = "";
        male.selected = true;
      private function removeSelected(evt:MouseEvent):void{
    ]]>
  </mx:Script>
  <mx:RadioButtonGroup id="gender"/>
  <mx:Panel layout="horizontal" backgroundColor="0xFFFFFF"
    borderColor="0x663300" title="Events" color="0xFFFFFF"
    horizontalGap="50">
    <mx:VBox horizontalAlign="right" color="0x000000" paddingBottom="10"
      paddingLeft="10" paddingRight="10" paddingTop="10">
      <mx:Label text="Event Roster" fontWeight="bold" fontSize="14"
        width="100%" textAlign="left"/>
      <mx:HBox width="{roster.width}">
        <mx:TextInput id="participant" width="100%"/>
        <mx:RadioButton id="male" label="M" groupName="gender" selected="true"/>
        <mx:RadioButton id="female" label="F" groupName="gender"/>
        <mx:Button label="Add" click="addParticipant()"/>
      </mx:HBox>
      <mx:DataGrid x="10" y="76" height="337" id="roster" editable="false" dataProvider="{rosterArray}">
        <mx:columns>
          <mx:DataGridColumn headerText="" width="30">
            <mx:itemRenderer>
              <mx:Component>
                <mx:Canvas>
                  <mx:CheckBox id="ckbx" selectedField="selected" change="onChange(event);"
                    label="" horizontalCenter="0">
                    <mx:Script>
                      <![CDATA[
                        import mx.controls.Alert;
                        private function onChange(evt:Event):void {
                          if(Boolean(data.selected) == false && outerDocument.num < 4){
                            outerDocument.num++;
                            data.selected = !data.selected;
                            outerDocument.processRoster();
                          }else if(Boolean(data.selected) == true){
                            outerDocument.num--;
                            data.selected = !data.selected;
                            outerDocument.processRoster();
                          }else{                           
                            mx.controls.Alert.show("Maximum of 4 participants can be selected.");
                            ckbx.selected = false;
                      ]]>
                    </mx:Script>
                  </mx:CheckBox>
                </mx:Canvas>
              </mx:Component>
            </mx:itemRenderer>
          </mx:DataGridColumn>
          <mx:DataGridColumn headerText="Name" dataField="name" width="200" editable="false" />
          <mx:DataGridColumn headerText="Sex" dataField="sex" width="40" editable="false" />
          <mx:DataGridColumn headerText="Time" dataField="time" width="45" editable="false" />
        </mx:columns>
      </mx:DataGrid>
      <mx:Button label="Remove Selected" fontSize="14" click="removeSelected(event)"/>
    </mx:VBox> 
    <mx:VBox horizontalAlign="right" color="0x000000" paddingBottom="10"
      paddingLeft="10" paddingRight="10" paddingTop="10">
      <mx:Label text="Races" fontWeight="bold" fontSize="14"
        width="100%" textAlign="left"/>
      <mx:DataGrid x="393" y="43" id="eventRace" dataProvider="{eventArray}" width="337" height="365">
        <mx:columns>
          <mx:DataGridColumn headerText="Racer 1" dataField="col1"/>
          <mx:DataGridColumn headerText="Racer 2" dataField="col2"/>
          <mx:DataGridColumn headerText="Racer 3" dataField="col3"/>
          <mx:DataGridColumn headerText="Racer 4" dataField="col4"/>
        </mx:columns>
      </mx:DataGrid>
      <mx:Button label="Remove Selected" fontSize="14" click="removeSelected(event)"/>
    </mx:VBox>
  </mx:Panel>
</mx:Application>

Similar Messages

  • How to cycle through various (imported) presets

    How to cycle through various (imported) presets/ effects in lightroom without adding them to the previous effect? In other words, I want to just keep trying various presets in developer mode but when I click on different effects, it should reset and apply current effect, instead of adding/ compounding over previous effect.
    What I am doing now is Undoing the effect each time before trying next effect or preset.
    Crysis 3 Hack Cheat 2013
    http://crysis3-cheat-hack.tumblr.com

    I have downloaded very few presets, but in order to make presets useful for me I need to have them pretty specific, so all in all it adds up to a pretty long list when you list all of them. All I wanted was a way to chose what presets gets listed in the import dialog (alternatively sort them in a specific order). Whatever you name your user presets folder they get listed at the end of the list, and conversely the Lightroom default presets gets listed at the top. The way Lightroom behaves with these presets folders is very unintuitive and frustrating, one of many reasons why I have a love/hate relationship with this program, but I'll have to get back to that because I have to run now!
    crysis 3 cheat hack

  • How to cycle through scenes using the up and down buttons??? (Please help, novice!)

    Hi,
    I'm currently trying to teach myself how to use flash CS5 and actionscript 3 and apart from doing small amounts of programing here and there I'm a complete novice.
    I have 36 photographs taken at 10-degree angles, making an object and i have each image in a different scene, with hidden buttons asigned to different parts of the object so that whenever you hover your mouse over them it provides some more information.
    What I want to do is to be able to cycle through these images in the different scenes using the up and down buttons on the keyboard.
    I'm hoping that I'm at least half way there having assigned the 'hot-spots' but I'm just stuck on the final part... please help!!!!
    Many thanks in advance!
    Harry

    If you are talking about the arrow keys on the keyboard you will have to use a Keyboard Event listener and take note of the constant value for resulting KeyCode
    This website seems to have a handle on it:
    http://www.republicofcode.com/tutorials/flash/as3keyboard/
    There is another method that allows you to listen just to the keys you want (up and down):
    http://www.flex888.com/598/using-keycodes-in-actionscript-3.html

  • How to cycle through report items

    If we have a report on a page, is it possible to cycle through all the items on the report by using JavaScript and fetch one of the attributes for all rows (i.e. ID)? I would then pass on these attributes to an external JS control....

    $('#report_edit_table tbody tr :checked').each(function() {
          var EDIT_FIELD_VALUE =  parseFloat($(this).closest('tr').find('.class specified in See Note 1 ').val());
          var TEXT_FIELD_VALUE =  parseFloat($(this).closest('tr').find('.class specified See Note 1').text());
    });This is more JQuery
    The Each function cycles through all rows. The checked specification is because this is being used on a tabular form with a checkbox. I believe you could take that off for a report and cycle through all rows on the page.
    The "#report_edit_table" is a Static ID to assign to the report region. IN my case, I assigned "edit_table" and APex adds the "report_". So, to be sure of the actual ID, use Firefox/Firebug or Chrome Developer tools (much better btw) and examine the html.
    If the field you want the value of is in a editable field such as on a tabular from, use the ".val"
    If the field you want the value of is in a text field such as on a tabular from, use the ".text" - Sounds like this is what you want as I doubt you'd display the ID field in an editable column.
    Note 1 For the class selector ".class specified in See This Note" Go to report attributes, edit the column of the ID field. Go to Column Attributes. Enter: class="id_class" for example, then enter '.id_class' in the JQuery above
    Note that in order to access a text field value, I believe you need to have it as a hidden field or a text field that saves state.
    Lots of ways to skin the cat, but this is one we use. Hope it helps. There are other variations/examples out there on a google search.
    Edited by: Bob37 on Nov 22, 2011 8:34 AM
    Just noticed you don't need the parseFloat if you're only reading text values. Use parseFloat if you're getting a number field and you want to do some numeric function on it.
    Edited by: Bob37 on Nov 22, 2011 2:00 PM

  • How to cycle through floating documents?

    SHIFT+CTRL+TAB to cycle through documents in one direction (most recently open to last opened for example or however it works), and CTRL` to cycle the other way. I don't know if everyone else's shortcuts are the same but nonetheless.
    If all documents are docked, then these shortcuts work. But if one or more documents are floating, while the rest are docked, then when the cycle reaches those floating document(s), then the cycling gets stuck on those ones and stops even if you continue to press the shortcut keys.
    Anyone else see this? Is there a way to get around it? I'm running CS6

    Not on my Mac, but if you think the Shortcut keys are not working properly, let's reset them.
    Edit > Keyboard Shortcuts    Hold down the Alt or Option key and the Cancel button will change to a Reset button, click on that.
    Other things outside Photoshop can cause problems. Bluetooth keyboard, tablet, or even an errant third party plug-in
    Of course, check your keyboard settings.
    Gene

  • How to change keyboard shortcut for cycle through open tabs in PS and AI CC 2014

    I would love to set my own keyboard shortcuts for cycling through open tabs in PS and AI 2014 on OS X. I found out that this can be achieved with ctrl+tab in PS, but I couldn't manage to make any of the suggestions in the forum work for AI. As said, I would like to set a more "standard" shortcut like alt+cmd+arrow-keys for both of the apps. If that shouldn't be possible, does anyone know a shortcut in AI CC 2014?
    Many thanks!
    Amadeus

    Thanks! The shortcut can be set like this in AI, although all key combinations I would want to use are not allowed. Too bad. But anyways, thank you very much for the tip!
    cmd+~ is not an option for me, I guess, since the swiss/german keyboard layout has no dedicated tilde key.
    So, I have a working shortcut in PS (ctrl+tab / of which I still don't know how to change, if possible at all) and thanks to you, I can now set one in AI as well. Unfortunately, I can not set it to be identical as in PS, since the "cmd" key needs to be included in AI's shortcut assignment dialogue, but I guess, this is as good as it gets.

  • How Do I Customize the Key Combination to Cycle Through Windows in Reverse in all Applications?

    How do I customize the key combination to cycle through windows in reverse in all applications?  I want to be able to change the global setting for Command+~ (Cmd+Shft+`) to something more desireable.  I could NOT find a way to do this in Systems Preference -> Keyboard -> Keyboard Shortcuts since there is not a menu selection "Cycle Through Windows in Reverse".  I then went and looked in the plists DBs of Finders resources hoping to find a setting I could override.  I was quite supprised, as well as some of the MAC gurus in the office, that there was not an easier way to override cycling through windows in reverse on a MacBook - the most user friendly and accessibility aware computer on the market:)
    Here is my MAC software info.
    System Version:  Mac OS X 10.6.7 (10J869)
    Kernel Version:  Darwin 10.7.0

    I don't know of any way to have a separate commandkey combo for the reverse cycle function.
    From the Help pages for OS X 10.6.7 ("Using global keyboard shortcuts") -
    NOTE: You can create keyboard shortcuts only for exisiting menu commands.
    Since the 'reverse' cycle command is not an existing menu item, creating a separate key combo for it doesn't seem possible. Apparently the 'reverse' cycle command is a fixed one, internally defined as a mod of the normal cycle command invoked by adding Shift to its key combo.
    There may be a way to achieve what you want via a two-step process: write an AppleScript that will invoke the 'reverse' key-combo set, then link the activation of the AppleScript to a key combo of your choosing. Not sure if this is even possible, though - usually AppleScript activation via keyboard would be set up via an FKey.
    I can understand wanting to share the RSI risk evenly between both hands, or even to unload the left hand if that is desirable. However, apparently a two-key combo can't be done for the reverse cycle function. Is a three-key combo not possible? ...meaning a two-key combo on the right (Command plus something) for normal cycling, adding Shift for reversing?
    One caution about changing keyboard command combos - it's very easy to accidentally set up a conflict with a another existing commandkey set. FWIW, most, if not all, of the mnemonic and easily-reached letters are already used. In this vein, the Keyboard Shortcuts page of the Keyboard prefs pane shows such conflicts via a yellow caution triangle next to the conflictors.

  • When I press play on my iPod the only the thing that happens the songs cycle through the current playlist instead of playing the audio. How do I fix this?

    Ever since this morning I synced my ipod to my computer all that happens is the ipod cycles through the songs in the current selected playlist. No audio or anything. All the songs that are in my song libraries and are synced to my ipod properly. I did not disconnect the cable whiile it was syncing. It has been a long time since I synced it. Why is my ipod doing this? This ipod is the current ipod classic with 160 GB. Please help

    Thank you, when I meant by I haven't synced with my library in a long time. I meant the day before this morning. So I already synced it and I am not hearing any audio when I press play. Right now I am in front of a mac at my job and I have synced and ejected it from a different computer and it still isn't working. Does this have anything to do with the fact that it might have something to do with my music library at my home computer?

  • How do I change the keyboard shortcut for Cycle through open documents in PS CC for Mac?

    Sorry to bug the community with such a seemingly inconsequential task, but I am seriously tired of using the awkward default keyboard shortcut for cycling through open docs in PS.  I'd like to change it to what I am used in in Chrome, which is Cmd+Option+[left] or {right} arrow keys.  I noticed this is not a command listed in the in keyboard shortcuts, for whatever reason.  Where on Earth can I change this? 
    If it is not possible to do it by default, is there a plug-in or a change to the code that will allow this basic functionality? 
    Thanks again guys and gals!

    As far as I know, you can't. It's "hard wired" in.  Not even Edit > Keyboard Shortcuts is allowed  to change it.
    However I did find this tip:
    Anyway i never found tabs in Adobe application useful, instead i prefer the old school method: simply switch off tabs feature via illustrator/ preferences/ user interface/ open documents as tabs. Then in Mac preferences panel, under keyboard, just search for the “focus on next application window” field (under menu, keyboard and text) and assign a shortcut if the default option doesn't fit you. And there is now you can easily switch between open documents!.
    The best part of this is that it can be used in all mac applications, not only Adobe ones. And remember, if you want this working on Indesign, Photoshop, etc be aware of first switch off the tab features so that the system could “see” multiple documents opened not only one single tabbed document.
    Gene

  • How to create a small field that cycles through a series of images. (using Acrobat Pro)

    Using Acrobat Pro, we need to use a small field to track student progress.  With successive mouse clicks, the field would cycle through: 
    -- a number (that identifies an element of study),
    -- same number surrounded by a circle (indicates element is assigned to the student),
    -- same number with a check mark (indicates element was completed by the student),
    -- back to the original number.
    This could probably be handled by cycling through a series of small images when the user clicks on the field.   
    The "Check Box" field allows only a check to be added to the field.  It does not allow the circle and does not cycle through multiple states. 
    The "Text Box" field might allow this capability, but if so we are not able to configure it properly.  
    Any solutions?   Thanks!

    Thanks Michael,
    The information at the link you provided enabled us to create a button that cycles through a series of ASCII characters. 
    This us useful, but we need to cycle through a series of images.  A more difficult problem. 
    FYI, an example of the javascript that cycles through a series of ASCII characters is shown below.  (The "else" statement pertaining to a null "" buttonGetCaption state is used to initiate an initial state of "1" for the button when the form is first opened.). 
    if
    (event.target.buttonGetCaption()=="1"+"\u2714") {
        event.target.buttonSetCaption("1");
        event.target.textColor = color.black; }
    else if (event.target.buttonGetCaption()=="") {
        event.target.buttonSetCaption("1");
        event.target.textColor = color.black; }
    else if (event.target.buttonGetCaption()=="1P") {
        event.target.buttonSetCaption("1"+"\u2714");
        event.target.textColor = color.green; }
    else if (event.target.buttonGetCaption()=="1") {
        event.target.buttonSetCaption("1P");
        event.target.textColor = color.red; }
    loop
    Again, we are still looking for a way to cycle through a series of images so any help with that problem would be appreciated. 

  • How to make screens cycle through like a slide show.

    I need to have about ten screens (with hypertrends and whatnot) cycle through like a slide show. 
    I figured i'd use a pulse timer...aaaaand some if then statements...Hmmm......Help me out!!!
    Old Fart once said "You can't polish a turd."
    Thnx dad...

    I got it...
    Made a FlipFlop with a F1 key input
    Made a PulseTimer with the FlipFlop for on/off, Time period of 0, and duration of 0:10
    Made a counter with the PulseTimer as count and for reset i did counter=11 (for ten screens)
    Made expresions that read counter=1 ~ counter=10 for each screen
    Conected each screens Maximize to an expression.

  • Issues with AUTO cycling through ....

    I'm trying to do this:
    Any help with one or the other is very much appriciated !!!
    1) When the Timer is finish auto cycling through the tabs (1 to 16) of the ViewStack, and switching over to tab (1) to STOP, I would like to address a function to do something ???
    The question is now how to write the code to ID that the Timer has come to a STOP on tab (1), and how can I incoperate this into the existing (onTimerOne) function.
    2) The second item I'm after is that if I'm amnualy select any tab (1 to 16) to address also a function to do something ???
    3) The third item I'm after is to automaticly zero (0) the ViewStack to tab number (1) if I click a Btn.
    <mx:Script>
    <![CDATA[
        import flash.events.TimerEvent;
        import flash.utils.Timer;
        private var timerOne:Timer;
        private function initOne():void {
            timerOne = new Timer(5000, myViewStack.numChildren);
            timerOne.addEventListener(TimerEvent.TIMER, onTimerOne);
        private function onTimerOne(evt:TimerEvent):void {
            if(myViewStack.selectedIndex == myViewStack.numChildren-1) {
            myViewStack.selectedIndex = 0;
            return;
            myViewStack.selectedIndex++;
        private function autoOne():void {
            if (!timerOne.running) {
            timerOne.start();
        private function manualOne():void {
            if (timerOne.running) {
            timerOne.stop();
    ]]>
    </mx:Script>
    4) Well, the fourth item I'm trying to work out is as I'm reading my data from an Xml file to have a TextArea which shows the different countries from the Xml file for each ViewStack tab while auto cycling through these tabs (1 to 16).
    The diffuculty here is that I use this Xml with a specific urlID="1" to urlId="16" as part shown below.
    <urlsOceania>
        <urlOceania urlID="1"/>
        <searchCountry>American Samoa</searchCountry>
        <etc></etc>
    </urlsOceania>
    I'm reading all the other items this way:
    source="{urlsOceania.urlOceania.(@urID==1).etc}"
    Thanks in advance aktell2007

    Thanks for the confirmation.  7 miles away is most likely using the same VZW tower but it does confirm the problem is not in your current location for us.
    You can look up local tower locations from many public websites such as the following:
    www.antennasearch.com
    www.cellreception.com
    http://www.evdoinfo.com/content/view/2990/63/
    The signal of -65 shows you have strong reception but it doesnt show the entire picture.  Your tower could be overloaded or unauthenticating you.  There are lots of little issues that exist outside of the raw signal strength between the towers and the connecting devices that we users have no control over.  As you may guess only a tower tech has access to identify and correct these things.
    Based on the picture of the back of the MBR1515/Netgear N300 router from Netgear I would assume that only a normal sized SIM card will fit.  I would not assume a micro SIM card will fit.  Since I do not have access to either of the VZW or non-VZW 4G LTE router I cannot confirm if it will work or not.  You might have to give Netgear a call and ask.  Based on what I can see from the User Guides of both devices the SIMs used for each should be compatible with eachother.
    If you decide to purchase the non vzw version please post back your findings for us.

  • Programmat​ically Cycle through Boolean Array

    I'm using an Agilent 34970 with a 34901A switch module. It has 16 switches going to two commons. The end function is to switch through all the sources to read resistance and voltage.
    The driver and sample vi from the NI idnet were used as a base for my vi.
    The sample vi uses a user-controlled 2-d boolean array (false = open). I want to be able to programmatically cycle through all the switches, but I don't know how to tell the dimensions of array I have.
    I would like to go through every element of the 2nd raw for each element in the 1st row. If I could programmatically ignore elements #9, 10, 19, and 20, that would be helpful too.
    Thanks for any help!
    Attachments:
    Agilent 34970 Advanced Scan-2U test-1.vi ‏31 KB
    Agilent 34970 Switch-2U test.vi ‏23 KB

    CelerityEDS wrote:
    Is there a way to determine what's in the vi front panel right now? I cannot determine if it's 2x10 or 10x2... There are no properties of the 2-d array that plainly tell me.
    There is "array size" which tells you the actual size of the 2D array.
    There are properties that tell you how many rows and columns are visible in the front panel array container.
    There are also properties that tell which element is currently scrolled to the top left corner.
    The size and index position of the front panel array control or indicator is not related to the actual array size. You can show only 2x2 elements of a 1000x1000 array or vice versa. if the container is too big, the extra elements are greyed. 
    LabVIEW Champion . Do more with less code and in less time .

  • Having images cycle through colors

    Hey guys im currently creating a puyo puyo game and i was wondering for instance say when my puyos touch the bottom boundary and the next two puyo images load how would i have them be different colors? Or if every time i load my J Frame the images are random colors. I want to make the colors that puyos can be limited to red,green,blue, and yellow and cycle through the colors randomly creating different color combination's based on the specified amount of colors. Hope this makes sense here is what i have so far within my animation class i appreciate any help.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*; 
    import javax.swing.event.*;
    import java.util.Random;
    public class PuyoAnimation extends JPanel {
      public static final int numDroppingPuyos=2;
        /**ball color enumerate: Red*/
        public static final int puyoRed=1;
        /**ball color enumerate: Green*/
        public static final int puyoGreen=2;
        /**ball color enumerate: Blue*/
        public static final int puyoBlue=3;
        /**ball color enumerate: Yellow*/
        public static final int puyoYellow=4;
      final int board_height = 6;
      final int board_width = 12;
      final int rightBoundary = 30;
      final int leftBoundary = 130;
      final int image_height= 32;
      final int image_width = 32;
      final int MAX_X = board_height*image_height;
      final int MAX_Y = board_width*image_height;
      private static final int DELTA_Y = 2;
      private static final int TIMER_DELAY = 20;
      Image images[];
      Timer pptimer;
      Random rand;
      boolean keyRight,keyLeft,keyUp;
      int X;
      int X2 = 30;
      int y;
         public PuyoAnimation() {
         super();
         images = new Image[4];
         images[0] = Toolkit.getDefaultToolkit().getImage("puyo_yellow.png");
         images[1] = Toolkit.getDefaultToolkit().getImage("puyo_blue.png");
         images[2] = Toolkit.getDefaultToolkit().getImage("puyo_green.png");
         images[3] = Toolkit.getDefaultToolkit().getImage("puyo_red.png");
         setFocusable(true);
         PuyoMove puyo_move = new PuyoMove(); // Make a new video game KeyListener
         addKeyListener(puyo_move);
         setBackground(Color.BLACK);
          rand = new Random();
          pptimer = new Timer(TIMER_DELAY, new TimerAction());
          pptimer.start();
         public void setAnimation(boolean OnandOff){
            if (OnandOff) {
                pptimer.start(); 
            } else {
                pptimer.stop(); 
         private int color2ImageIndex(int color){
          return color-1;
        public void puyoBoundsRight(){
        if ((X > rightBoundary) || (X2 > rightBoundary)){
        X -= 5;
        X2 -= 5;
        public void puyoBoundsLeft(){
        if ((X < leftBoundary) || (X2 < leftBoundary)){
        X += 5;
        X2 += 5;
       private class PuyoMove implements KeyListener {
         public void keyTyped(KeyEvent k){}
          public void keyPressed(KeyEvent k){
            switch (k.getKeyCode()){
              case KeyEvent.VK_LEFT:
                   keyLeft = true;
                   break;
              case KeyEvent.VK_RIGHT:
                   keyRight = true;
                   break;
         public void  keyReleased(KeyEvent k) {
            switch (k.getKeyCode()){
            case KeyEvent.VK_LEFT:
                 keyLeft = false;
                 break;
            case KeyEvent.VK_RIGHT:
                 keyRight = false;
                 break;
            public void paintComponent(Graphics g){
             super.paintComponent(g); 
            g.drawImage(images[0],X,y,this);
            g.drawImage(images[1],X2,y,this);
            class TimerAction implements ActionListener {
            public void actionPerformed(ActionEvent e) {
             Color c = new Color(rand.nextInt(4) + 1);
               if (keyLeft){
                puyoBoundsRight();
               else if (keyRight) { 
                puyoBoundsLeft();
                y += DELTA_Y;
            if (y + image_width  >= MAX_Y){
           setAnimation(false);
                repaint();
       }

    Hey morgalr sorry to bother you again i tried what you suggested and after compiling i received an error stating that there was an IOException i fixed that but im unsure to on where to go from here it works fine now but i cant get the images to change colors, here is my code so far thanks again
       BufferedImage[] bi = new BufferedImage[4];
                try {
             bi[0] =  ImageIO.read(new File("puyo_yellow.png"));
            bi[1] =  ImageIO.read(new File("puyo_blue.png"));
             bi[2] =  ImageIO.read(new File("puyo_green.png"));
             bi[3] =  ImageIO.read(new File("puyo_red.png"));
             catch ( IOException e )
            // BufferedImage myBI = bi[myRand.nextInt(4)];
           }Edited by: Riz01 on Oct 3, 2009 10:07 AM

  • Cycle through list and build compound array...

    I have a database that I'm pulling data from that is already existing. There is a designs table and a details table. The designs table stores the id's of the details items that are associated with the design. Since I'm using Flash remoting I would like to just get all the designs and their details back in one compound array instead of making a bunch of calls. I'm stuck on how to make the string "5,8,12,19" into an array, cycle through the array and then get the details info for each id. Then return the compound array when finished.
    I would prefer the array be like this:
    [design item 1 and it's data][details array of the design 1 items], [design item 2 and it's data][details array of the design 2 items]....
    Here is what I have so far
    <cffunction name="getDesignsByAct" access="remote" returntype="query" hint="gets activities by id">
    <cfargument name="send_id" type="numeric" required="yes" />
        <cfquery name="getDesignsByActQuery" datasource="#dsn#">
        SELECT design_id, design_items
        FROM designs_table
        WHERE design_activity = #send_id#
        </cfquery>
        <cfquery name="getDetailsQuery" datasource="#dsn#">
    SELECT
        FROM
         details_table
        WHERE <!-- cycle through the list of "design_items" in the above query -->
    </cfquery>
        <cfset this_return[1] = getDesignsByActQuery>
    <cfset this_return[2] = getDetailsQuery>
       <cfreturn this_return >
    </cffunction>
    Thanks in advance.

    Is your end goal to get a multi-dimensional array?  a query recordset object?  or an array of structs?  Based on your description, it looks like you want something like this:
    arrMultiDimArray = NewArray(2)
    arrMultiDimArray[1][1] = Query Data from Design Record 1
    ArrMultiDimArray[1][2] = Array of Detail records data structures (or query recordset object?) associated with design record 1
    If that is the case, then you should be able to put something together like this:
    1) Query your design & details data from the database as a joined recordset
    2) Initialize your multi dimensional array
    3) You can use the <cfoutput group=""> attribute to create an outer loop that only changes once for each new design ID
    4) Increment your first dimension array and add your design data to position one of your 2nd dimension
    5) Create a new array to store your Detail record items
    6) Use a nested <cfoutput> loop to loop over your detail item records and populate your new array
    7) Store your new array in position two of your 2nd dimension
    8) Return your 2D array to your flash remoting app

Maybe you are looking for

  • Twonky for OSX and DMC250

    I have a mac mini acting as a home theatre media sharing hub with smb file sharing enabled. If I read correctly, the DMC250 is unable to access smb shares directly and the cisco media server application is only windows compatible. Is it possible for

  • ITunes can't find files in library

    I moved my iTunes library to an external hard drive following the instructions but after I consolidated I saw that most of the files were not moved so I dragged and dropped the missing files into the library. The problem is that iTunes does not recog

  • Get Selection options from one view to another view

    Hi Experts, I am using two views, first view  it shows basic list of records based on selection options criteria , here I used component WDR_SELECT_OPTIONS . Then if we click on any record in first view then it opens popup window with record relevant

  • JBoss Permissions issue (Quality Center 11 Installation)

    I'm currently trying to install HP Application Lifecycle Management/Quality Center 11 on my Amazon EC2 box running Windows Server 2008.  I am logged into the box as Administrator. I'm trying to install a trial Version of Quality Center Enterprise, us

  • Value of the goods movement is negative: Message no. M7301

    HI,     In subcontracting process while receiving the goods from subcontractor following error is coming " Value of the goods movement is negative:"Message no. M7301. pls tell me why this error is coming and how to solve it thanks & regards vr