StartDrag

I have written code to drag and drop JLabels between various extended selection JLists, and for the main part it works fine. However fairly frequently the DragGestureListener is not invoked when I suspect it should be, e.g. the mouse button is down and the mouse is moved but startDrag() isn't invoked because the DragGestureRecognizer hasn't recognized this.
Another, presumably related side effect, is that sometimes the DropTargetListener.drop() method is not invoked when the mouse button is released, and the dragged object can be dragged about with the mouse button up.
I'm running JDK1.3.0 on NT4 with service pack 6.
Anyone know if this is a bug ?
Paul Sandie

It might be a bug...it's very hard to say given the information you gave....But a brief search on the bug parade gave this as a likely suspect:
http://developer.java.sun.com/developer/bugParade/bugs/4200168.html
Not too sure it's related to your case, though.
HTH,
Fredrik

Similar Messages

  • Custom cursor using startDrag

    Hello everyone,
    I have a movieclip following my mouse to act as a custom cursor.
    I am using startDrag on the movie clip and mouse.hide()
    What I am trying to resolve is the following:
    I have several hidden simple button objects in the background of my flash movie. ( I am using these to detect when the user has the mouse in certain areas of the flash movie)
    When i go to move over these simple buttons, my custom cursor movieclip stops following the mouse cursor.  Normally my cursor would also then change to the Hand cursor, but i disabled that.
    Can anyone think of any method or hack that would make this work for me?  I would like my custom cursor following the mouse pointer at all times even when hovering over a simple button.
    thanks in advance.

    The cursor changes to hand cursor yet?
    When you say "single button Several hidden objects", the number is?

  • StartDrag constrain to Rectangle

    hi there
    please can somoe help with this little problem, I have a demo file that I am trying to created a constraint to a rectangle. I have the startDrag working and I am trying to constrain a square to the movie size of 600x400.
    I have been searching online help files but I can not for the life of me get it to work, would someone beable to put me out of my misery. I have attached the demo file I am working with but I will also post my script here for thoughs who prefer that.....going crazy, can any help, does it have to be this difficult...aarrrghh!!
    this is what I thought I could simply add
    animation", false, 0, 0, 300, 300);
    but know joy....anyone help   : (
    my code:
    ////Button Listeners/////////////
    // BtnNav listeners
    btnNav.addEventListener(MouseEvent.ROLL_OVER, btnNavOver);
    btnNav.addEventListener(MouseEvent.ROLL_OUT, btnNavOut);
    btnNav.addEventListener(MouseEvent.CLICK, btnNavDown);
    // change: made the graphic "red shape" a movieClip and made redShape and closeBtn a movieClip
    // added this listener to that button...
    animation.redShape.closeBtn.addEventListener(MouseEvent.MOUSE_UP,closeUp);
    ////for the click and drag
    animation.addEventListener(MouseEvent.MOUSE_DOWN,dragStart);
    animation.addEventListener(MouseEvent.MOUSE_UP,dragStop);
    ///////button 1 function ///////////
    // BtnNav Over function
    function btnNavOver(event:MouseEvent):void {
    btnNav.gotoAndPlay("over"); // go into btn1 movieclip and play the over frame label
    // BtnNav Out function
    function btnNavOut(event:MouseEvent):void {
    btnNav.gotoAndPlay("out"); // go into btn1 movieclip and play the out frame label
    //animation.stopDrag();
    // BtnNav Down function
    function btnNavDown(event:MouseEvent):void {
    // change: tell the movieClip animation to play...
    animation.play();
    //this.gotoAndPlay("animation");
    // play any frame label in any movieclip
    // change: added this function for the close button to have it play the animation clip...
    function closeUp(event:MouseEvent):void {
    animation.play();
    /////for the click and drag////
    function dragStart(event:MouseEvent):void {
        event.currentTarget.startDrag();
    //("animation", false, 0, 0, 300, 300);
    function dragStop(event:MouseEvent):void {
        stopDrag();

    I'm afraid it does not get simpler than this (AFAIK).
    Here's the (stripped down version) you could use:
    import flash.geom.Rectangle;
    ////Button Listeners/////////////
    ////for the click and drag
    animation.addEventListener(MouseEvent.MOUSE_DOWN,dragStart);
    animation.addEventListener(MouseEvent.MOUSE_UP,dragStop);
    /////for the click and drag////
    function dragStart(event:MouseEvent):void {
        event.currentTarget.startDrag( false, new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight ) );
    function dragStop(event:MouseEvent):void {
        stopDrag();
    The rectangle created defines the bounds in which the movieClip "animation" is dragged.
    The registrationpoint of the movieClip "animation" will remain within these bounds. If you want the whole clip to remain within these bounds easiest is to have the registrationpoint in the middle of the clip and defin the rect like:
        var d:DisplayObject = DisplayObject( event.currentTarget );
        var r:Rectangle = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );
        r.inflate( -d.width / 2, -d.height / 2 );
        event.currentTarget.startDrag( false, r );
    Just some handy methods of the Rectangle object to inflate (or shrink) a rectangle.

  • StartDrag in 3D not working

    The Language Reference states:
    "Three-dimensional display objects follow the mouse and        Sprite.startDrag() moves the object within       the three-dimensional plane defined by the display object. Or, if the  display object is a two-dimensional object       and the child of a three-dimensional object, the two-dimensional  object        moves within the three dimensional plane defined by the  three-dimensional parent object."
    However, this does not seem to be the case.  I have a 2D object which is the child of a 3D object, but startDrag will not work on the child.  If I remove any tweens in code from the parent's rotationY then startDrag will work.    If I have any reference to rotationY it will not work, even if it is set to 0.
    I found this post about reseting the matrix: http://forums.adobe.com/message/978511#978511   Which A. is a hack/workaround and B. I can't seem to get to work in my case.
    Digging further this seems to be a bug that was fixed in Flash 10 back in Oct 2008: http://labs.adobe.com/technologies/flashplayer10/releasenotes.html.  However, I have the latest Flash player and it is not working for me.
    Fluke or do other people experience the same problem and I should re-submit the bug?
    Thanks

    I am not sure but, given the fact that 3D is not really 3D but a Bitmap object's representation redrawn, you cannot interact with the object inside Bitmap for there is none - again, it is a single Bitmap.
    I see that the only way to preserve interactivity is to render each object separately.

  • StartDrag using Generic method in Actionscript 3

    Hi,
    AS3:
    How to get general id (or) name from xml loaded images. bcoz, i want to drag and drop that images in generic method. Now, i currently used the event.target.name for each one.
    So, code length was too large. See my code below.
    /*********loading images through xml********/
    var bg_container_mc:MovieClip
    var bg_bg_myXMLLoader:URLLoader = new URLLoader();
    bg_bg_myXMLLoader.load(new URLRequest("xml/backgroundimages.xml"));
    bg_bg_myXMLLoader.addEventListener(Event.COMPLETE, processXML_bg);
    function processXML_bg(e:Event):void {
              var bg_myXML:XML=new XML(e.target.data);
              columns_bg=bg_myXML.@COLUMNS;
              bg_my_x=bg_myXML.@XPOSITION;
              bg_my_y=bg_myXML.@YPOSITION;
              bg_my_thumb_width=bg_myXML.@WIDTH;
              bg_my_thumb_height=bg_myXML.@HEIGHT;
              bg_my_images=bg_myXML.IMAGE;
              bg_my_total=bg_my_images.length();
              bg_container_mc = new MovieClip();
              bg_container_mc.x=bg_my_x;
              bg_container_mc.y=bg_my_y;
              ContentHead.addChild(bg_container_mc);
              for (var i:Number = 0; i < bg_my_total; i++) {
                       var bg_thumb_url=bg_my_images[i].@THUMB;
                        var bg_thumb_loader = new Loader();
                       bg_thumb_loader.load(new URLRequest(bg_thumb_url));
                       bg_thumb_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded_bg);
                       bg_thumb_loader.name="bg_load"+i;
                       bg_thumb_loader.addEventListener(MouseEvent.MOUSE_DOWN, bg_down)
                       bg_thumb_loader.x = (bg_my_thumb_width-18)*bg_x_counter;
                       bg_thumb_loader.y = (bg_my_thumb_height-45)*bg_y_counter;
                       if (bg_x_counter+1<columns_bg) {
                                 bg_x_counter++;
                       } else {
                                 bg_x_counter=0;
                                 bg_y_counter++;
    function thumbLoaded_bg(e:Event):void {
              var my_thumb_bg:Loader=Loader(e.target.loader);
             var sprite:Sprite = new Sprite();
              var shape:Shape = new Shape();
              shape.graphics.lineStyle(1, 0x0098FF);
              shape.graphics.drawRect(e.target.loader.x-2, e.target.loader.y-2, e.target.loader.width+4, e.target.loader.height+4);
              sprite.addChild(shape);
              sprite.addChild(my_thumb_bg);
              sprite.x=4;
              bg_container_mc.addChild(sprite);
              my_thumb_bg.contentLoaderInfo.removeEventListener(Event.COMPLETE, thumbLoaded_bg);
    //  get name for each image. 
    I want to change this code in generic method. do needful.
    function bg_down(event:MouseEvent):void {
              var bg_name:String=new String(event.currentTarget.name);
              var bg_load:MovieClip=event.currentTarget as MovieClip;
              if (event.currentTarget.name=="bg_load0") {
                      var alaska_mc:alaska_png=new alaska_png();
                       addChild(alaska_mc);
                       alaska_mc.x=stage.mouseX;
                       alaska_mc.y=stage.mouseY;
                       alaska_mc.name="alaska_duplicate"+alaska_inc;
                       alaska_inc++;
                       alaska_mc.startDrag(false);
                      alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
                       alaska_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load1") {
                       var lake_mc:lake_png=new lake_png();
                       addChild(lake_mc);
                       lake_mc.x=lake_mc.mouseX;
                       lake_mc.y=lake_mc.mouseY;
                       lake_mc.name="lake_duplicate"+lake_inc;
                       lake_inc++;
                       lake_mc.startDrag(false);
                       lake_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load2") {
                       var mountn_mc:mountn_png=new mountn_png();
                       addChild(mountn_mc);
                       mountn_mc.x=mountn_mc.mouseX;
                       mountn_mc.y=mountn_mc.mouseY;
                       mountn_mc.name="mountn_duplicate"+mountn_inc;
                       mountn_inc++;
                       mountn_mc.startDrag(false);
                       mountn_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load3") {
                       var town_mc:town_png=new town_png();
                       addChild(town_mc);
                       town_mc.x=town_mc.mouseX;
                       town_mc.y=town_mc.mouseY;
                       town_mc.name="town_duplicate"+town_inc;
                       town_inc++;
                       town_mc.startDrag(false);
                       town_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load4") {
                       var water_mc:water_png=new water_png();
                       addChild(water_mc);
                       water_mc.x=water_mc.mouseX;
                       water_mc.y=water_mc.mouseY;
                       water_mc.name="water_duplicate"+water_inc;
                       water_inc++;
                       water_mc.startDrag(false);
                      water_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load5") {
                       var city_mc:city_png=new city_png();
                       addChild(city_mc);
                       city_mc.x=city_mc.mouseX;
                       city_mc.y=city_mc.mouseY;
                       city_mc.name="city_duplicate"+city_inc;
                       city_inc++;
                       city_mc.startDrag(false);
                      city_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load6") {
                        var citywide_mc:citywide_png=new citywide_png();
                       addChild(citywide_mc);
                       citywide_mc.x=citywide_mc.mouseX;
                       citywide_mc.y=citywide_mc.mouseY;
                       citywide_mc.name="citywide_duplicate"+citywide_inc;
                       citywide_inc++;
                       citywide_mc.startDrag(false);
                      citywide_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load7") {
                       var downtown_mc:downtown_png=new downtown_png();
                       addChild(downtown_mc);
                       downtown_mc.x=downtown_mc.mouseX;
                       downtown_mc.y=downtown_mc.mouseY;
                       downtown_mc.name="downtown_duplicate"+downtown_inc;
                       downtown_inc++;
                       downtown_mc.startDrag(false);
                      downtown_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load8") {
                       var powerlines_mc:powerlines_png=new powerlines_png();
                       addChild(powerlines_mc);
                       powerlines_mc.x=powerlines_mc.mouseX;
                       powerlines_mc.y=powerlines_mc.mouseY;
                       powerlines_mc.name="powerlines_duplicate"+powerlines_inc;
                       powerlines_inc++;
                       powerlines_mc.startDrag(false);
                      powerlines_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load9") {
                       var tropical_mc:tropical_png=new tropical_png();
                       addChild(tropical_mc);
                       tropical_mc.x=tropical_mc.mouseX;
                       tropical_mc.y=tropical_mc.mouseY;
                       tropical_mc.name="tropical_duplicate"+tropical_inc;
                       tropical_inc++;
                       tropical_mc.startDrag(false);
                      tropical_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
              if (event.currentTarget.name=="bg_load10") {
                       var waters_mc:waters_png=new waters_png();
                       addChild(waters_mc);
                       waters_mc.x=waters_mc.mouseX;
                       waters_mc.y=waters_mc.mouseY;
                       waters_mc.name="waters_duplicate"+waterthumb_inc;
                       waterthumb_inc++;
                       waters_mc.startDrag(false);
                      waters_mc.addEventListener(MouseEvent.MOUSE_UP, stdrag);
    Please suggest me if any  one.
    Regards,
    Viji. S

    Post AS3 questions in the AS3 forum, not the AS1/2 forum.

  • Problem with startDrag

    Hello guys, im having some issues with a movieclip drag.
    many times, it just dont work how it was supposed to.
    i press and then it doesnt work, or sometimes i press and the
    movieclip goes away. weel many strange thing.
    this is by code:
    botaoProblemas.onPress = function() {
    this.startDrag();
    botaoProblemas.onRelease = function() {
    botoes(this);
    function botoes(mc:MovieClip) {
    mc.stopDrag();
    // and some random things
    you can check what i am saying here:
    http://www.imauro.com/monografia/
    i thought it could be something with my movieclip but i
    copy/paste it from ilustrator and then just hit F8 and make a
    movieclip with Reg TL.
    any ideas how to make the bets out of drag? or something i
    need to take care of?
    thank you

    Im getting the problem now.
    The problem is, when i release the mouse with other MC in
    front of mine he doesnt drop it and the mc stay following my mouse.
    I thought that by using the getNextHighestDepth i would solve
    it, but guess not :(
    Any idea how to do this please?
    I am using object to make the mouse stuff like:
    var meuObject:Object = new Object();
    meuObject.onRollOut = function(){
    apagarTexto();
    meuObject.onPress = function(){
    var novaDepth= this.getNextHighestDepth();
    this.swapDepths(novaDepth);
    this.startDrag();
    meuObject.onRelease = function() {
    botoes(this);
    for (i=0;i<6;i++){
    var newDepth = this.getNextHighestDepth();
    var newMC:String = "botaoMenu" + String(i);
    this.attachMovie(newMC,newMC,newDepth,meuObject);
    }

  • StartDrag problem?

    I'm building a simple map application, where users can click
    on the map and drag it around. Pretty basic idea. The map is an
    extended Canvas, nested inside of a parent container which is also
    a Canvas. When someone clicks on the map, I call startDrag, and on
    release I stop it. Still pretty basic. The problem I'm having is
    that whenever a user clicks on the map, they can sometimes drag the
    map right outside of the parent container. I'm not sure how to fix
    this, is it a bug? Or am I missing something?
    I've put together a simple example of what I'm talking about.
    http://webdojo.net/flex/
    If you click on the red square and drag it, I want that to
    stay in the white square. It makes sense to me that it should be
    default, but you can drag the red square out of its parent. Notice
    when you release it goes back into its parent, and you see
    scrollbars to its position.
    Here's the source view:
    http://webdojo.net/flex/srcview/
    I've tried setting clipContents to true on the parent Canvas,
    but it seems to do nothing. Any ideas?

    Im getting the problem now.
    The problem is, when i release the mouse with other MC in
    front of mine he doesnt drop it and the mc stay following my mouse.
    I thought that by using the getNextHighestDepth i would solve
    it, but guess not :(
    Any idea how to do this please?
    I am using object to make the mouse stuff like:
    var meuObject:Object = new Object();
    meuObject.onRollOut = function(){
    apagarTexto();
    meuObject.onPress = function(){
    var novaDepth= this.getNextHighestDepth();
    this.swapDepths(novaDepth);
    this.startDrag();
    meuObject.onRelease = function() {
    botoes(this);
    for (i=0;i<6;i++){
    var newDepth = this.getNextHighestDepth();
    var newMC:String = "botaoMenu" + String(i);
    this.attachMovie(newMC,newMC,newDepth,meuObject);
    }

  • StartDrag element with rotationY or rotationX bug

    Hello  there,
    I´ve  looked a  lot in the web but it seems that no one got this problem...  or at least  not published it.
    I´m making a startDrag with bounds  on a element  with rotationY value. Ok, it drags, but when got in the  bounds it just  give a huge bug, distorting the element scale. I tryed  some other things  but nothing worked - like put the drag canvas without  rotationY inside  another canvas with the rotationY. I tryied on Flex  Builder 3 and Flash  Builder and both gives the same bug. Does anyone  has an idea or got this  error?
    PS:  in Flex Builder 3 we need to configure  it to accept rotationY or  rotationX parameters.
    This bug is  cleared related to rotationY for  me because this parameter modifys the  2d into a 3d space, so the  rectangle could not be right. I wish someone  can help me! Thanks!
    http://www.keek.me/testes/drag2.swf
    <?xml  version="1.0" encoding="utf-8"?>
    <mx:Application  xmlns:mx="http://www.adobe.com/2006/mxml"
              layout="absolute"
            verticalAlign="top"
              backgroundColor="white"
              backgroundGradientColors="[#0694F7, #501A82]"   backgroundGradientAlphas="[1.0, 1.0]"
              horizontalScrollPolicy="off" verticalScrollPolicy="off" >
          <mx:Script>
            <![CDATA[
                public function   allowDrag():void{
                    window_1.cacheAsBitmap = true;
                  public function startDragg():void{
                      window_1.startDrag(false,new Rectangle(0,10,300,0));
                  public function stopDragg():void{
                      window_1.stopDrag();
                private function   stage_mouseUp(evt:Event):void {
                    stopDragg();
              ]]>
        </mx:Script>
        <mx:Canvas   id="window_1" mouseUp="stopDragg();" rotationY="20"   mouseDown="startDragg();" width="564" height="240"   backgroundColor="#FFFFFF"/>
    </mx:Application>

    Repost!
    Hi,
    please, can someone from Oracle give me a statement?

  • How to startdrag/stopdrag a movieclip which has textfield

    please help me with the following code.
    I can not drag the movie clip which has a input text field.I
    want to type a number in it and than drag it on the screen
    button_btn.onRelease=function():Void{
    _root.attachMovie("text_mc","input_mc",this.getNextHighestDepth(),{_x:70,_y:150});
    } //input_mc is a movie clip instance which has input
    textfiled named input_txt
    input_mc.onPress=function():Void{
    startDrag(this);
    input_mc.onRelease=function():Void{
    stopDrag();

    I don't understand your code. You are attaching a movie
    called "parent" in the libarary and renaming it "parent_mc." That
    seems like a bad idea because it is likely to look confusing with
    _parent. So I would give those better names.
    Next you have commented out attaching something called
    "mc_txet" which you rename "text_mc" (again confusing, but not as
    confusing as the parent thing) to rect_mc.
    Then you attach event handlers to parent_mc. So I'm not
    really clear on all the things you are trying to do. What you need
    to do is set aside your current project and start with a brand new
    document, figure out how to make this work, and then work it back
    into your existing project. This works for me:
    1. Brand new document.
    2. Draw a filled rectangle and convert it to movie clip.
    Callt he clip, "Background" and give the instance name "background"
    3. Over the background instance draw an input textfield the
    field must be smaller than the background art. Give it the instance
    name, "theInput"
    4. Select both the background instance and theInput
    textfield. Convert to symbol. Name the symbol "TextInputer" and
    name the instance "textInputer"
    5. Select the frame and put the code shown below.
    6. It works.
    7. You could then make the TextInputer exportable for
    actionscript and use attachMovie and soforth and so on.

  • Can not get the index number from a StartDrag Function

    var t:Array=new Array();
    t=[d1,d2,d3,d4,d5];
    var d:Array=new Array();
    d=[t1,t2,t3,t4,t5];
    var ust:int;
    for(var i:int=0;i<t.length;i++){
    t[i].addEventListener(MouseEvent.MOUSE_DOWN, mouseDowner);
    for(var j:int=0;j<t.length;j++){
    t[j].addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
    function mouseDowner(event:MouseEvent):void {
    event.target.startDrag();
    trace(t.indexOf(MovieClip(event.target)));
    var ast:int;
    ast=t.indexOf(MovieClip(event.target));
    trace(ast);
    ust=ast.valueOf();
    function mouseReleased(event:MouseEvent):void {
    event.target.stopDrag();
    if(d.indexOf(MovieClip(event.target).dropTarget.parent)!=-1){
    trace(d.indexOf(MovieClip(event.target).dropTarget.parent));}
    else{trace("not appropriate");}
    //trace(MovieClip(event.target).dropTarget.parent.name);
    var tf1:TextField = new TextField();
    tf1.text="LIGHT";
    tf1.x=-30;
    tf1.y=-30;
    t1.addChild(tf1);
    tf1.mouseEnabled=false;
    var tf2:TextField = new TextField();
    tf2.text="EASY";
    tf2.x=-30;
    tf2.y=-30;
    t2.addChild(tf2);
    tf2.mouseEnabled=false;
    var tf3:TextField = new TextField();
    tf3.text="IMPOSSIBLE";
    tf3.x=-30;
    tf3.y=-30;
    t3.addChild(tf3);
    tf3.mouseEnabled=false;
    var tf4:TextField = new TextField();
    tf4.text="FAST";
    tf4.x=-30;
    tf4.y=-30;
    t4.addChild(tf4);
    tf4.mouseEnabled=false;
    var tf5:TextField = new TextField();
    tf5.text="UGLY";
    tf5.x=-30;
    tf5.y=-30;
    t5.addChild(tf5);
    tf5.mouseEnabled=false;
    var tf6:TextField = new TextField();
    tf6.text="DARK";
    tf6.x=-30;
    tf6.y=-30;
    d1.addChild(tf6);
    tf6.mouseEnabled=false;
    var tf7:TextField = new TextField();
    tf7.text="DIFFICULT";
    tf7.x=-30;
    tf7.y=-30;
    d2.addChild(tf7);
    tf7.mouseEnabled=false;
    var tf8:TextField = new TextField();
    tf8.text="POSSIBLE";
    tf8.x=-30;
    tf8.y=-30;
    d3.addChild(tf8);
    tf8.mouseEnabled=false;
    var tf9:TextField = new TextField();
    tf9.text="SLOW";
    tf9.x=-30;
    tf9.y=-30;
    d4.addChild(tf9);
    tf9.mouseEnabled=false;
    setChildIndex(d5, 1);
    var tfh:TextField = new TextField();
    tfh.text="BEAUTIFULL";
    tfh.x=-30;
    tfh.y=-30;
    d5.addChild(tfh);
    tfh.mouseEnabled=false;
    setChildIndex(d[0], 0);
    setChildIndex(d[1], 0);
    setChildIndex(d[2], 0);
    setChildIndex(d[3], 0);
    setChildIndex(d[4], 0);
    trace(ust);

    var t:Array=new Array();
    t=[d1,d2,d3,d4,d5];
    var d:Array=new Array();
    d=[t1,t2,t3,t4,t5];
    var ust:int;
    var alt:int;
    for(var i:int=0;i<t.length;i++){
    t[i].addEventListener(MouseEvent.MOUSE_DOWN, mouseDowner);
    for(var j:int=0;j<t.length;j++){
    t[j].addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
    function mouseDowner(event:MouseEvent):void {
    event.target.startDrag();
    trace(t.indexOf(MovieClip(event.currentTarget)));
    ust=t.indexOf(MovieClip(event.currentTarget));
    trace(ust);
    trace(ust);
    function mouseReleased(event:MouseEvent):void {
    event.target.stopDrag();
    if(d.indexOf(MovieClip(event.currentTarget).dropTarget.parent)!=-1){
    trace(d.indexOf(MovieClip(event.currentTarget).dropTarget.parent));
    alt=d.indexOf(MovieClip(event.currentTarget).dropTarget.parent);
    trace(alt);}
    trace(alt);
    trace(ust);
    if(alt==ust){trace("ok");}
    else{trace("not appropriate");}
    var tf1:TextField = new TextField();
    tf1.text="LIGHT";
    tf1.x=-30;
    tf1.y=-30;
    t1.addChild(tf1);
    tf1.mouseEnabled=false;
    var tf2:TextField = new TextField();
    tf2.text="EASY";
    tf2.x=-30;
    tf2.y=-30;
    t2.addChild(tf2);
    tf2.mouseEnabled=false;
    var tf3:TextField = new TextField();
    tf3.text="IMPOSSIBLE";
    tf3.x=-30;
    tf3.y=-30;
    t3.addChild(tf3);
    tf3.mouseEnabled=false;
    var tf4:TextField = new TextField();
    tf4.text="FAST";
    tf4.x=-30;
    tf4.y=-30;
    t4.addChild(tf4);
    tf4.mouseEnabled=false;
    var tf5:TextField = new TextField();
    tf5.text="UGLY";
    tf5.x=-30;
    tf5.y=-30;
    t5.addChild(tf5);
    tf5.mouseEnabled=false;
    var tf6:TextField = new TextField();
    tf6.text="DARK";
    tf6.x=-30;
    tf6.y=-30;
    d1.addChild(tf6);
    tf6.mouseEnabled=false;
    var tf7:TextField = new TextField();
    tf7.text="DIFFICULT";
    tf7.x=-30;
    tf7.y=-30;
    d2.addChild(tf7);
    tf7.mouseEnabled=false;
    var tf8:TextField = new TextField();
    tf8.text="POSSIBLE";
    tf8.x=-30;
    tf8.y=-30;
    d3.addChild(tf8);
    tf8.mouseEnabled=false;
    var tf9:TextField = new TextField();
    tf9.text="SLOW";
    tf9.x=-30;
    tf9.y=-30;
    d4.addChild(tf9);
    tf9.mouseEnabled=false;
    setChildIndex(d5, 1);
    var tfh:TextField = new TextField();
    tfh.text="BEAUTIFULL";
    tfh.x=-30;
    tfh.y=-30;
    d5.addChild(tfh);
    tfh.mouseEnabled=false;
    setChildIndex(d[0], 0);
    setChildIndex(d[1], 0);
    setChildIndex(d[2], 0);
    setChildIndex(d[3], 0);
    setChildIndex(d[4], 0);

  • Why is the startDrag() lag so choppy?

    I have tried increasing the frame rate, it doesn't help.
    I am compiling using AIR for iOS and running on a first generation iPad.
    I have simple movie clips that get dragged around the screen. No memory hogs, it's just a little kid's game. And yet startDrag() and startTouchDrag() are really choppy. It's like dragging on one of those old 1 frame per second machines. My finger will land and .75-1 second later the Sprite will catch up. 1 second is a long, long time in a user interface. Other similar apps (not written in Actionscript) have smooth, silky drag functions. Even my 3 year old daughter notices how bad the lag is.
    Is this just an AIR compiler problem, or am I doing something wrong?

    Yes - actually the movie clip being dragged is nothing but dynamic text (I changed this from when I wrote earlier saying they were simple graphics. I had to make them dynamic. It didn't effect the drag). But that's the only thing going on.
    But I have other apps where I drag dynamic text around and it works just fine.
    Is there a setting in fonts embedding or something like that that would make it better?
    (Hm, I just thought of this...in my other apps the dynamic text is being dragged over a bitmap and in this one it's being dragged over a vector. Would that make a difference?)

  • StartDrag Basic Problem

    Hi,
    I am starting to find my way in AS3.
    I use startDrag in the code and it works. But when I try
    stopDrag it doesn't stop to drag.
    I hope somebody can tell me what I am doing wrong?
    Thanks
    Here is my code:

    you're removing your mouseup listener when you
    startdrag.

  • Turn StartDrag On & Off

    Hi guys and gals,
    I've got an app that creates several instance from a database
    and displays them on the screen (images, text, video etc). Each
    element has it's own name/instancename and is listed in a listbox.
    I want the user to be able to select the element from the listbox
    and click a "move" button, which will attach the appropriate
    startDrag/ stopDrag code onto the relevant element (movieclip). I
    can attach the code upon creation of the clip eg
    evt.onPress = function() {
    evt.startDrag(false,40,90,890,690);
    evt.onRelease = function() {
    evt.stopDrag();
    but is there a way to disable this until the user presses the
    move button. Alternatively, is there a may to "attach" the code to
    the movieclip as and when it's required and then detach it once the
    move has finished?
    thanks all!

    phil ashby,
    >I can attach the code upon creation of the clip eg
    >
    > evt.onPress = function() {
    > evt.startDrag(false,40,90,890,690);
    > };
    Let's take a look so far. (I'm assuming "evt" the instance
    name of your
    clip.) It makes more sense at this point to use the global
    "this" property
    inside the function assigned to evt's MovieClip.onPress
    event.
    evt.onPress = function():Void {
    this.startDrag(false,40,90,890,690);
    > evt.onRelease = function() {
    > evt.stopDrag();
    > };
    Same thing here.
    > but is there a way to disable this until the user
    presses
    > the move button.
    Sure thing. :) Check out the MovieClip class entry of the
    ActionScript
    2.0 Language Reference for all the things you can do with a
    movie clip
    symbol. Among the property, method, and event categories,
    you'll find a
    MovieClip._enabled property.
    > Alternatively, is there a may to "attach" the code to
    > the movieclip as and when it's required and then
    > detach it once the move has finished?
    There is. In fact, you've already accomplished half of this
    goal: by
    virtue of your existing ActionScript, you've already
    "attached" code to an
    instance. You'll have to handle the appropriate change or
    release event for
    your list box (see the Components Language Reference for
    event information)
    and cause that event handler to invoke the same ActionScript
    you've already
    shown.
    If you prefer -- and this may make things a bit easier --
    use a named
    function instead of a function literal:
    function customStartDrag():Void {
    this.startDrag(false,40,90,890,690);
    function customStopDrag():Void {
    this.stopDrag();
    evt.onPress = customStartDrag;
    evt.onRelease = customStopDrag;
    evt.onReleaseOutside = customStopDrag;
    And to remove ...
    evt.onPress = null;
    evt.onRelease = null;
    evt.onReleaseOutside = null;
    David Stiller
    Adobe Community Expert
    Dev blog,
    http://www.quip.net/blog/
    "Luck is the residue of good design."

  • Rotate on startDrag () function

    how can I make an MC rotate when I use the on (press) with
    the this.startDrag() function? I have tried many different ways of
    doing this, but all that happens is... nothing at all. I've tried
    fitting in the _rotation and the rotate command, but all fails.
    Please help me. Thanks in advanced.

    "DJ Sick Nick" <[email protected]> wrote in
    message
    news:eevc0h$ldm$[email protected]..
    > how can I make an MC rotate when I use the on (press)
    with the
    > this.startDrag()
    > function? I have tried many different ways of doing
    this, but all that
    > happens
    > is... nothing at all. I've tried fitting in the
    _rotation and the rotate
    > command, but all fails. Please help me. Thanks in
    advanced.
    >
    assuming the instance name of your draggable mc is "drag_me"
    you could do:
    drag_me.onPress = function() {
    this.startDrag(false);
    //Not necessary, but may give you some values to help with
    rotation
    below.
    // These are just the values of the cursor when you first
    press the
    button.
    var startX:Number = _root._xmouse;
    var startY:Number = _root._ymouse;
    this.onMouseMove = function() {
    //Again, not necessary, but now you can compare the values
    of the
    start and current every frame.
    var currentX:Number = _root._xmouse;
    var currentY:Number = _root._ymouse;
    //maybe use the differences between currentX and startX (and
    Ys) to
    do some rotation.
    this._rotation = ..... ? ......
    drag_me.onRelease = function() {
    stopDrag();
    this.onMouseMove = undefined;
    or, if you just want it to start rotating, regardless of
    position, you could
    try:
    drag_me.onPress = function() {
    this.startDrag(false);
    this.onEnterFrame = function() {
    this._rotation += 1;
    drag_me.onPress = function() {
    stopDrag();
    delete this.onEnterFrame;
    Please note, no code above has been tested.
    SMB

  • Startdrag() and ClassCastException !

    hello everybody !
    when i execute this code :
    public class CTree extends JTree implements DragSourceListener,
                                                      DragGestureListener,
                                                      Autoscroll {
         private BufferedImage _imgGhost;
    public void dragGestureRecognized(DragGestureEvent e) {
    Transferable transferable = new ... ;
    e.startDrag(null, _imgGhost, new Point(5,5), transferable, this);
    a message "ClassCastException" appears and the problem is linked to the startDrag() method.
    why ?
    it's important or not ?
    can you help me ?
    thanks for all.
    FMP.

    this the stack :
    "java.lang.ClassCastException
         at sun.awt.datatransfer.DataTransferer.translateTransferable(DataTransferer.java:1197)
         at apple.awt.CDataTransferer.translateTransferable(CDataTransferer.java:129)
         at sun.awt.datatransfer.DataTransferer$6.run(DataTransferer.java:1937)
         at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
         at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:230)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:183)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
         at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
         at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
    FMP.

Maybe you are looking for

  • Iphone 6 fast battery drain IOS 8.1.2 even on standby

    I have a new iphone 6 64Gb setup as a new phone, already with IOS 8.1.2 installed.  I have experienced really fast battery drain all the time. I have tried with location services disabled, push disabled, background app refresh disabled siri off Iclou

  • How do I delete photos from iPod Touch?  Some photos do not have the trash basket option!

    How do I delete photos from iPod Touch?  Some photos do not have the trash basket option! When I first synced my iPod Touch with my laptop, it uploaded a lot of photos onto the iPod.  I now wish to delete those but it does not seem as a straight forw

  • How can I reduce the size of the MASTERS folder inside Photos?

    I was trying to find out why my Photos app database is SO large.  I have 8 gig of jpg photos. I chose to NOT copy them when I imported them into Photos. Yet my Photos app database is 8g as well!  That's a lot of space to use when I didn't even copy t

  • Ipad will not start no matter what?

    My Ipad is totally dead and can not be awakened no matter what, any suggestions?

  • Query sql sys.views inside a Clr

    Hi, I am working on a table function Clr (for sql server 2005) which must analyze the text of a stored procedure. Here's a sample of my code         private class PostTraitement         public SqlInt32 IdPostTraitement;         public SqlString TxtMa