How to change the position of two objects?

I have four componensts of course is that I imported from my main mxml file

and each placed at the four corners.

What I want to achieve is to drag each item on others then swap their position.

For example, A comp is slipped on model B, in this case, change the position of A and b.

But for the moment, it doesn't seem to work properly. I could not find out what the problem with my code. Could someone help me reach this goal?

A big thank you to all those who could give me a helping hand!

///////////////////////////////////////////////////////////////////

This is one of my component *.

All the other three components are made in the same way, except each source image file is different *.

<? XML version = "1.0" encoding = "utf-8"? >
" < = xmlns:mx mx:Box ' http://www.Adobe.com/2006/MXML "width ="42"height ="42"> "
< mx:Image source="Images/air.png"/ >
< / mx:Box >

////////////////////////////////////////////////////////////////////////////////////////

It's my mxml that calls my components *.

<? XML version = "1.0" encoding = "utf-8"? >
" < = xmlns:mx mx:WindowedApplication ' http://www.Adobe.com/2006/MXML "layout ="absolute"xmlns:comp ="Comp.*"creationComplete ="onInit()"> "
< mx:Script >
<! [CDATA]
Import mx.containers.Box;
Import Comp.Icon_illustrator;
Import Comp.Icon_air;
Import Comp.Icon_flash;
Import Comp.Icon_flex;

private var i_1:Icon_air; 1
private var i_2:Icon_flash; 2
private var i_3:Icon_flex; 3
private var i_4:Icon_illustrator; 4
private var origX:Number;
private var origY:Number;
private var startObj:String;
private var icons: Array;

private var h_1:Box;
private var h_2:Box;
private var h_3:Box;
private var h_4:Box;

private function onInit (): void {}

initialize all icons
i_1 = new Icon_air();
i_2 = new Icon_flash();
i_3 = new Icon_flex();
i_4 = new Icon_illustrator();

i_1.name = "i_1;
i_2.name = "i_2;
i_3.name = "i_3;
i_4.name = "i_4";

Fill icon
showArea.addChild (i_1);
showArea.addChild (i_2);
showArea.addChild (i_3);
showArea.addChild (i_4);

Set x position
i_1.x = 100;
i_2.x = 200;
i_3.x = 100;
i_4.x = 0;

the position value is
i_1.y = 0;
i_2.y = 100;
i_3.y = 200;
i_4.y = 100;

icons = [i_2 i_3, i_1, i_4];
addEventListeners
for (var i: int = 0; i < icons.length; i ++) {}
icons [i] .addEventListener (MouseEvent.MOUSE_DOWN, sensors);
icons [i] .addEventListener (MouseEvent.MOUSE_UP, stopDragMe);
}

} //end of onInit

private void moveMe(e:MouseEvent):void {}
e.currentTarget.startDrag ();
showArea.setChildIndex (DisplayObject (e.currentTarget), 0);

origX = e.currentTarget.x;
origY = e.currentTarget.y;

startObj = e.currentTarget.name;
}

private void stopDragMe(e:MouseEvent):void {}
{if (this [startObj].hitTestObject(Icons[1]))}
trace ("hit 2");

This [startObj] .x = i_2.x;
This there [startObj] = i_2.y;

i_2.x = origX;
i_2.y = origY;

} else {if (this [startObj].hitTestObject(icons[0]))
trace ('hit 1');


This [startObj] .x = i_1.x;
This there [startObj] = i_1.y;

i_1.x = origX;
i_1.y = origY;

} else {}
trace ("knocking others');
This [startObj] .x = origX;
This there [startObj] = origY;
}
e.currentTarget.stopDrag ();

} //end stopDragMe

[]] >
< / mx:Script >

< mx:Panel id = "showArea" width = "400" height = "300" layout = "absolute" backgroundColor = "0 x 999999" / >

< / mx:WindowedApplication >

This shows you how to create dynamic user interface.



     
          
     
     
     

Tags: Flex

