Skip to main content
saratogacoach
Inspiring
June 26, 2013
Answered

Drag/Drop Small MC Objects

  • June 26, 2013
  • 1 reply
  • 862 views

I'm building a project with small dots (6X6) that the user drags/drops onto a part of the stage. These need to be small, but "grabbable" with the mouse pointer (or in touch enabled platforms using a stylus point). I have been trying, unsuccessfully so far, to create these as MC's inside larger (14X14) dots (also MC) set to 0 alpha so the larger surrounding area doesn't show, but would allow for grabbing the smaller dot MC inside. So far, doesn't work. The smaller dot drags/drops OK, but the alpha transparent larger top layer of the MC shows no evidence of being grabbed. Not sure if this is possible for dragging/dropping. Essentially, what I am trying to do is set up a surrounding transparent grag handle to make the smaller dot easier to drag/drop without obstructing the area/view on which it needs to be positioned/dropped. Would prefer not to use a third-party item for transform handles, if possible.

Maybe there is a better way to do this?

Any suggestions/specific steps to accomplish this, appreciated.

This topic has been closed for replies.
Correct answer Ned Murphy

Here is a link to an example file that does what you just described as far as creating the draggable objects goes - one has the bigger piece alpha-ed out while the other does not... both drag properly. 

http://www.nedwebs.com/Flash/AS3_Drag_alpha.fla

1 reply

Ned Murphy
Legend
June 26, 2013

Using a transparent outer area is the way to go.  But you need to have the entire mc be draggable, not just the small dot you place within it.  Your drag/drop code should be applied to the overall mc. 

saratogacoach
Inspiring
June 26, 2013

Hi Ned,

I think that is what I'm doing, but I can re-check.

Steps:

(1) create 6X6 dot, convert to MC, give it instance name as well; (2) create 14X14 dot, convert to MC, give it instance name as well; (3) smaller dot/MC layer to top, bigger dot/MC layer to bottom; (4) select both and convert to MC with instance name as well; (5) script MCcombined.MCBiggerDot.alpha = 0;

(6) using drag/drop event listeners (start drag, stop drag, etc.) script drag and drop for MCcombined: result--smaller dot can be grabbed but area around it (representing the bigger dot with alpha=0 dot cannot be grabbed.

I must be doing something wrong.

But another solution that I found is to scaleX, scaleY the smaller dot (by itself) so that when clicked/unclicked it gets bigger and smaller.

saratogacoach

Ned Murphy
Ned MurphyCorrect answer
Legend
June 26, 2013

Here is a link to an example file that does what you just described as far as creating the draggable objects goes - one has the bigger piece alpha-ed out while the other does not... both drag properly. 

http://www.nedwebs.com/Flash/AS3_Drag_alpha.fla