• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

instance1 ? where is my instance name


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 ?
1 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:

moshemAuthor Commented:
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now