Newby to Flash -- need help with Drag and Drop

I have been trying to create a drag and drop in Flash where I have five different places for an instance of a mc to be dropped. I want to be able to drop only three instances to each place and these three instances are specific to one of the five "drop places".  I also want the mc instance to go back to its original position if it is not dropped on the right place.  I've got the actionscript working to drag and drop the mc instances on the "drop places"  but I cannot figure out how to do the if statements so that if it doesn't match the correct drop place it will go back to its original position.
Here's some of my code:
Analyze1_mc.objName = "Analyze1";
Analyze1_mc.val = 1;
Design1_mc.objName = "Design1";
Design1_mc.val = 4;
Analyze1_mc.buttonMode = true; // sets mouse pointer to hand
Design1_mc.buttonMode = true;
Analyze1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
Analyze1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
Design1_mc.addEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
Design1_mc.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop);
var originalPosition:Point;
function returnToOriginalPosition(): void
          originalPosition = new Point(x,y)
          x = originalPosition.x;
          y = originalPosition.y;
// function to drag item clicked
function fl_ClickToDrag(event:MouseEvent):void
          event.currentTarget.startDrag();
          event.target.parent.addChild(event.target);
function fl_ReleaseToDrop(event:MouseEvent):void
          var target:MovieClip = event.currentTarget as MovieClip;
          var item:MovieClip = MovieClip(event.target);
          item.stopDrag();
