AS3 _targetInstanceName equivalent is scrollTargetName
Back in the MX2004 day we could use the _xch clip in the Flash IDE to help us determine the name of any asset we dropped our component onto. Excessive Googling hasn’t turned up anything useful so, dear reader, this is for you.
In the CS4 library, select your component clip, right-click and choose ‘Component Definition‘. Add a parameter called scrollTargetName, give it a variable name of ‘scrollTargetName‘. In your component class, ensure you have getters and setters for ‘scrollTargetName‘ and for ‘scrollTarget‘, like this:
Now update your component by selecting ‘Component Definition’ again, but this time just clik ‘OK‘ to force the update.
Now place a TextField or MovieClip onstage and give it an instance name, then drag your updated component from the library onto the test clip. If you check the Component Parameters panel you should see that it’s automagically populated with the instance name of your example clip, just like _targetInstanceName used to. Dragging it onto other named instances should also update the parameter in the panel. Dragging your component onto an unnamed instance forces a default instance name, couldn’t be sweeter!
I also implemented some functionality that (via the SWFPanel of my component) auto-positions the dropped component instance at the top-left of its’ target instance. Let me know in the comments if you want to see how this is done.











Awesome to find this – I’ve been searching for this functionality for some time.
It would be phenomenal to see an implementation that auto-positions itself to the dropped component.
Thanks so much for this article!
Jason Sturges