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

  • SEARCH
  • Home
  • 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 892237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:01:13+00:00 2026-05-15T14:01:13+00:00

I have a red box called mc1_mc and every time when you drag on

  • 0

I have a red box called mc1_mc and every time when you drag on it you get a new little blue box added to the stage. Yhe idea is that you can drag those blue boxes too. however I dont know how to detect them.

this is the code:

var newBlok:Boolean;
var blokIndex:int = 0;
var blokje:blok;
var huidigBlok:DisplayObject;
var prullenBak:DisplayObject = getChildByName("groen_mc");

stage.addEventListener(MouseEvent.MOUSE_DOWN,pickUp);
stage.addEventListener(MouseEvent.MOUSE_UP,dropIt);

function pickUp(event:MouseEvent):void
{
    trace(event.currentTarget);
    trace(event.target);
    trace(event.target.name);

    if (event.target.name == "mc1_mc")
    {
        trace("hoi");

        blokje = new blok;  
        blokje.name = "blokje" + blokIndex;
        blokIndex++;

        addChild(blokje);
        blokje.startDrag(true);

    }

    if (event.target.type == blok)
    {
        trace("blok");
    }

    //blokjeVast = blokje;
}

function dropIt(event:MouseEvent):void
{
    event.target.stopDrag();
}

he wont ever come to the line: trace(“blok”);
even when the object i clicked on gives:

[object Stage]
[object blok]
blokje0

for the lines.

trace(event.currentTarget);
trace(event.target);
trace(event.target.name);

does anyone know how to do check if its a object of type “blok”?

  • 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-15T14:01:14+00:00Added an answer on May 15, 2026 at 2:01 pm

    To check whether an object is of a certain type, you can use the is operator.

    So, you should change this:

    if (event.target.type == blok)
    {
        trace("blok");
    }
    

    To this:

    if(event.target is blok) 
    {
        trace("blok");
    }
    

    And if the target is of type blok, you should see the trace.

    There’s one caveat here. ìs tells you if an object is of a certain type. Since a class can extend other classes and implement interfaces, you should check for the most derived or specific one first (if you want to distinguish between, say, Sprite and MovieClip).

    var mc:MovieClip = new MovieClip();
    
    if(mc is MovieClip) {
        trace("is MovieClip");
    } else if(mc is Sprite) {
        trace("is Sprite");
    }
    
    // even if mc is a MovieClip, your code will never get in the else block
    if(mc is Sprite) {
        trace("is Sprite");
    } else if(mc is MovieClip) {
        trace("is MovieClip");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 1 red polygon say and 50 randomly placed blue polygons - they
I have an enum public enum Color { Red = 0, Blue = 1,
I have a Red Hat Linux box that I did not configure but must
How, using Nth-Child could I add a class to every red box? alt text
i have put in a css box colored red and for some reason the
I have a Red Had Enterprise Linux 5 and a CentOS 5 box, both
No, not literally . Rather, do you have any red tape horror stories of
I have a big red button and I'm trying to use javascript to perform
I have a VB.NET form with a red background and white text. I want
I have an array apple color: red price: 2 orange color: orange price: 3

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.