if (event.target.hitTestObject(AnalyzeTarget_mc)  && (event.target.val == 1)) {
                                        trace ("Analyze1");
                                        event.target.x = AnalyzeTarget_mc.x + 42;
                                        event.target.y = AnalyzeTarget_mc.y + 5;
                                        updateItem(Analyze1_mc);
                              } else {
                                        returnToOriginalPosition();
if (event.target.hitTestObject(DesignTarget_mc) && (event.target.val == 4)) {
                                        trace ("Design1");
                                        event.target.x = DesignTarget_mc.x + 42;
                                        event.target.y = DesignTarget_mc.y + 5;
                                        updateItem(Design1_mc);
                              } else {
                                        returnToOriginalPosition();
function updateItem(item:MovieClip):void {
          buttonMode = false;
          removeEventListener(MouseEvent.MOUSE_DOWN, fl_ClickToDrag);
I put the trace in to check the function -- and I do get the output when the mc instance is dropped on the right place -- but there is no return to original position if the instance is dropped in the wrong spot and there is no update to the mc instance. 
Any help would be greatly appreciated. Thanks!

That line you speak of is merely declaring a variable, nothing is being assigned to it.
One way of assigning the original position data to each object is to just assign it like follows:
Analyze1_mc.originalX = Analyze1_mc.x;
Analyze1_mc.originalY = Analyze1_mc.y;
etc...
Another way to do it with less code is to assign it generically just before you start dragging each of them...
function fl_ClickToDrag(event:MouseEvent):void
          event.currentTarget.originalX = event.currentTarget.x;
          event.currentTarget.originalY = event.currentTarget.y;
          event.currentTarget.startDrag();
          event.target.parent.addChild(event.target);
One thing I noticed in your code earlier is that you switch between using event.currentTarget and event.target.  If you want to be sure that the object your code is targetiing is the object that has the listener assigned to it (your movieclips) stick with using currentTarget.   target can end up pointing to something inside that object instead of the object itself.  In the following lines...
          var target:MovieClip = event.currentTarget as MovieClip;
          var item:MovieClip = MovieClip(event.target);
You could very well be assigning target and item as being the same object.  I don't think that is what you want.  You might wanting to have one of them be the object you drop it on, which would be the dropTarget, not the target

Similar Messages

  • Need help with drag and drop game, Urgent!

    Hi I have created a drag and drop game, the drag and drop is
    working alright however once the right word has been placed in the
    box, and moves on to the next question the previous correct answer
    stays where it was placed, how can i get it to snap back to its
    original location? Also when the right word is draged in to the the
    white box i want it to snap into place in that box so it fits in
    there.
    Also if you have any other thoughts and advice on how i can
    improve on this please email me thanx
    Can someone please help, my .fla file can be found here:
    http://www.freshlemon.co.uk/timeline.fla
    http://www.freshlemon.co.uk/timeline.fla.zip
    thanx

    tellTarget is ancient
    I forget what it even used to do??? hahaha
    seriously, just put in the instance name and what you want it
    to do:
    tellTarget("movieclip"){
    play();
    is now just
    movieclip.play();

  • Help with drag and drop

    As a PC user I am having some trouble adjusting to Mac differences. I am trying to drag a photo from Iphoto to Reunion family tree program, I open the page I need in Reunion and then open Iphoto and Reunion is not visable to drag the photo to. In windows I could open two programs side by side or drag the the item to the task bar over the other program and it would open to drag the picture to. How do I do that with a Mac?

    well, I'm not quite sure what reunion is, but its relatively similar to windows. just like the taskbar, the dock manages all your open applications, so you can click and drag (just like on a pc) and hover over the icon of the second window's program on the dock. If the icon dims a bit, then wait there a second and the second window will pop to the front, and you can drop wherever you want. Depending on the program, however, and its file associations, the icon might not dim, so there is a useful button on all macs, called the exposé button (usually on the same button as F3, looks like a box with three smaller boxes in it) that shows all your windows. Press that after starting your drag, hold your mouse over the second window where you want to drop, press the button again, then drop where you need. I personally find this all a little tedious, so apple also made "hot corners". these are corners of the screen, that, whenever you touch them with your mouse, and action happens. You can change which actions happen in which corners if you go to System Preferences>Exposé and Spaces>Exposé under Hot Corners.

  • MOVED: [Athlon64] Need Help with X64 and Promise 20378

    This topic has been moved to Operating Systems.
    [Athlon64] Need Help with X64 and Promise 20378

    I'm moving this the the Administration Forum.  It seems more apporpiate there.

  • Can shared actions reset with drag and drop?

    I'm currently creating an interactive module where the learner will need to drag and drop grey squares to the correct area on the screen.  If you see my picture below, I have a possible 20 grey squares needing to be dragged and dropped for each terminal that's on the lower right of the screen capture. I've created a shared action that shows different wires moving for each of the 20 grey squares moving from the upper image to the lower right image of the screen.  This is painstakingly time consuming, but worth the effect.  The problem I have stems from the drag and drop's "reset" button.  The "reset" button helps set the grey squares that are my drag sources to their original positions, but it does not reset the shared actions that correspond to the movement of each grey square.  Is there any way I can reset not only the drag sources, but also the shared actions associated with the drag sources?  Any help is truly appreciated. 

    This article might be useful: http://coenraets.org/blog/2007/06/air-to-desktop-drag-and-drop-two-simple-utility-classes/

  • SharePoint Server Publishing Infrastructure with drag-and-drop

    Hello,
    When I activated "SharePoint Server Publishing Infrastructure" future, I can no longer use drag-and-drop functionality between two libraries (eg. drag from Document Library to MyDoc library). When I disable it, drag and drop is possible.
    But I need both of this functionalities, because i use Managed navigation. What should I do?
    Thanks in advance,
    Tomaz

    Hi Tomaz,
    According to your description, I could reproduce this issue as:
    1. Create a web application with team site
    2. Create a new library called docA, upload a new document
    3. Then I could move the document to Document library with drag-and-drop feature
    4. Activate SharePoint Server Publishing Infrastructure
    5. I could not move the document from Document library to docA library with drag-and-drop feature
    6. Upload a new document to docA, then also could not move it to Document library with drag-and-drop feature
    Since you also want to use Managed Navigation, you can use Content and Structure feature to move a document from one library to another library. You can do as Site Settings->content and structure under Site Administration->clicking on the library,
    then you can move or copy the document to the destination library.
    I hope this helps.
    Thanks,
    Wendy
    Wendy Li
    TechNet Community Support

  • Pls Help! Drag and Drop problem, identical symbols acting differently - same code! WHY?

    In the attached file, I have a series of symbols that have a drag and drop command to change colour at different sections of a bullseye, and that are also text editable (html).
    However, some of the symbols get stuck and will not be moved after moving once or at all, and some get stuck once their text has been edited.
    I have poured over the code and it appears to be the same for each symbol - can anyone explain as to why this is happening?
    I also cannot now edit the text properly on the ipad (it is really fiddly to change between different symbols to edit their text -- is there maybe a better way to do this? A button to change between symbols to then edit their text, can you help with this too?)
    THANK YOU SO MUCH!!!
    File here:
    https://www.dropbox.com/s/g71gnfichjgyehn/NEW%20RISK%20RADAR.zip

    Hi, I think I undertsand what you mean now, so the code is as below, btu I am not sure what a handler is? but some of my risks still get stuck once the text has been changed on them:
    // Use for loop for attr
    // deleted  yepnope since you load with scropt loading
    // added pos for each symbol so we can replace them there.
    document.ontouchmove = function(e) {
            e.preventDefault();
    var risk = ;
    var Pos = [
    {'x':-9,'y':806},
    {'x':27,'y':854},
    {'x':72,'y':894},
    {'x':71,'y':934},
    {'x':231,'y':811},
    {'x':231,'y':853},
    {'x':231,'y':894},
    {'x':231,'y':934},
    {'x':388,'y':811},
    {'x':388,'y':852},
    {'x':388,'y':893},
    {'x':388,'y':934},
    {'x':543,'y':811},
    {'x':543,'y':853},
    {'x':543,'y':893},
    {'x':543,'y':934}
    var myText = ; 
    for (i=0;i<risk.length;i++){
    sym.getSymbol(risk[i]).$(risk[i]).attr("contenteditable",true);
    sym.$('Quadrant_text').attr("contenteditable",true);
    sym.$('Quadrant1_text').attr("contenteditable",true);
    sym.$('Quadrant2_text').attr("contenteditable",true);
    sym.$('Quadrant3_text').attr("contenteditable",true);
    // apply the draggable JQuery UI plugin to the MyDraggableSymbol symbol on your stage
    sym.$('Risk1').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk1").stop("Initial");
      sym.setVariable("symName","Risk1");
    //adding for risk3_orange similarly add for other symbols
    sym.$('Risk1').draggable();
    sym.getSymbol('Risk1').$("Risk1").bind('click tap',function(ev) {
         sym.$('Risk1').draggable('disable');
    }).unbind('dblclick tap',function(ev) {
         sym.$('Risk1').draggable('enable');
    sym.$('Risk2').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk2").stop("Initial");
      sym.setVariable("symName","Risk2");
    //adding for Risk2 similarly add for other symbols
    sym.$('Risk2').draggable();
    sym.getSymbol('Risk2').$("Risk2").bind('click tap',function(ev) {
         sym.$('Risk2').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk2').draggable('enable');
    sym.$('Risk3').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk3").stop("Initial");
      sym.setVariable("symName","Risk3");
    //adding for Risk3 similarly add for other symbols
    sym.$('Risk3').draggable();
    sym.getSymbol('Risk3').$("Risk3").bind('click tap',function(ev) {
         sym.$('Risk3').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk3').draggable('enable');
    sym.$('Risk4').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk4").stop("Initial");
      sym.setVariable("symName","Risk4");
    //adding for Risk4 similarly add for other symbols
    sym.$('Risk4').draggable();
    sym.getSymbol('Risk4').$("Risk4").bind('click tap',function(ev) {
         sym.$('Risk4').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk4').draggable('enable');
    sym.$('Risk5').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk5").stop("Initial");
      sym.setVariable("symName","Risk5");
    //adding for Risk5 similarly add for other symbols
    sym.$('Risk5').draggable();
    sym.getSymbol('Risk5').$("Risk5").bind('click tap',function(ev) {
         sym.$('Risk5').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk5').draggable('enable');
    sym.$('Risk6').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk6").stop("Initial");
      sym.setVariable("symName","Risk6");
    //adding for Risk6 similarly add for other symbols
    sym.$('Risk6').draggable();
    sym.getSymbol('Risk6').$("Risk6").bind('click tap',function(ev) {
         sym.$('Risk6').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk6').draggable('enable');
    sym.$('Risk7').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk7").stop("Initial");
      sym.setVariable("symName","Risk7");
    //adding for Risk7 similarly add for other symbols
    sym.$('Risk7').draggable();
    sym.getSymbol('Risk7').$("Risk7").bind('click tap',function(ev) {
         sym.$('Risk7').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk7').draggable('enable');
    sym.$('Risk8').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk8").stop("Initial");
      sym.setVariable("symName","Risk8");
    //adding for Risk8 similarly add for other symbols
    sym.$('Risk8').draggable();
    sym.getSymbol('Risk8').$("Risk8").bind('click tap',function(ev) {
         sym.$('Risk8').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk8').draggable('enable');
    sym.$('Risk9').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk9").stop("Initial");
      sym.setVariable("symName","Risk9");
    //adding for Risk9 similarly add for other symbols
    sym.$('Risk9').draggable();
    sym.getSymbol('Risk9').$("Risk9").bind('click tap',function(ev) {
         sym.$('Risk9').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk9').draggable('enable');
    sym.$('Risk10').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk10").stop("Initial");
      sym.setVariable("symName","Risk10");
    //adding for Risk10 similarly add for other symbols
    sym.$('Risk10').draggable();
    sym.getSymbol('Risk10').$("Risk10").bind('click tap',function(ev) {
         sym.$('Risk10').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk10').draggable('enable');
    sym.$('Risk11').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk11").stop("Initial");
      sym.setVariable("symName","Risk11");
    //adding for Risk11 similarly add for other symbols
    sym.$('Risk11').draggable();
    sym.getSymbol('Risk11').$("Risk11").bind('click tap',function(ev) {
         sym.$('Risk11').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk11').draggable('enable');
    sym.$('Risk12').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk12").stop("Initial");
      sym.setVariable("symName","Risk12");
    //adding for Risk12 similarly add for other symbols
    sym.$('Risk12').draggable();
    sym.getSymbol('Risk12').$("Risk12").bind('click tap',function(ev) {
         sym.$('Risk12').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk12').draggable('enable');
    sym.$('Risk13').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk13").stop("Initial");
      sym.setVariable("symName","Risk13");
    //adding for Risk13 similarly add for other symbols
    sym.$('Risk13').draggable();
    sym.getSymbol('Risk13').$("Risk13").bind('click tap',function(ev) {
         sym.$('Risk13').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk13').draggable('enable');
    sym.$('Risk14').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk14").stop("Initial");
      sym.setVariable("symName","Risk14");
    //adding for Risk14 similarly add for other symbols
    sym.$('Risk14').draggable();
    sym.getSymbol('Risk14').$("Risk14").bind('click tap',function(ev) {
         sym.$('Risk14').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk14').draggable('enable');
    sym.$('Risk15').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk15").stop("Initial");
      sym.setVariable("symName","Risk15");
    //adding for Risk15 similarly add for other symbols
    sym.$('Risk15').draggable();
    sym.getSymbol('Risk15').$("Risk15").bind('click tap',function(ev) {
         sym.$('Risk15').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk15').draggable('enable');
    sym.$('Risk16').draggable(,
    drag: function(e,ui)
      sym.getSymbol("Risk16").stop("Initial");
      sym.setVariable("symName","Risk16");
    //adding for Risk16 similarly add for other symbols
    sym.$('Risk16').draggable();
    sym.getSymbol('Risk16').$("Risk16").bind('click tap',function(ev) {
         sym.$('Risk16').draggable('disable');
    }).bind('dblclick tap',function(ev) {
         sym.$('Risk16').draggable('enable');
    sym.getSymbol("Drop").$('Outer').droppable(
    sym.getSymbol("Drop").$('Middle').droppable(
    sym.getSymbol("Drop").$('Target').droppable(
    sym.$('resetBtn').click(function(){
      sym.$('Quadrant_text').html('Quadrant');
      sym.$('Quadrant1_text').html('Quadrant');
      sym.$('Quadrant2_text').html('Quadrant');
      sym.$('Quadrant3_text').html('Quadrant');
    for (i=0;i<risk.length;i++){
      sym.$(risk[i]).css({"left":Pos[i].x,"top":Pos[i].y,"position":"absolute"})
      sym.getSymbol(risk[i]).stop(0);
      sym.getSymbol(risk[i]).$(risk[i]).html("Challenge");
    But is still doesn't work,
    Subject: Re:  Pls Help! Drag and Drop problem, identical symbols acting differently - same code! WHY?

  • Problem with Drag and drop in panel dashboard

    Hi
    I am having problem with drag and drop in panel dashboard.
    I will explain what i am doing.
    I am using Oracle three column template in First region i am having a table that showing all customer.
    I drag one record from my table and drop it on customer info (CIF) page on second region it is working fine.
    my CIF page has a dashboard with 6 panel box. i am showing 6 different jsff in 6 panel box.
    I put drop target in each jsff
    <af:dropTarget dropListener="#{backingBeanScope.backing_customerinformation.handleItemDrop}"
    actions="COPY">
    <af:dataFlavor flavorClass="org.apache.myfaces.trinidad.model.RowKeySet"
    discriminant="CustomerSearchDnD"/>
    </af:dropTarget>
    when i put drop target my panel boxes moves only when i drag it to another panel box header not entire part of panel box.
    if i remove the drop target then panel box move normally as the example given on: [http://adfui.us.oracle.com:7778/faces-trunk/faces/visualDesigns/dashboard.jspx?_afrLoop=2021391022520156&_afrWindowMode=0&_afrWindowId=null] but in taht case i am not able to drag and drop my data

    You must be an Oracle employee as you're referring to a component in the upcoming JDeveloper version which has yet been released to the general public. Oracle employee's are, I believe, directed to post on internal Oracle forums.
    CM.

  • Problem with Drag and Drop on a JTree

    I would like to have a JTree with drag and drop support with the following characteristics:
    1) The JTree holds near 100 different kinds of TreeNodes
    2) The drag and drop operation uses TreeNodes as Transferable
    3) The drop operation adds a new TreeNode child on the TreeNode that accepts the drop
    4) There are some rules for a TreeNode to accept the drops by example:
         Type1 can accept Type2
         Type2 can accept Type3
         All other combinations are not allowed
    I am using the following classes to support this behavior
    JTree
    DataFlavor
    DragSourceListener
    DropTarget
    DropTargeListener
    DragSource
    GestureListener
    Transferable
    The question is:
    How to change the cursor shape when the mouse is over a node to show graphically the drop accepting rules.?
    I can not use the the following methods to change the cursor-shape
    DropTargetListener.dragEnter
    And
    DropTargetListener.dragOver
    Case they receive a DropTargetDragEvent witch don�t knows nothing about the TreeNode type dragged.
    I can not create a TreeNode on the method GestureListener.dragGestureRecognized cause this could not work when dragging between two diffents JVM.

    Hello,
    You might want to search this forum for this class : DNDTree.java. It pretty much does the job.

  • Is it possible to create a tree with drag-and-drop functionality using ajax

    I saw these samples;
    Scott Spendolini's AJAX Select List Demo
    http://htmldb.oracle.com/pls/otn/f?p=33867:1:10730556242433798443
    Building an Ajax Memory Tree by Scott Spendolini
    http://www.oracle.com/technology/pub/articles/spendolini-tree.html
    Carl Backstrom ApEx-AJAX & DHTML examples;
    http://htmldb.oracle.com/pls/otn/f?p=11933:5:8901671725714285254
    Do you think is it possible to create a tree with drag-and-drop functionality using ajax and apex like this sample; http://www.scbr.com/docs/products/dhtmlxTree/
    Thank you,
    Kind regards.
    Tonguç

    Hello,
    Sure you can build it, I just don't think anyone has, you could also use their solution as well in an APEX page it's just a matter of integration.
    Carl

  • How can i get the address with drag and drop from address book into pages?

    I want to creat a letter withe the new pages. Normaly it was possible to put the adress from the adressbook with drag and drop into the letter. So it was possible to create one letter with many different adresses. But now I didn't find this function any more. How to do ist now?
    Withe best regards and I'm sorry for may bad english
    Klaus

    Sounds like you "upgraded" to Pages 5.
    Apple has removed over 90 features from Pages 5.
    http://www.freeforum101.com/iworktipsntrick/viewforum.php?f=22&sid=3527487677f0c 6fa05b6297cd00f8eb9&mforum=iworktipsntrick
    Pages '09 should still be in your Applications/iWork folder.
    Archive/trash Pages 5, after Exporting your files to Pages '09, and rate/review it in the App Store, then get back to work.
    Peter

  • Need help with JTextArea and Scrolling

    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    public class MORT_RETRY extends JFrame implements ActionListener
    private JPanel keypad;
    private JPanel buttons;
    private JTextField lcdLoanAmt;
    private JTextField lcdInterestRate;
    private JTextField lcdTerm;
    private JTextField lcdMonthlyPmt;
    private JTextArea displayArea;
    private JButton CalculateBtn;
    private JButton ClrBtn;
    private JButton CloseBtn;
    private JButton Amortize;
    private JScrollPane scroll;
    private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
    private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
    private JComboBox rateTermList;
    double interest[] = {5.35, 5.5, 5.75};
    int term[] = {7, 15, 30};
    double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
    int termInMonths, month, termLoop, monthLoop;
    public MORT_RETRY()
    Container pane = getContentPane();
    lcdLoanAmt = new JTextField();
    lcdMonthlyPmt = new JTextField();
    displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
    rateTermList = new JComboBox(rateTerm);
    scroll = new JScrollPane(displayArea);
    scroll.setSize(600,170);
    scroll.setLocation(150,270);//DEFINE BUTTONS
    CalculateBtn = new JButton("Calculate");
    ClrBtn = new JButton("Clear Fields");
    CloseBtn = new JButton("Close");
    Amortize = new JButton("Amortize");//DEFINE PANEL(S)
    keypad = new JPanel();
    buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
    keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
    keypad.add(new JLabel("Loan Amount$ : "));
    keypad.add(lcdLoanAmt);
    keypad.add(new JLabel("Term of loan and Interest Rate: "));
    keypad.add(rateTermList);
    keypad.add(new JLabel("Monthly Payment : "));
    keypad.add(lcdMonthlyPmt);
    lcdMonthlyPmt.setEditable(false);
    keypad.add(new JLabel("Amortize Table:"));
    keypad.add(displayArea);
    displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
    buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
    buttons.add(CalculateBtn);
    buttons.add(Amortize);
    buttons.add(ClrBtn);
    buttons.add(CloseBtn);//ADD ACTION LISTENER
    CalculateBtn.addActionListener(this);
    ClrBtn.addActionListener(this);
    CloseBtn.addActionListener(this);
    Amortize.addActionListener(this);
    rateTermList.addActionListener(this);//ADD PANELS
    pane.add(keypad, BorderLayout.NORTH);
    pane.add(buttons, BorderLayout.SOUTH);
    pane.add(scroll, BorderLayout.CENTER);
    addWindowListener( new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    String arg = lcdLoanAmt.getText();
    int combined = Integer.parseInt(arg);
    if (e.getSource() == CalculateBtn)
    try
    JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
    if ((e.getSource() == CalculateBtn) && (arg != null))
    try{
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
    monthlyInterest = interest[0] / (12 * 100);
    termInMonths = term[0] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
    monthlyInterest = interest[1] / (12 * 100);
    termInMonths = term[1] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
    monthlyInterest = interest[2] / (12 * 100);
    termInMonths = term[2] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
    }                    //IF STATEMENTS FOR AMORTIZATION
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
    loopy(7, 5.35);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
    loopy(15, 5.5);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
    loopy(30, 5.75);
    if (e.getSource() == ClrBtn)
    rateTermList.setSelectedIndex(0);
    lcdLoanAmt.setText(null);
    lcdMonthlyPmt.setText(null);
    displayArea.setText(null);
    if (e.getSource() == CloseBtn)
    System.exit(0);
    private void loopy(int lTerm,double lInterest)
    double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
    int amount, months, termloop, monthloop;
    String lcd2 = lcdLoanAmt.getText();
    amount = Integer.parseInt(lcd2);
    termloop = 1;
    paid = 0.00;
    monthlyrate = lInterest / (12 * 100);
    months = lTerm * 12;
    monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
    total = months * monthly;
    balance = amount;
    while (termloop <= lTerm)
    displayArea.setCaretPosition(0);
    displayArea.append("\n");
    displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
    displayArea.append("\n");
    displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
    monthloop = 1;
    while (monthloop <= 12)
    monthint = balance * monthlyrate;
    monthprin = monthly - monthint;
    balance -= monthprin;
    paid += monthly;
    displayArea.setCaretPosition(0);
    displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
    displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
    monthloop ++;
    termloop ++;
    public static void main(String args[])
    MORT_RETRY f = new MORT_RETRY();
    f.setTitle("MORTGAGE PAYMENT CALCULATOR");
    f.setBounds(600, 600, 500, 500);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    }need help with displaying the textarea correctly and the scroll bar please.
    Message was edited by:
    new2this2020

    What's the problem you're having ???
    PS.

  • Need help with ADF and Business Intelligence BI integration

    Hi All,
    I am using JDev 11.1.1.6.0.
    I am trying to integrate BI Dashboard into my ADF application.
    The BI Dashboard that I am integrating includes prompts, and using the prompt value, the table inside the dashboard is filtered. So, when I drag and drop the dashboard into the page, it asks me the the prompt value with Dashboard Prompts dialog.
    The problem is that even though I entered value into the prompt value (Value 1, Value 2) in the dialog, the table is not filtered. It's like it is not using the value that I entered.
    I also tried to bind the prompt value (in the dialog box) with the attribute binding in my page. But it's also not working.
    Could you please help me with this issue? Thanks.
    Best Regards,
    cmoster

    I have not done this myself , but thought that some tips here might help you -
    http://docs.tpu.ru/docs/oracle/en/fmw/11.1.1.6.0/bi.1111/e10545/embedding_adf.htm#autoId15

  • Need help with trim and null function

    Hi all,
    I need help with a query. I use the trim function to get the first three characters of a string. How do I write my query so if a null value occurs in combination with my trim to say 'Null' in my results?
    Thanks

    Hi,
    Thanks for the reply. What am I doing wrong?
    SELECT trim(SUBSTR(AL1.user_data_text,1,3)),NVL
    (AL1.user_data_text,'XX')
    FROM Table
    I want the XX to appear in the same column as the
    trim.The main thing you're doing wrong is not formatting your code. The solution may become obvious if you do.
    What you're saying is:
    SELECT  trim ( SUBSTR (AL1.user_data_text, 1, 3))
    ,       NVL ( AL1.user_data_text, 'XX' )
    FROM    Tablewhich makes it clear that you're SELECTing two columns, when you only want to have one.
    If you want that column to be exactly like the first column you're currently SELECTing, except that when that column is NULL you want it to be 'XX', then you have to apply NVL to that column, like this:
    SELECT  NVL ( trim ( SUBSTR (AL1.user_data_text, 1, 3))
                , 'XX'
    FROM    Table

  • Possible Bug with Drag-and-Drop Being Published via HTML5 - Getting "Undefined" Error When Dragging Object

    Hello,
    I came up with a way to use drag-and-drop interactions that will take advantage of file input so that I may create a drag-and-drop interaction that uses one draggable object over and over allowing multiple scoring/tracking possibilities.  Example use...is having the draggable object be dynamic in that it randomly changes its text so that a learner can drag a term it's possible classification.........thus allowing the possibility of having many terms easily loaded without having to redo a drag-and-drop interaction for each needed terms/classifications updates/changes.
    My Issue: When using a variable to represent the text for a draggable Smart Shape object, I'm getting the error message "undefined" when, clicking/pressing on the object, as well as during the drag of the object. This issue occurs when publishing the project in an HTML5 format.  Flash interestingly enough seems to work perfect...but we are not interested in publishing via Flash any longer.
    To better help you explore this error message, I've set up a test project so that you can see when and how the "undefined" message shows up during a drag-and-drop interaction.  I've also included the Captivate 8 project file used to make the exploration project I'm sharing in this post.
    Link to Captivate project I created for you all to explore "undefined" error message": http://iti.cscc.edu/drag_and_drop_bug/
    Link to this Captivate 8 Project file: http://iti.cscc.edu/drag_and_drop_bug.cptx
    It's pretty interesting how things react in this demo, please try the following actions to see some interesting happenings:
    Drag the Yellow (or variable drag box) to the drag target.
    Drag Black Hello square to Drag target and click undo or reset - watch the undefined message come up on the Yellow (or variable drag box).
    Drag the Yellow (or variable drag box) to the drag target and then use the undo or reset.
    Move both draggable boxes to the drag target and use the undo and reset buttons...
    Anyhow, I know you all are sharp and will run the demo through its paces.
    I'd really be very honored if anyone help me figure out how I could (when publishing out to HTML5) no longer have the "undefined" error message show up when using drag-and-drop with a variable for shape text. This technique has been well received at the college I work at...and I have many future project requests for using such an idea on a variety of similar interactions. I'd love see a solution or see if this might be a bug Adobe may be able to fix!
    I tried to find a solution to the issue documented here for quite some time, but I was not able to find anyone with this problem much less attempting the idea I'm sharing in the help request -  save the darn "undefined" message that comes up!
    Many thanks in advance for any help and/or direction that you all may be able to provide,
    Paul

    Hello,
    I just wanted to supply a minor update related to my drag-and-drop question/issue stated above:
    I did another test using Captivate 7, and found that the undefined error (publishing as HTML5) does not appear and the variable data remains visible - except the variable data turns very small and does not honor any font size related settings.
    I did go ahead and submit this to Adobe as a possible bug today.
    Thanks again for any help related to this issue.  If the issued documented above is solved, it will allow many amazing things to be done using Captivate's drag-and-drop for both regular type projects as well as interaction development for iBooks! 
    Matter of fact if this issue gets fixed, I'll publish a Blog entry (or video) on way's I've used Captivate's drag-and-drop to create dynamic learning activities for Higher Ed. and for use in iBooks.
    ~ Paul

Maybe you are looking for

  • 11i to r12 Conversion - help needed

    Hi My client is doing re-implementation of r12 and migrating from 11i to r12. I need help particularly on conversions side. The client is a SaaS company. they are considering to bring open and history transactions and applied/unapplied receipts to r1

  • I cant install Itunes on my windows 8 laptop. (unspecified errors encountered)

    I have tried to install Itunes and Icloud on my windows 8 laptop. I have hunted all through the laptop and see no sign that any apple product has ever been on this laptop, yet iget errors during the install process that causes the installer to abort

  • DATA LOAD ISSUE /NO ROLL UP MEMORY

    Hello Team, I have this master data load failure for FIS_BELNR. The problem which I think that everytime it tries to load it runs out of internal table space in the backend. I really don't know what it means. This data is been failing everyday becaus

  • Email settings in J4580 All-In-One Solution Center

    Hi there, For some time i use my all-in-one J4580 printer with the Windows Vista application on my computer. But recently i change and did run an upgrade to the Windows 7 application and everything did goes verry well without any problems accept for

  • Format: Windows to Mac

    The iPod touch says it is in "Windows" format. This isn't a problem, but soon I will be moving to mac, and I was wondering if when I transfer my iTunes library over to my new mac, whether or not this will change to "Macintosh." If it doesn't (I don't