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

instance1 ? where is my instance name

Hi,

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)
{
      target.handle_wheel(wheelnum);
      
      scroll_mc();
};

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:

_level0.courses_mc.scrlContent9

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

_level0.instance1.instance2


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 ?
0
moshem
Asked:
moshem
1 Solution
 
section25Commented:
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
// ------------------------------------------------
depth=this.getNextHighestDepth();
clip_name = "room_1";
_root.createEmptyMovieClip(clip_name,depth);

// then attach the movie to the clip by name
// ----------------------------------------------------
_root[clip_name].attachMovie("myRoom","room",0);


// ------- 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:
_root.room_1.myRoom(wheel_num);

0
 
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...
0

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