Similar Questions

  • How to change the position of the BB Menu?

    Hi all
    I would like to know how to change the position of the BB Menu. We made a personalized menu of BB and it appears in the upper right of the screen. I would like to know if it is possible to display the menu in the lower left side. We have checked RIM API, but did not find anything for this. Is there a way to do this? We could use other libraries or specific solution as it is very important for our project.

    Thank you

    Pedro

    It is not possible with the menus built-in mechanism.

    You can provide your own menu, using popupscreen and objectlistfield, for example. You can place this popup where you want.

  • How to change the position of 'you passed the test?

    Hello

    I need help on how to change the position of the message "congratulations, you passed the test. Perhaps the failure message.
    It should be in the Middle, but now to the left, it sinks in the background.
    I Don t see where to change it. All of the index are adjustable but it escapes me...


    Thank you very much!

    I think you are talking about the area of control on the slide to score? Move this area result or score slide himself slide.

  • How to change the position of a window created in the script?

    Hi all

    A window called from another window are the same size. How to change the position of the window from the window of the appellant's appeal?

    You can also use the property frameLocation of the window to get a set the locations of the windows.

  • How to change the position or timing of a video ads in a video player?

    I want to change the "timing" when the ads will be playing in a video player. Currently, there are rollers (played before the beginning of the video), mid-roll (played between the two) and post-rouleaux (played end of the video). To change the position, I am not able to. Help, please!

    Kind regards

    Nandini

    If you use cuepoints, change their location.

  • How to change the position of the code in a split screen?

    How one does change the position of the code in a split screen? It shows me currently right code and I need the code to be on the left.

    Thanks in advance!

    Go to the view menu and uncheck the box design on the left

  • How to set the position of an object PDEPath

    Hello
    I'm a beginner in the plugin Acrobat SDK development.
    I tried to reflow content within the pdf. I was able to redistribute most of the content except PDEPath object.as

    For PDEPath object re-flow that I was using the function PDEElementSetMatrix (PDEElement pdeElement, ASFixedMatrixP matrixP);

    and the trace object was not get positioned to led. It has been rather get placed outside the margin of page very far above the page.

    Another issue is that whenever I was trying to get the coordinates of the position of any object of PDEPath, using the PDEElementGetMatrix function.
    It's come 0,0 coordinate.

    Can someone help me know what could be the problem here.

    Thank you
    Marie José Saffiuddin

    The position of the paths is indeed defined by the matrix and only in this way.

    Things to watch

    -Make sure that you understand how to work with ASFixedMatrix objects (items cannot be defined directly as integers or real numbers).

    -Make sure you understand how to work the PDF matrices

    n ' forget not that the origin of the matrix cannot be the lower-left corner of the page. items are visible only if they are within the rectangle defined by the CropBox, or if there is no CropBox, the HD Mediabox Recorder

  • How to change the length of line objects

    Hi all

    How to change the length of the line objects.

    I know how to change the width or height of the elements.

    Utils < Facade::IGeometryFacade > ()--> (ResizeItems)
    itemList,
    Transform::PasteboardCoordinates (),
    Geometry::OuterStrokeBounds (),
    refPoint, Geometry::ResizeTo (newWidth, newHeight)
    );

    I know the new length and PMrect of the line item before moving.

    What I want to know is how to get the new width and height of this.

    Thank you.

    Fujimori - Satoru

    Find your old address of trigonometry and read the part about the Pythagorean theorem. This will give the scale factor you need to get the old PMRect to the new

  • How to change the positions of xy graph scale label

    LV2013

    Is it possible to change the position of label scale at design time?  The only way I can find to move each program which is not convenient.

    Surely, it should be possible to just catch them and move?

    # You have not to save it.  But do not tell it to replace the original control that exists in the VI.

  • How to change the position of the scrollbar component combobox

    Hello

    I would like to change the position of the scroll bar in a drop-down list on the right to the left box.

    Please advice.

    Thank you

    Yair Papo

    You can use the dropdown combobox property ' to reference the list component and then use the list component verticalScrollBar property to reference the scrollbar control.

    you will probably need to use the move() method to change its position rather than assign x, y properties and you will probably need to wait until the rendering is complete before attempting to assign its position.

  • How to change the position of the column

    Hai All

    I created a table with four columns and I need to change the position of the column

    For example, the Table name is emp

    the columns are name, address, empno, salary

    And now I need to change columns position while I display select * from emp not as select col1, col3, col2...

    Pls tell if it is possible

    And when the addition of f, it is possible to add a new column in a specific column position

    For example

    In the table above we will add a new column in a second post

    Please give some good examples

    Thanks in advance

    Srikkanth.M

    Hi Srikkanth,

    It's previous post on the use of views.
    What you could do is take your table T1 with columns: C1, C2, C3.
    And you need to re - order C2, C3, C3, then what you could do is

    Create view v_t1
    as
    Select C2, C3, C4
    from T1;

    Note: There is nothing on the oracle technology in this solution, you also need not to be a pro, it is same in MS Access. Structured query language. Don't underestimate your self by saying new to Oracle.

    See you soon

  • How to change the position of the canvas by programming?

    Hi all

    We need to change the position of a canvas by program. Is it possible to do?
    If not, can we change the canvas of a particular item running?
    Please help me on this.

    Kind regards
    Amit

    Check the following built-ins to manipulate a canvas:
    SET_VIEW_PROPERTY
    SET_CANVAS_PROPERTY

    See [formulas documentation | http://www.oracle.com/webapps/online-help/forms/10g/state?navSetId=_&navId=0] for more information.

  • How to change the position of the color of the gradient?

    How can I change the angle or position of the color of the gradient in the gradient shade?

    Tool shade of gradient (in the toolbar)

  • How to see the position of an object or an image in Indesign?

    I can see the size of it (dimensions) in the info panel and the position of the mouse, but not the position of the current selected object or frame.

    On the left side of the control panel

  • How to change the position of an element with the code?

    Hello! I'm doing a drag & drop, in this case, they send me a question and answer 4 options, the user has to drag the correct answer in a box, then the change in question and a new 4 responses is displayed. But I can't ' "reset" of the position of my movable elements for the next question.

    Please help me =)

    I use this code:

    () yepnope

    {

    Nope:]

    "js/jquery-ui-1.9.2.custom.min.js,"

    "js/jquery.ui.touch-punch.min.js,"

    'css/jquery-ui-1.9.2.custom.min.css '.

    ],

    full: init

    }

    );

    function init() {}

    var point = sym.$("Stage");

    var Rect1 = sym.$("Rect1");

    var Rect2 = sym.$("Rect2");

    var Rect3 = sym.$("Rect3");

    var Rect4 = sym.$("Rect4");

    Rect1.html("1");

    Rect2.html("2");

    Rect3.html("3");

    Rect4.html("4");

    Rect1.CSS ("text-align", "Center");

    Rect2.CSS ("text-align", "Center");

    Rect3.CSS ("text-align", "Center");

    Rect4.CSS ("text-align", "Center");

    Rect1.draggable ({containment: Stadium});

    Rect2.draggable ({containment: Stadium});

    Rect3.draggable ({containment: Stadium});

    Rect4.draggable ({containment: Stadium});

    Rect1.draggable ("option", "back", "invalid"); / / If the user does not move the right answer, return to initial position, but if he answer right, the draggable to line up on the box.

    Rect2.draggable ("option", "back", "disabled");

    Rect3.draggable ("option", "back", "disabled");

    Rect4.draggable ("option", "back", "disabled");

    / / droppable box

    var dropCase1 = sym.$("dropCase1");

    dropCase1.css ("position", "absolute");

    dropCase1.droppable({)

    accept: caso, / / my "case" var evolves according to the current issue. for this I use a switch/case statement.

    Drop: function (event, ui) {}

    Console.log ("good");

    }

    });

    }

    Hi, chino_10.

    I tried!

    1 set 4 rectangles & dropCase.

    2. Add the code

    var correctID = sym.$("Rect1").attr("id");  //correct rect
    
    function init(){
      sym.$("dropCase").droppable({
        accept:".button",
        tolerance: "fit",
        drop:function(evt, ui){
          if(ui.draggable.attr("id")==correctID){
            console.log("correct");
            ui.draggable({revert:false}); //turn off revert flag
          }else{
            console.log("incorrect");
          }
        }
      });
      $(".button").draggable({revert:true});
    }
    
    //load jQuery-ui from CDN & init
    yepnope({
     nope:"http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js",
     complete:init
    });
    
    

    HTH. UME.

Maybe you are looking for

  • Cannot open the menu options

    I never had any problems using Firefox before. but now, everytime I open a new tab, my pinned pages have disappeared. It now says: The address is not valid The URL is not valid and cannot be loaded. Web addresses are usually written like http://www.e

  • Problem with Mail

    Hello world! MacBook Pro (17-inch, late 2011 г.) OS X El Capitan 10.11.4 Please, help me, because it is impossible to use my Mail. Every day! Several times a day! My Mail goes down and I got an error message: Process: Mail [491] Path: /Applications/M

  • Password bios reset HP compaq mini 110

    Hi, I need help, how can I reset my bios password? CNU9237RC5 Model 110 c-101DEE I hope you can answer me SOON. =) Your help will be very appreciated thanks!

  • OfficeJet jumps randomly lines

    My HP Officejet J4680 recently started jumping lines of text when printing from MS Word documents, but will print documents pdf without problem, what is happening with this?

  • Adobe Acrobat Standard XI

    I can't reinstall Adobe Acrobat XI Standard on my computer Windows 10.  I get the following message: "the wizard was interrupted before Adobe Acrobat XI could be completely installed."  Your system has not changed.  To complete installation at anothe