Announcement

Collapse
No announcement yet.

Drag drop events between Scaleform DragSlots in AS3

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Drag drop events between Scaleform DragSlots in AS3

    I have a simple scaleform inventory. I'm using the scaleform DragSlot class for the inventory slots (scaleform.clik.controls.DragSlot).

    I'm trying to figure out how to trigger actions on the drop events, so I can call Unrealscript when placing an item in a new slot.

    Does anyone know how I can access this event in AS?

    #2
    Code:
    var myDragSlot:DragSlot = new DragSlot();
    myDragSlot.addEventListener(DragEvent.DRAG_END,dragEnded);
    Code:
    private function dragEnded(e:Event)
    {
        trace("drag has ended for:",DragSlot(e.currentTarget));
    }

    Comment


      #3
      Thanks for the help. Sorry if this is a noob AS question, but I want to get the slot that item was dragged from and the slot that the item was dropped into?

      Then I can pass these two variables to unrealscript and handle everything from there.

      Comment


        #4
        To be a bit more clear, here is what I have in my AS:

        Code:
         public override function handleDropEvent(e:DragEvent):Boolean {
        			
                   ExternalInterface.call("MoveItemToSlot", e.dragTarget.name, e.dropTarget.name);	
        	 
                    var acceptDrop:Boolean = true; // Ask C++
                    if (acceptDrop) {
                        content = e.dragSprite;
                    }
                    
                    return acceptDrop;
                }
        My problem is that AS doesn't like the way i'm trying to access e.dragTarget.name. It triggers this error:
        Code:
        Access to possibly undefined property name through a reference with static type scaleform.clik.interfaces:IDragSlot
        I can see in the debugger that the name I need is there:


        How can I access this property, so that I can sent it over the unrealscript?

        Comment


          #5
          Ahhhh, nevermind. I wasn't thinking straight. Should have read the error properly

          I just needed to use:
          Code:
          e.dragTarget['name']

          Comment

          Working...
          X