Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4080050
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:52:49+00:00 2026-05-20T17:52:49+00:00

This is my first real programming endeavor and this is the last thing holding

  • 0

This is my first real programming endeavor and this is the last thing holding my little project back from being a success.

My goal with this code is to add event listeners to an array of Movie Clips that will drag and drop them on the stage.

Here is the code:

var itemBank:Array = new Array(d1_anim.drawer1.test01.movieClip_1, d1_anim.drawer1.test01.movieClip_2);

for(var i:int = 0; i < itemBank.length; i++) {
    itemBank[i].buttonMode = true;
    itemBank[i].addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
    itemBank[i].addEventListener(MouseEvent.MOUSE_UP, dropOff);
    trace("pickUp added to " + itemBank[i]);
}

function pickUp(event:MouseEvent):void
{
    event.target.startDrag(true);
    trace("Draging " + event.target);
}

Right now the MC does not drag and the trace statement says:

pickUp added to [object MovieClip]

EDIT:
Here is my fla, I give up. I don’t know why it wont work. Please help.
[Download it here](Edit: removed download link)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T17:52:50+00:00Added an answer on May 20, 2026 at 5:52 pm

    Your current code has been tested and works fine. The error must be somewhere else.

    If you want the test code i used you can download the source here: Drag & Drop Source File (Same code as yours, this is just a proof that it works).


    EDIT: Here are the changes that i made to your code to make it work. Read the comments for better understanding. I also changed the registration point of the d1_anim.drawer1.test01.hair1 movie clip to center instead of top-left, this is needed to make it work.

    import flash.display.MovieClip;
    import com.reintroducing.ui.SliderUI; // Always have imports at top. It's a good practice.
    
    var itemBank:Array = new Array(d1_anim.drawer1.test01.hair1);
    
    for(var i:int = 0; i < itemBank.length; i++) {
        itemBank[i].buttonMode = true;
        itemBank[i].mouseChildren = false;// Added this line. For explanation go to: http://ryanbosinger.com/blog/2008/actionscript-3-eventtarget-returns-children-of-movieclip/
        itemBank[i].addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
        itemBank[i].addEventListener(MouseEvent.MOUSE_UP, dropOff);
        trace("pickUp added to " + itemBank[i]);
    }
    
    function pickUp(e:MouseEvent):void
    {
        e.currentTarget.startDrag(true);
        trace("Draging " + e.currentTarget);
    }
    function dropOff(e:MouseEvent):void
    {
        // --- Change 'this' to 'e.currentTarget' --- \\
        e.currentTarget.stopDrag();
        e.currentTarget.x = mouseX;
        e.currentTarget.y = mouseY;
        e.currentTarget.width = 200;
        // --- Putting the target in a temporary variable made an error dissapear. --- \\
        // --- I don't really know why and i don't really care either --- \\
        var tempMC = e.currentTarget;
        this.stage.addChild(tempMC);
        d1_anim.visible = false;
    }
    

    And here is a link to the working .fla

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am complete newbie for programming and this is my first real program I
Currently using MySQL version 5.1.6 This is my first real world build and so
Code first: '''this is main structure of my program''' from twisted.web import http from
I did this: [User.first, User.last].to_xml and got this: <users type=array> <user> <created-at type=datetime>2010-03-16T06:40:51Z</created-at> <id
I am programming my first real PHP website and am wondering how to make
It's not a real programming (coding) problem, sorry for that (but design comes first).
I would like to hear from people who have real world programming experience in
I am starting my first programming project in PHP making some sort of web
This is my first real attempt at using multithreading, I want to know how
Warning: Please treat me like the rookie I am. This is my first real

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.