instance1 ? where is my instance name

Posted on 2009-05-01
Last Modified: 2013-11-11

I am creating an instance of a symbol inside my movieclip at runtime.

I do it like this:

this.attachMovie( symbolName, symbolName + "_mc", this.getNextHighestDepth(), {_x:tx, _y:ty});      

In the symbol I have this code which handles the mouse wheel:

// mouse wheel handler

this.mouseListener = new Object ();

this.mouseListener.onMouseWheel = function (wheelnum:Number, target)

Mouse.addListener (this.mouseListener);

the line target.handle_wheel(wheelnum); is supposed to call the name of the instance on top of which the mouse is at the time the wheel is used.

this works well for objects placed on the stage, target is for example:


the problem begins when the symbol is attached at run time, I then get this value for target:


I was not able to get the correct name and write a handler function for it, I was not able to trigger the event function in any way.

what can be done ? why am I not getting the real instance name ?
Question by:moshem
    LVL 8

    Accepted Solution

    How are you attaching the symbol at runtime?

    You can still name your clip when you attach it at runtime. Here is an example which creates a new empty clip and then attaches a movie to it that is in the library and set up for exporting. It names the clip so you can reference it later.

    // create the clip that will hold the movie
    // ------------------------------------------------
    clip_name = "room_1";

    // then attach the movie to the clip by name
    // ----------------------------------------------------

    // ------- end of code

    Where "room" is the name you have given the movie in the the export setting.

    Now you can reference the object like this:

    LVL 1

    Author Comment

    well, I think the documentation says the first parameter is the export name and the second parameter is the instance name.

    that is exactly how I do it, except that I dont create an empty movieclip first, I just attach it to my main movieclip.

    I then reference it using this["instance name].gotoAndPlay and it works...

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Join & Write a Comment

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
    The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
    The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now