Can't understand how this group by clause works

The Schema is as below: (http://www.psoug.org/reference/rollup.html)
CREATE TABLE grp_rep (
person_id NUMBER(3),
division VARCHAR2(3),
commission NUMBER(5));
INSERT INTO grp_rep VALUES (1,'SAM',1000);
INSERT INTO grp_rep VALUES (2,'EUR',1200);
INSERT INTO grp_rep VALUES (1,'EUR',1450);
INSERT INTO grp_rep VALUES (1,'EUR',700);
INSERT INTO grp_rep VALUES (2,'SEA',1000);
INSERT INTO grp_rep VALUES (2,'SEA',2000);
INSERT INTO grp_rep VALUES (1,'EUR',800);
COMMIT;
Query1:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY person_id, ROLLUP (person_id, division);
Query2:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY division, ROLLUP (person_id, division);
The results of query1 are okay. It has results from rollup and group by person_id.
But, in Query2 results of rollup are missing and results of group by division is there.
Anyone can explain how the group by clause works when there are multiple columns involving CUBE, ROLLUP and simple column names?
Regards.

Thank you shoblock!
but, What i m really looking for is,
How group by clause works when i add regular column along with RollUp in group by clause?
I have understood simple group by clause like
...group by column1,column2,column3....
n I also know simple rollup clauses like
...group by rollup(column1,column2,column3,...)
But my Problem is how does this work:
...group by column2,rollup(column1,column2,...)
...group by column1,rollup(column1,column2,...)
See below Results:
Query1:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY person_id,ROLLUP ( person_id, division );
Result:
PERSON_ID DIVISION SUM(COMMISSION)
     1      EUR      2950
     1     SAM      1000
     2      EUR      1200
     2      SEA      3000
     1           3950
     2           4200
     1           3950
     2           4200
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY division,ROLLUP ( person_id, division );
Query2:
SELECT person_id, division, SUM(commission)
FROM grp_rep
GROUP BY division,ROLLUP ( person_id, division );
Result:
PERSON_ID DIVISION SUM(COMMISSION)
1 EUR 2950
2 EUR 1200
     1 SAM      1000
2 SEA 3000
1 EUR 2950
2 EUR 1200
1 SAM 1000
2 SEA 3000
EUR 4150
SAM 1000
SEA 3000
guys, help me make understand above results!
Regards.

Similar Messages

  • I really can't understand how this recursive works??

    Hi all,
    I have got a recursive function that checks for palendrome string. But it is confusing. I know that a string is palenromme if it is empty or has a char or first char and last one are same and middle is palindromme too.
    but can't understand how this function works.
    class Palindromme
         boolean palindrom(String s)
              if (s.length() <= 1 || s.equals(null) || s=="") //this is the stopping point
                   return true;
              else
              {                    //recursive definition
                   return ( s.charAt(0) == s.charAt(s.length()-1) ) && palindrom(s.substring(1,s.length()-1));
    specially i don't know how palindrom(s.substring(1,s.length()-1)); is working cause it has to be increased for each loop.
    abdul
    PS: actually i don't know how recursion works from Data structure point of view

    Hi,
    ok your palindrome is : "otto"
    return ( s.charAt(0) == s.charAt(s.length()-1) ) && palindrom(s.substring(1,s.length()-1));
                  o                     o                                   tt
    so first part is true                                        
    in the second part palindrom is called again but with the remaining tt
    so second time :
    return ( s.charAt(0) == s.charAt(s.length()-1) ) && palindrom(s.substring(1,s.length()-1));
                   t                     t                                 ""
    Third time:
    if (s.length() <= 1 || s.equals(null) || s=="") //this is the stopping point
    return true;after all for otto the recusion is:
    return ( s.charAt(0) == s.charAt(s.length()-1) ) && s.charAt(1) == s.charAt(s.length()-2) ) && nothing left of otto);
    Phil

  • How much does this cost? & I still can't understand how this work

    How much does this cost? & I still can't understand how this work

    Hello mkopti,
    ePrint is a free feature include on most of our wireless printers that are e-all-in-one enabled. It allows you to register your printer on HP's website http://www.eprintcenter.com and create an account. Once an account has been created you can enable the web services feature, after connecting to a valid network with internet access, which will print off a registration code you can use to add the printer to your account and customize an email address for the printer. This allows you to print to the printer from virtually anywhere simply by sending an email to the printers email address and when it is received it will print.
    Most of these printers are also Airprint enabled meaning you can print locally from the same network on the iPad, iPod, and iPhone (version 4.3.2 and higher) by using the built in "Print" command in the idevices.
    If you have any other questions or need clarification feel free to reply to this post and I will try to answer any questions you have.
    If I have solved your issue, please feel free to provide kudos and make sure you mark this thread as solution provided!
    Although I work for HP, my posts and replies are my own opinion and not those of HP.

  • Can't understand how TableCellRenderer is meant to work

    I've not done much Swing work and I'm trying to understand how a customer TableCellRenderer is meant to work. I know I've made a stupid mistake here somewhere but I can't find any specific docs on what I'm try to do.
    Basically I have a column in my JTable which holds my own Counter object. I want to render the cell so that the current value of the counter is displayed, along with 2 little buttons that allow the user to increment/decrement the counter value.
    The code is below, I seem to have 3 problems:
    1) One click on the button seems to increment the counter several times (inserting some log statements it seems that the MouseListener is being added several times?)
    2) The value on the counter doesn't seem to get refreshed/repainted once the button is clicked, only some time later (e.g. when I click on a different cell in the JTable)
    3) The +/- buttons dont "depress" when they are clicked.
    Any help much appreciated!
    public Component getTableCellRendererComponent(
    JTable table, Object lagInput,
    boolean isSelected, boolean hasFocus,
    int row, int column) {
    removeAll();
    final Counter counter = (Counter)counter;
    final JButton increment = new JButton("+");
    increment.setMargin(new Insets(1,1,1,1));
    increment.setPreferredSize(new Dimension(15,15));
    final JButton decrement = new JButton("-");
    decrement.setMargin(new Insets(1,1,1,1));
    decrement.setPreferredSize(new Dimension(15,15));
    final JTable finalTable = table;
    final int finalColumn = column;
    table.addMouseListener(new MouseAdapter(){
    public void mousePressed(MouseEvent e) {
    Rectangle panelBounds = finalTable.getTableHeader().getHeaderRect(finalColumn);
    Rectangle buttonBounds = increment.getBounds();
    buttonBounds.translate(panelBounds.x, panelBounds.y);
    if (buttonBounds.contains(e.getX(), e.getY())){
    counter.increment();
    Rectangle buttonBoundsDec = decrement.getBounds();
    buttonBoundsDec.translate(panelBounds.x, panelBounds.y);
    if (buttonBoundsDec.contains(e.getX(), e.getY())){
    counter.decrement();
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridheight = 2;
    c.gridx = 0;
    c.gridy = 0;
    add(counter);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridheight = 1;
    c.gridx = 0;
    c.gridy = 1;
    add(increment);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridheight = 1;
    c.gridx = 1;
    c.gridy = 1;
    add(decrement);
    return this;
    }

    If that's all there is to the Counter class, it seems to me that what you really want is a JTable of JSpinners.import java.awt.Component;
    import javax.swing.*;
    import javax.swing.table.TableCellEditor;
    import javax.swing.table.TableCellRenderer;
    public class SpinnerTable {
       void makeUI() {
          Integer[][] data = new Integer[10][5];
          String[] colNames = new String[data[0].length];
          for (int i = 0; i < data[0].length; i++) {
             colNames[i] = "Column " + i;
             for (int j = 0; j < data.length; j++) {
                data[j] = 0;
    JTable table = new JTable(data, colNames) {
    @Override
    public Class getColumnClass(int column) {
    return Integer.class;
    table.setDefaultEditor(Integer.class, new TableCellSpinner(table));
    table.setDefaultRenderer(Integer.class, new TableCellSpinner(table));
    table.setRowHeight(new JSpinner().getPreferredSize().height + table.
    getIntercellSpacing().height);
    JScrollPane scrollPane = new JScrollPane(table);
    JFrame frame = new JFrame("SpinnerRendererTable");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(400, 400);
    frame.setLocationRelativeTo(null);
    frame.add(scrollPane);
    frame.setVisible(true);
    public static void main(String[] args) {
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
    new SpinnerTable().makeUI();
    class TableCellSpinner extends AbstractCellEditor
    implements TableCellRenderer, TableCellEditor {
    JTable table;
    JSpinner spinner = new JSpinner();
    JTextField editor = ((JSpinner.DefaultEditor) spinner.getEditor()).
    getTextField();
    TableCellSpinner(JTable table) {
    this.table = table;
    public Component getTableCellRendererComponent(JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column) {
    spinner.setValue((Integer) value);
    if (isSelected) {
    editor.setBackground(table.getSelectionBackground());
    } else {
    editor.setBackground(table.getBackground());
    if (hasFocus) {
    spinner.setBorder(BorderFactory.createLineBorder(table.getGridColor()));
    } else {
    spinner.setBorder(null);
    return spinner;
    public Component getTableCellEditorComponent(JTable table, Object value,
    boolean isSelected, int row, int column) {
    spinner.setValue((Integer) value);
    spinner.setBorder(BorderFactory.createLineBorder(table.getGridColor()));
    return spinner;
    public Object getCellEditorValue() {
    return spinner.getValue();
    }Check that out carefully in case I've missed anything.
    db
    edit Added the code for the isSelected border
    Edited by: Darryl.Burke

  • IVR NAT - can someone explain how this works?

    The CLI config guide, cookbook, and other things I have found do not explain exactly what is getting translated to what with regards to IVR NAT. I setup a simple scenario, and its all working but I am trying to understand how virtual domains and NAT in general is making it all work.
    I setup two switches, MDS1 and MDS2. I put VSAN 10 on MDS1 with a single HOST and VSAN 20 on MDS2 with a single DISK. I made a common transit VSAN between them, VSAN 99 via FCIP. Here is my confused take on what is happening.
    HOST can only communicate with DISK if it were in its own VSAN10, which its not. So a FCID is created in VSAN10 of 0x9a6e9f so it can talk to it. This is using domain 9a, which is a virtual domain, not an actual domain so when traffic is directed to it, the MDS re-writes it to 0x736ef8 which is a virtual domain fcid, then the far side mds notices it can get to that pwwn and maps it back to the real fcid in vsan 20 of 0x0900ef. Is this even close? I just want to understand how the "routing" is really working. I understand there is a topology table built, which in this case it is:
    MDS1 10,99
    MDS2 20,99
    (I am using auto topology). Below I have outputs I captured. I had to type these in by hand as there was no way to cut/paste of of the lab I was using. I appreciate any help on this, sorry for the marathon of posts here lately.
    MDS1
    HOST VSAN10
    MDS2
    DISK VSAN20
    I setup an IVRZoneset so that the HOST and the DISK could see eachother. I am using CFS and IVR NAT as well.
    So it works great, the HOST can see the DISK. But I am trying to find out about the translations, here are the tables:
    P26-MDS-1# show fcns database
    VSAN 10:
    FCID TYPE PWWN (VENDOR) FC4-TYPE:FEATURE
    0x9a6e9f N 22:6e:00:0c:50:17:26:00 (Seagate) scsi-fcp:target
    0xbd0000 N 21:00:00:e0:8b:07:4c:5a (Qlogic) scsi-fcp:init
    Total number of entries = 2
    VSAN 99:
    FCID TYPE PWWN (VENDOR) FC4-TYPE:FEATURE
    0x736ef8 N 22:6e:00:0c:50:17:26:00 (Seagate) scsi-fcp:target
    0xa85c9f N 21:00:00:e0:8b:07:4c:5a (Qlogic) scsi-fcp:init
    Total number of entries = 2
    P26-MDS-1# show flogi data
    INTERFACE VSAN FCID PORT NAME NODE NAME
    fc1/5 10 0xbd0000 21:00:00:e0:8b:07:4c:5a 20:00:00:e0:8b:07:4c:5a
    Total number of flogi = 1.
    P26-MDS-2# show fcns database
    VSAN 20:
    FCID TYPE PWWN (VENDOR) FC4-TYPE:FEATURE
    0x0900ef N 22:6e:00:0c:50:17:26:00 (Seagate) scsi-fcp:target
    0x385c50 N 21:00:00:e0:8b:07:4c:5a (Qlogic) scsi-fcp:init
    VSAN 99:
    FCID TYPE PWWN (VENDOR) FC4-TYPE:FEATURE
    0x736ef8 N 22:6e:00:0c:50:17:26:00 (Seagate) scsi-fcp:target
    0xa85c9f N 21:00:00:e0:8b:07:4c:5a (Qlogic) scsi-fcp:init
    P26-MDS-2# show flogi data
    INTERFACE VSAN FCID PORT NAME NODE NAME
    fc1/6 20 0x0900ef 22:6e:00:0c:50:17:26:00 22:6e:00:0c:50:17:26:00
    Total number of flogi = 1.
    P25-MDS-1# sh ivr virtual-domain
    VSAN # Domains IVR Virtual Domains
    10 1 154
    99 2 115,168

    You found the correct command to view how the FCID is rewritten as the frame is transferred from 1 VSAN to another. The re-writes for data frame headers are done by the line cards at wire rate. Some control frames that contain the FCID in the payload are routed to the supervisor so that the payload can be updated with the new FCIDs as well.
    - Mike

  • Recently updated Numbers to Version 3.5.2 and now also seem to have Numbers Version 2.0 on my launchpad? Can anyone explain how this has happened - how do I get rid of it?

    Recently updated Numbers to Version 3.5.2 and now also seem to have Numbers Version 2.0 on my launchpad? Can anyone explain how this has happened - how do I get rid of it? Not able to move to Trash.

    What is strange however is that my iMac is only a few months old and they all were upgraded to V3.x just a few months ago - with all Apps for iWork removed at that time.
    Unless you did something specific to remove the old versions of the iWork apps (not advisable) then, as Wayne points out, they were not actually removed from your Mac, just moved into that subfolder within your main Applications folder.
    I originally downloaded Numbers 2.x from the App Store (i.e. didn't install from a disk). I still have it on my Mac.  But only Numbers 3.x appears in Launchpad.
    I don't know whether this will help, but in Mac App Store you might try clicking 'Account' under 'Quick Links' on the right, signing in with your password, and clicking the 'Reset' button to the right of 'Reset all warnings for buying and downloading'.  Sometimes the App Store gets a little confused. It's possible Launchpad may be taking its cue from the App Store in showing that old version of Numbers.
    By Launchpad I assume you really mean Launchpad, not the Dock.  I usually use the Dock. If that's what you're using too, then of course you can just drag the icon for the old Numbers off the Dock and it will vanish. (But the Numbers 2.3 application will still be there in that subfolder when you need it.)
    SG

  • HT1665 I am trying to connect my Samsung Bluetooth device with my new Iphone 4S.  Can anyone explain how this is done?

    I am trying to connect my Samsung Bluetooth device to my new Iphone 4s. Can anyone explain how this is don?

    Which Samsung Bluetooth device?
    Please note that the iPhone will not pair with other phones, tablets, etc for purposes of file transfer.

  • I can't understand how to edit titles on the spine of books. Could anyone help me? Thanks.

    I can't understand how to edit titles on the spine of books. Could anyone help me? Thanks.

    the trouble is that on the spine of the book the title is cut off and I don't know how avoid it.
    I don't think you can, Fred. Pick a shorter title. And add the additional information by adding a subtitle on your title page. You can always add a second text box, using the "edit layout" panel.
    Regards
    Léonie

  • Things have really changed.  I can't understand how Apple could release the Lion OS as buggy as it is ?  It's like reliving the nightmare of my PC days and the Microsoft crap !  Do I have to wipe the hardrive before reinstalling Snow Leopard ?  Comments..

    Things have really changed.  I can't understand how Apple could release the Lion OS as buggy as it is ?  It's like reliving the nightmare of my PC days and the Microsoft crap !  Do I have to wipe the hardrive before reinstalling Snow Leopard ?  The amazing thing is that when I installed Snow Leopard not a hitch, ever !    My trust in Apple is gone and believe me I will think twice before doing anymore OS upgrades, **** I can go back to the PC for a lot less money.

    Adios baby! Enjoy that PC!

  • My ipad mini is totally drain and after plug it to regain the power its not working anymore.can somebody knows how to make my ipad work again

    my ipad mini is totally drain and after plug it to regain the power its not working anymore.can somebody knows how to make my ipad work again

    Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • Can anyone explain how this works (vlans and bridge groups)

    Can someone please explain how this works...I have started to have problems but nothing changed. My problems are vlan1 and 1000 getting blocked on the switchport where the root bridge is attached.
    ROOT BRIDGE:
    ssid state
    station-role root bridge
    rts threshold 4000
    concatenation
    interface Dot11Radio0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    no snmp trap link-status
    bridge-group 1
    bridge-group 1 spanning-disabled
    interface Dot11Radio0.911
    encapsulation dot1Q 911
    no ip route-cache
    no snmp trap link-status
    bridge-group 5
    interface Dot11Radio0.1000
    encapsulation dot1Q 1000
    no ip route-cache
    no snmp trap link-status
    bridge-group 2
    bridge-group 2 spanning-disabled
    interface Dot11Radio0.2001
    encapsulation dot1Q 2001
    no ip route-cache
    no snmp trap link-status
    bridge-group 253
    bridge-group 253 spanning-disabled
    interface Dot11Radio0.2120
    encapsulation dot1Q 2120
    no ip route-cache
    no snmp trap link-status
    bridge-group 7
    interface Dot11Radio0.2330
    encapsulation dot1Q 2330
    no ip route-cache
    no snmp trap link-status
    bridge-group 3
    bridge-group 3 spanning-disabled
    interface Dot11Radio0.2336
    encapsulation dot1Q 2336
    no ip route-cache
    no snmp trap link-status
    bridge-group 4
    interface Dot11Radio0.2350
    encapsulation dot1Q 2350
    no ip route-cache
    no snmp trap link-status
    bridge-group 6
    interface Dot11Radio0.2901
    encapsulation dot1Q 2901
    no ip route-cache
    no snmp trap link-status
    bridge-group 255
    bridge-group 255 spanning-disabled
    interface Dot11Radio0.2902
    encapsulation dot1Q 2902
    no ip route-cache
    no snmp trap link-status
    bridge-group 254
    bridge-group 254 spanning-disabled
    interface FastEthernet0
    no ip address
    no ip route-cache
    interface FastEthernet0.1
    encapsulation dot1Q 1
    no ip route-cache
    no snmp trap link-status
    interface FastEthernet0.911
    encapsulation dot1Q 911
    no ip route-cache
    no snmp trap link-status
    bridge-group 5
    interface FastEthernet0.1000
    encapsulation dot1Q 1000 native
    ip address 10.0.32.10 255.255.255.0
    no ip route-cache
    no snmp trap link-status
    bridge-group 1
    interface FastEthernet0.2001
    encapsulation dot1Q 2001
    no ip route-cache
    no snmp trap link-status
    bridge-group 253
    bridge-group 253 spanning-disabled
    interface FastEthernet0.2120
    encapsulation dot1Q 2120
    no ip route-cache
    no snmp trap link-status
    bridge-group 7
    interface FastEthernet0.2330
    encapsulation dot1Q 2330
    no ip route-cache
    no snmp trap link-status
    bridge-group 3
    interface FastEthernet0.2336
    encapsulation dot1Q 2336
    no ip route-cache
    no snmp trap link-status
    bridge-group 4
    interface FastEthernet0.2350
    description 81 River Rd - Labor
    encapsulation dot1Q 2350
    no ip route-cache
    no snmp trap link-status
    bridge-group 6
    interface FastEthernet0.2901
    encapsulation dot1Q 2901
    no ip route-cache
    no snmp trap link-status
    bridge-group 255
    bridge-group 255 spanning-disabled
    interface FastEthernet0.2902
    encapsulation dot1Q 2902
    no ip route-cache
    no snmp trap link-status
    bridge-group 254
    bridge-group 254 spanning-disabled
    interface BVI1
    ip address 10.0.32.10 255.255.255.0
    no ip route-cache
    ip default-gateway 10.0.32.1

    NON-ROOT BRIDGE#2:
    ssid state
    station-role non-root bridge
    rts threshold 4000
    concatenation
    infrastructure-client
    interface Dot11Radio0.1
    encapsulation dot1Q 1 native
    no ip route-cache
    bridge-group 1
    bridge-group 1 spanning-disabled
    interface Dot11Radio0.1000
    encapsulation dot1Q 1000
    no ip route-cache
    bridge-group 254
    bridge-group 254 spanning-disabled
    interface Dot11Radio0.2001
    encapsulation dot1Q 2001
    no ip route-cache
    bridge-group 252
    bridge-group 252 spanning-disabled
    interface Dot11Radio0.2336
    encapsulation dot1Q 2336
    no ip route-cache
    bridge-group 251
    bridge-group 251 spanning-disabled
    interface Dot11Radio0.2901
    encapsulation dot1Q 2901
    no ip route-cache
    bridge-group 253
    bridge-group 253 spanning-disabled
    interface Dot11Radio0.2902
    encapsulation dot1Q 2902
    no ip route-cache
    bridge-group 255
    bridge-group 255 spanning-disabled
    interface FastEthernet0
    no ip address
    no ip route-cache
    hold-queue 80 in
    interface FastEthernet0.1000
    encapsulation dot1Q 1000 native
    no ip route-cache
    bridge-group 1
    interface FastEthernet0.2001
    encapsulation dot1Q 2001
    no ip route-cache
    bridge-group 252
    bridge-group 252 spanning-disabled
    interface FastEthernet0.2336
    encapsulation dot1Q 2336
    no ip route-cache
    bridge-group 251
    bridge-group 251 spanning-disabled
    interface FastEthernet0.2901
    encapsulation dot1Q 2901
    no ip route-cache
    bridge-group 253
    bridge-group 253 spanning-disabled
    interface FastEthernet0.2902
    encapsulation dot1Q 2902
    no ip route-cache
    bridge-group 255
    bridge-group 255 spanning-disabled
    interface BVI1
    ip address 10.0.32.11 255.255.255.0
    no ip route-cache
    ip default-gateway 10.0.32.1

  • Hey i am unfamiliar with how to use icloud for storage. Can some one slowly( lol ) help me to understand how this thing works. I also need someone to help with how to transfer pics from your iphone to your flash drive.

    Hello i am needing some assistance as i am not very good at how the cloud works. I need to delete my account and start over.  I don't want to loose all of the things that i have on phone. Help!

    Slowly
    http://www.apple.com/icloud/features/
    but surely
    http://www.gottabemobile.com/2011/10/18/how-to-sync-email-contacts-and-calendar- with-icloud/
    we will come
    http://transfer-iphone-contacts.blogspot.com/p/iphone-contacts-sync-via-icloud.h tml
    to understanding
    http://support.apple.com/kb/PH12519
    on how icloud sync and backup work.
    http://www.apple.com/support/icloud/backup/
    http://support.apple.com/kb/ht1766
    And here we will find instructions on how to backup (import) pictures to computer, cause there is no direct transfer to flash drive.
    http://support.apple.com/kb/ht4083

  • I need help understanding how this works. AS 2.0

    Its my first time here and i only started learning flash today. I aint too great with maths and i was showed this piece of code that makes a triangles point follow the cursor. It involved mathimatical things ( which i aint so great at) and the guy said "You dont need to know how it works, just how to use it." well i copied his code and it worked, but i have no idea how to use it in other rotation apart from the one he taught us. I dont even understand how to redo his code i saved it to a word document and anytime i wanted to make something rotate something in that fashion i would refer to that. But i dont want to have to do that, i want to know how to use it, dont have to understand it, but use it for other rotation matters. If you are going to help, please try to be a bit simmple i explaining it, cause im new. Dont get me wrong i aint thick but i can find it a bit hard to follow some things, that is i my current problem.
    here is the rotation code:
    onEnterFrame = function()
    hero._rotation = getmouse(hero);
    getmouse = function(mc:MovieClip):Number
    dy = _ymouse-mc._y;
    dx = _xmouse-mc._x;
    rad = Math.atan2(dy,dx);
    rotate = rad*180/Math.PI
    return rotate+90
    also if it helps, here is the video i was watching: http://www.youtube.com/watch?v=w3OfrpbNhHs
    please if you can, explain how the entire thing works.
    thanks for any help given in advance.

    Hi,
    Here's a short primer.  It may not be sufficient but here goes.
    1st, move the closing bracket at the end and put it on the third line.  This makes the code more efficient
    onEnterFrame = function(){                               // this causes Flash to repeatedly
                                                                              execute the next line at the
                                                                              frame rate you selected
                                                                              for your document
           hero._rotation = getmouse(hero);               // this tells Flash to rotate a
                                                                              movie clip (named hero) based
                                                                              on the function getmouse()
    };                                                                     // putting the }; here makes the
                                                                              code more efficient and readable
    getmouse = function(mc:MovieClip):Number{   // This is the function called with
                                                                             mc referring to hero that was
                                                                             passed from the second line.
         dy = _ymouse-mc._y;                                // dy means delta y which subtracts
                                                                            the y position of the movieclip
                                                                            from the mouses y position
         dx = _xmouse-mc._x;                               // dx = delta x (same as above line
                                                                            but on the x axis)
                                                                         // once you have the x and y sides
                                                                            you male a triangle.
                                                                            Now use trig to find the angle
         rad = Math.atan2(dy,dx);                           // the computer works in radians
                                                                            the arc tangent atan2 will give the
                                                                            angle in radians
         rotate = rad*180/Math.PI                            // you want to convert the radians to
                                                                            degrees, that's what this line does
         return rotate+90                                         // this returns the value of rotate back
                                                                            to the calling function in line 2.
                                                                            the +90 determines which part
                                                                        // of the hero movie clip is facing the
                                                                           mouse.
    If you put the mouse cursor over any of the green reserved words above in the Actions panel you will get a desctription of what these do.
    hope that helps.

  • Can't understand how Finder handles photos!

    I would like to understand how finder handles photos because I switched from windows recently and can't understand some things.
    First example, renaming lots of photos (without using iPhoto). I already have a automator action for renaming files, but if I have lots of photos with the numbers wrong, I wanted to organize the photos by date created and then rename them and get them in order. The problem is finder renames the files but with some order he chooses, and not the one I wanted. I know this happens because I select all the photos and he decides this way, but how can I do this my way!?
    The second question is kinda related. If I open lots of photos in finder (using command+a and command+o), why do the photos that are open in preview are opened in an order finder chooses, even if I arrange my photos in different orders (kind, name, date, etc)?
    I'm finding handling files in finder a little too much work to do, it was supposed to be a simple thing, just renaming or opening photos, because despite all his many weaknesses, windows worked kinda well with files, like pictures...

    Part of it depends on what criterion you have chosen to arrange the files in the Finder window: Name, Date Modified, Date Created, Size, Kind, Label. If by Name, I think the ones with numbers are ordered before letters.

  • [SOLVED] Can't understand how `install` command works

    Hi there:
    I'm trying to make a PKGBUILD for pgModeler, which comes pre-compiled, so I think what I should do is to move the application directory completely to /opt/pgmodeler and make a symbolic link from /usr/bin to the /opt/pgmodeler/start-pgmodeler.sh script. So, i just wrote this:
    pkgname=pgmodeler
    pkgver=0.4.1
    pkgrel=1
    pkgdesc="An open source tool for modeling PostgreSQL databases"
    arch=('x86_64')
    url="http://pgmodeler.com.br"
    license=('GPL3')
    source=("http://www.pgmodeler.com.br/releases/$pkgname-$pkgver-linux64.tar.gz" "pgmodeler.desktop")
    md5sums=('574887c35bc9e0a1bc65f8d4494200bb' '1f3ebda62e941ea7ea17cfb609cc392e')
    depends=(libpqxx)
    package() {
    install -Dm644 "$srcdir/$pkgname-$pkgver-linux64" "$pkgdir/opt/$pkgname"
    install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
    install -Dm644 "$srcdir/$pkgname-$pkgver-linux64/pgmodeler_logo.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
    chmod 755 "$pkgdir/opt/$pkgname/start-pgmodeler.sh"
    ln -s "$pkgdir/opt/$pkgname/start-pgmodeler.sh" "$pkgdir/usr/bin/$pkgname"
    But it fails in the first line of the package() function:
    [tae@localhost pgmodeler]$ makepkg -s
    ==> Making package: pgmodeler 0.4.1-1 (Sun Mar 17 23:03:08 CLST 2013)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving Sources...
    -> Found pgmodeler-0.4.1-linux64.tar.gz
    -> Found pgmodeler.desktop
    ==> Validating source files with md5sums...
    pgmodeler-0.4.1-linux64.tar.gz ... Passed
    pgmodeler.desktop ... Passed
    ==> Extracting Sources...
    -> Extracting pgmodeler-0.4.1-linux64.tar.gz with bsdtar
    ==> Removing existing pkg/ directory...
    ==> Entering fakeroot environment...
    ==> Starting package()...
    install: omitting directory ‘/home/tae/GitHub/pgmodeler/src/pgmodeler-0.4.1-linux64’
    ==> ERROR: A failure occurred in package().
    Aborting...
    This is my first PKGBUILD and I'm trying to decipher how to make it by looking at this files: https://aur.archlinux.org/packages/dr/dropbox/PKGBUILD and https://aur.archlinux.org/packages/op/opcion/PKGBUILD and I never used the install command before so I'm pretty lost.
    Thanks beforehand.
    Last edited by Tae (2013-03-19 12:44:45)

    Thanks to all. I learned a couple of stuff, but I still have no luck. This is what I've tried:
    I wrote install -d "$pkgdir/opt" in the first line of the package() function before ask, but it didn't make any difference. In fact, I'm not sure what it does (from its man page: treat all arguments as directory names; create all components of the specified directories).
    I modified the function with all your suggestions, and now it looks:
    package() {
    cp -R "$srcdir/$pkgname-$pkgver-linux64" "$pkgdir/opt/$pkgname"
    chmod 644 "$pkgdir/opt/$pkname/"
    chmod 755 "$pkgdir/opt/$pkgname/start-pgmodeler.sh"
    install -Dm644 "$srcdir/$pkgname.desktop" "$pkgdir/usr/share/applications/$pkgname.desktop"
    install -Dm644 "$pkgdir/opt/$pkgname/pgmodeler_logo.png" "$pkgdir/usr/share/pixmaps/$pkgname.png"
    ln -s "/opt/$pkgname/start-pgmodeler.sh" "$pkgdir/usr/bin/$pkgname/"
    but I get:
    $ makepkg -s
    ==> Making package: pgmodeler 0.4.1-1 (lun mar 18 20:33:53 CLST 2013)
    ==> Checking runtime dependencies...
    ==> Checking buildtime dependencies...
    ==> Retrieving Sources...
    -> Found pgmodeler-0.4.1-linux64.tar.gz
    -> Found pgmodeler.desktop
    ==> Validating source files with md5sums...
    pgmodeler-0.4.1-linux64.tar.gz ... Passed
    pgmodeler.desktop ... Passed
    ==> Extracting Sources...
    -> Extracting pgmodeler-0.4.1-linux64.tar.gz with bsdtar
    ==> Removing existing pkg/ directory...
    ==> Entering fakeroot environment...
    ==> Starting package()...
    cp: cannot create directory ‘/home/tae/GitHub/pgModeler/pkg/opt/pgmodeler’: No such file or directory
    ==> ERROR: A failure occurred in package().
    Aborting...
    Here I can't understand why it tries to create /opt/pgmodeler inside the pkg/ directory. For what I found in other PKGBUILDs and from the $pkgdir definition of the PKGBUILD man page (This contains the directory where makepkg bundles the installed package (this directory will become the root directory of your built package)) I though it will be the root directory.
    So I removed all the $pkgdir from the function and now I get this error:
    mkdir: cannot create directory ‘/opt/pgmodeler/’: Permission denied

Maybe you are looking for

  • Arabic text in my web application using iText..

    Hey Guys, I'm using the iText library to produce PDF reports in my web application; platform (ADF 11g and Weblogic 10g). I'm having a problem with rendering arabic text on the page, is there a way to print arabic text outside of a PdfPTable ?? I need

  • Combobox and arrow keys

    how can i disable the arrow keys in combobox component. i use as2. thnks

  • Can not install Oracle 9i R2 on Windows 2000

    I can not install Oracle 9i R2 on Win 2000. It failed at 48% with this message. Error in writing to file C: \oracle\ora92\oem_webstage\oem_webstage_8.jar I tried by copying the 3 disks to my hard drive and reinstall but not success. Help me please. T

  • Equal Cost Multi Path route support.

    Can anyone tell me if Solaris 8 supports ECMP? First if it works, and second, if it officially works? Anyone have a web page or document stating it works? Even more generally, can anyone point me to a Sun web page that lists RFC compliance for their

  • Bug report - Escaping list targets

    http://screencast.com/t/0WsRfR7nH192 Minor nit - With all the security related changes in APEX 4.1 and 4.2, the Builder itself has missed a few places to properly escape/unescape stuff. See above. The Edit (List) Region page (4000:4651) shows the tar