# \[Flash 8\] Dynamic Instance Names

**URL:** <https://forum.kirupa.com/t/flash-8-dynamic-instance-names/224795>\
**Category:** flash\
**Created:** [May 5, 2007, 5:13pm UTC](https://forum.kirupa.com/t/flash-8-dynamic-instance-names/224795 "2007-05-05T17:13:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shapirotechnics](https://avatars.discourse-cdn.com/v4/letter/s/49beb7/32.png) [@Shapirotechnics](https://forum.kirupa.com/u/Shapirotechnics)\
**Post date:** [May 5, 2007, 5:13pm UTC](https://forum.kirupa.com/t/flash-8-dynamic-instance-names/224795/1 "2007-05-05T17:13:54Z")

</div>

Hi, I am doing a school project (a timeline) involving 5 individual timelines (“soc\_time”, “tech\_time”, “env\_time”, “eco\_time”, “pol\_time”) on a single, main timeline (“timeline”) that moves with the left and right cursor keys. “Timeline” has lines at 200 pixel intervals for reference (10 years = 200 pixels). There are 5 thumbnails at the bottom (“soc\_thumb”, “tech\_thumb”, etc.) and when you click on one, it makes the sub-timeline (“soc\_time”, “tech\_time”, etc) appear using timeline.attachMovie (i.e. when you click on “society” at the bottom the society timeline (“soc\_time”) appears on the main timeline). Inside each sub-timeline (“soc\_time”, etc.) there are dates (“soc\_1900”, “soc\_1904”, etc) (no attachMovie involved here, they are already in the sub-timeline). When you click on these dates, a window pops up with more information on that date (“win\_soc\_1900”, etc)

What I need to do is simplify/cleanup my code, because now it is over 750 lines, and I know there is a way to make it shorter. Ultimately, my best idea involves writing a function that takes “soc\_1900”'s, “soc\_1904”'s, etc.'s \_x position relative to the sub-timeline it is nested in (“soc\_time”). I want to take the \_x positions, divide by 20 and add 1900 which would give me the date it is.

What I have now is this:

```auto

_root.onMouseDown = function() {
        if (timeline.soc_time.soc_1900.hitTest(_xmouse, _ymouse, true) && !window_soc_1900) {
            _root.attachMovie("_win_soc_1900", "win_soc_1900", 101);
            window_soc_1900 = true;
            setProperty(win_soc_1900, _x, 85);
            setProperty(win_soc_1900, _y, 95);
            setProperty(this, _alpha, 80);
        }
        if (timeline.soc_time.soc_1913.hitTest(_xmouse, _ymouse, true) && !window_soc_1913) {
            _root.attachMovie("_win_soc_1913", "win_soc_1913", 102);
            window_soc_1913 = true;
            setProperty(win_soc_1913, _x, 85);
            setProperty(win_soc_1913, _y, 95);
            setProperty(this, _alpha, 80);
        }
};
//ad infinitum

```

As I said, this works fine, but what I want to do is something like this:

```auto

var windows:Boolean = false;
function socClick() {
    if (this.hitTest(_xmouse, _ymouse, true) && !windows) {
        _root.attachMovie("_win_soc"+this._x/20+1900, "win_soc_"+this._x/20+1900, getNextHighestDepth());
        windows = true;
        setProperty("win_soc_"+this._x/20+1900, _x, 85);
        setProperty("win_soc_"+this._x/20+1900, _y, 95);
        setProperty("win_soc_"+this._x/20+1900, _alpha, 80);

    }
};
_root.soc_1900.onMouseDown=socClick();

```

I just can’t get this to work, hence this thread.

Working on uploading an swf.
