10 Replies Latest reply on May 23, 2010 6:53 PM by SpaghettiCoder

    Idea for project - need initial guidance

    willise414

      Hi all,

       

      I have a project idea in mind that I would like to try and create, but need a little help in the initial stages.

       

      Here is the situation:

       

      I am in a business where staff rotate on shift work at various times of the day. During a day shift, there are 12 employees on shift and 8 positions to staff. Obviously, the staff rotate in and out of these 8 positions. Right now, we use pen and paper to track how long each employee has been working a position, out on break, etc.

       

      I was thinking of a flex (or possible flash) application where I could create a placeholder for each of the 8 positions. I could input the staff for the day (with their start and end times) on an adhoc basis each morning. I would also have a placeholder for "Employees on Break" for example.

       

      What I envision, is being able to take an employee's icon and drag it into a placeholder for a work position. This would activate a clock timer that would display how long the employee has been sitting in the work position. When it is time for a break, I could drag another employee into the position and drag the original employee to teh "On Break" placeholder. This would, of course, start a new timer, indicating the amount of time the employee has been on break.

       

      Are there any helpful tutorials that may give me some insight into creating this? Would it be better to design it in Flash or Flex? I have some ActionScript experience, and while it would be really nice to have all of this information stored on a database, it is certainly not a requirement as my ActionScript knowledge is not to that level just yet. I have no problem with functions, arrays, etc and XML files though. Ad hoc creation of the working employees is the key to simplicity, I think - for now anyway.

       

      Anyway, thanks for any help you can provide!!

        • 1. Re: Idea for project - need initial guidance
          SpaghettiCoder Level 3

          I'd use a database, everytime you shift staff from one state to another, i'd have it insert into the Database

           

          where they came from

          where they are going

          and a timestamp.

           

          1.  You'll have a paper trail just incase you need to double check numbers.

          2.  Seeing how long they spent in any one state could be done with sql calculation or a actionscript one.

          3. If you have a timer and your computer crashes, or you lose power and the computer reboots all the data in your timer would be gone?

          if it was in a database you would simply make a database call and be back up and going again.

          • 2. Re: Idea for project - need initial guidance
            willise414 Level 1

            Thank you for your reply.

             

            I have created the flex application, albeit not in a database yet (but I think you are right in your suggestion and I will do that).

             

            I have enabled the drop and drag functionality and everything seems to work to my satisfaction. I am only missing a couple of small pieces to the puzzle.

             

            Whenever I drop an icon into another datagrid, I want a timer to start counting up, in minutes, denoting how long it has been since the icon was dropped in the datagrid. If I drag it to another datagrid, I want the timer counter to reset to zero and begin to count up again.

             

            How can I accomplish this?

             

            Thanks in advance!!

            • 3. Re: Idea for project - need initial guidance
              willise414 Level 1

              I have created most of what I want to do, I think. I have the drag and drop feature working, and I have a timer working, albeit with a Button click for now. What I would like is to have a timer start with the drop of the initials into the other datagrid. So I am assuming this has to be a mouseup event?

               

              Here is my code:

               

               

               

              <?xml version="1.0" encoding="utf-8"?>

              <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

                 xmlns:s="library://ns.adobe.com/flex/spark"

                 xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="init()">

              <fx:Declarations>

              <!-- Place non-visual elements (e.g., services, value objects) here -->

               

              <mx:DateFormatter id="df" formatString="JJ:NN:SS"/>

              </fx:Declarations>

               

              <fx:Script>

              <![CDATA[

               

              import mx.collections.ArrayCollection;

              import flash.utils.Timer;

              import flash.events.TimerEvent;

              import flash.events.MouseEvent;

              private const TIMER_INTERVAL:int = 0;

               

              private var baseTimer:int;

               

              private var t:Timer;

               

              private function init():void

              {

              t = new Timer(TIMER_INTERVAL);

              t.addEventListener(TimerEvent.TIMER, updateTimer);

              }

               

              private function updateTimer(evt:TimerEvent):void

              {

              var ms:Number=getTimer() - baseTimer;

              var d:Date = new Date(0,0,0,0,0,0,ms);              

              counter.text =df.format(d)

              counter0.text =df.format(d);

              }

               

              private function startTimer():void

              {

              baseTimer = getTimer();

              t.start();

              }

               

              private function stopTimer():void

              {

              t.stop();

              }

               

              [Bindable]

               

              private var controllers:ArrayCollection = new ArrayCollection

              ([

              {controller:"XT"},

              {controller:"TU"},

              {controller:"LN"},

              {controller:"GR"},

              {controller:"AP"},

              {controller:"CU"},

              {controller:"MV"},

              {controller:"GL"},

              {controller:"MW"}]);

               

               

               

              ]]>

              </fx:Script>

               

               

               

               

              <mx:DataGrid dataProvider="{controllers}" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"

              allowMultipleSelection="true" x="10" y="76" width="173" textAlign="center">

              <mx:columns>

              <mx:DataGridColumn headerText="Controllers" dataField="controller" fontWeight="bold"/>

               

              </mx:columns>

               

               

              </mx:DataGrid>

              <mx:DataGrid  dragEnabled="true" dropEnabled="true" dragMoveEnabled="true"

              x="269" y="76" width="173" fontWeight="bold" textAlign="center" verticalAlign="middle">

              <mx:columns>

              <mx:DataGridColumn headerText="Available Staff" dataField="controller"/>

               

              </mx:columns>

              </mx:DataGrid>

              <mx:DataGrid dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" x="497" y="76" width="130" fontWeight="bold" textAlign="left" height="88">

              <mx:columns>

              <mx:DataGridColumn headerText="Position 1" dataField="controller"/>

               

               

              </mx:columns>

              </mx:DataGrid>

               

              <mx:DataGrid dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" x="669" y="76" width="127" fontWeight="bold" textAlign="center" height="88">

              <mx:columns>

              <mx:DataGridColumn headerText="Position 2" dataField="controller"/>

               

               

              </mx:columns>

              </mx:DataGrid>

              <s:Label x="575" y="107" id="counter" width="52"/>

              <s:Label x="575" y="129" id="counter0" width="52"/>

              <s:Button x="272" y="239" label="Start" click="startTimer()"/>

               

               

              </s:Application>

               

               

              How can I have the timer in each line of the datagrid start automatically when something is dropped in the grid?
              Thanks
              • 4. Re: Idea for project - need initial guidance
                SpaghettiCoder Level 3

                //Listen for this

                .addEventListener(DragEvent.DRAG_COMPLETE, dragCompleteHandler)

                 

                 

                private function dragCompleteHandler(event:DragEvent):void

                {

                 

                }

                 

                • 5. Re: Idea for project - need initial guidance
                  willise414 Level 1

                  SpaghettiCoder,

                   

                  Thanks for the help.

                   

                  I can't seem to get the eventListener to work, so I must not be doing it right.

                   

                  Where should I be placing the code you posted?

                   

                  Thanks again!

                  • 6. Re: Idea for project - need initial guidance
                    SpaghettiCoder Level 3

                    Add the listener on the datagrid, or the container you will be dropping objects into.

                     

                    Every time you drop something into that container the function would be called.

                    • 7. Re: Idea for project - need initial guidance
                      willise414 Level 1

                      I hate asking again, because I really like to figure things out myself, but I can't see how this is supposed to work. I want to take the timer function, currently activated by the "Start" button, and replace it with a drop in the datagrid.

                       

                      Can you show me, in the code I posted, what I need to do? I have been googling event handlers for a day or so to figure this out, but all the examples deal with listening for a mouse click. I need to fire the startTimer function when the item is dropped on the datagrid.

                       

                      Thanks for your patience!

                      • 8. Re: Idea for project - need initial guidance
                        SpaghettiCoder Level 3

                        each dgrid you plan on dropping things into you'll need to have add

                         

                        dragComplete="dragCompleteHandler(event)"

                         

                        everytime a object gets dropped into that dgrid it'll execute dragCompleteHandler()

                         

                         

                        private function dragCompleteHandler(event:DragEvent):void

                        {

                             //your timer which is currently actived by your start button click, that  code would go in here.

                        }

                        • 9. Re: Idea for project - need initial guidance
                          willise414 Level 1

                          Thanks for the clarification. It works as it is supposed to now.

                           

                          I have a couple of more obstacles to overcome, but I'll try to get them on my own. If I can't, I'll be back.

                           

                          Thank you!

                          • 10. Re: Idea for project - need initial guidance
                            SpaghettiCoder Level 3

                            If the question has been answered you may want to mark the question as being answered...