# Problem with attachMovie and scrollBar

**URL:** <https://forum.kirupa.com/t/problem-with-attachmovie-and-scrollbar/210871>\
**Category:** flash\
**Created:** [December 23, 2006, 2:53am UTC](https://forum.kirupa.com/t/problem-with-attachmovie-and-scrollbar/210871 "2006-12-23T02:53:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbailey](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/jbailey/32/2380_2.png) [@jbailey](https://forum.kirupa.com/u/jbailey)\
**Post date:** [December 23, 2006, 2:53am UTC](https://forum.kirupa.com/t/problem-with-attachmovie-and-scrollbar/210871/1 "2006-12-23T02:53:35Z")

</div>

I am trying to attach the scrollBar component that ships with F7/+. I can use this  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000ff]this[/COLOR].[COLOR=#0000ff]attachMovie[/COLOR]COLOR=#000000[/COLOR];  
[/LEFT]  
[/FONT]

and that works fine. However, if I do the below script it doesn’t work. Why?

```
 ActionScript Code:
 [FONT=Courier New][LEFT][COLOR=#000000] **function** [/COLOR] initializeElements[COLOR=#000000]([/COLOR]g[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
[COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR][COLOR=#0000ff]loaded[/COLOR] == filesize[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
    [COLOR=#0000ff]if[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]width[/COLOR][COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR] == [COLOR=#ff0000]"lastChild"[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
        [COLOR=#808080]*//note to user*[/COLOR]
    [COLOR=#000000]}[/COLOR]
    [COLOR=#0000ff]else[/COLOR][COLOR=#000000]{[/COLOR]
        holder.[COLOR=#0000ff]createEmptyMovieClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"box"[/COLOR]+g, holder.[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
        tlistener = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]Object[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
        tlistener.[COLOR=#0000ff]onLoadInit[/COLOR] = [COLOR=#000000] **function** [/COLOR][COLOR=#000000]([/COLOR]target_mc[COLOR=#000000])[/COLOR] [COLOR=#000000]{[/COLOR]
            target_mc.[COLOR=#000080]pictureValue[/COLOR] = g;
            target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_width[/COLOR] = [COLOR=#0000ff]width[/COLOR][COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
            target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_height[/COLOR] = [COLOR=#0000ff]height[/COLOR][COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
            target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_x[/COLOR] = xloc[COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
            target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_y[/COLOR] = yloc[COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
            target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]htmlText[/COLOR] = dytext[COLOR=#000000][[/COLOR]g[COLOR=#000000]][/COLOR];
            target_mc.[COLOR=#000080]isDropShadow[/COLOR] = [COLOR=#000000] **true** [/COLOR];
            target_mc.[COLOR=#000080]holder[/COLOR].[COLOR=#0000ff]_x[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_x[/COLOR] + target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_width[/COLOR];
            target_mc.[COLOR=#000080]holder[/COLOR].[COLOR=#0000ff]_y[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_y[/COLOR] + target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_height[/COLOR];
            target_mc.[COLOR=#000080]draggerShell[/COLOR].[COLOR=#0000ff]_x[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_x[/COLOR] + target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_width[/COLOR];
            target_mc.[COLOR=#000080]draggerShell[/COLOR].[COLOR=#0000ff]_y[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_y[/COLOR] + target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_height[/COLOR];
            target_mc.[COLOR=#000080]imageMover1[/COLOR].[COLOR=#0000ff]_x[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_x[/COLOR] - [COLOR=#000080]2[/COLOR];
            target_mc.[COLOR=#000080]imageMover1[/COLOR].[COLOR=#0000ff]_y[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_y[/COLOR] - [COLOR=#000080]2[/COLOR];
            target_mc.[COLOR=#000080]imageMover1[/COLOR].[COLOR=#0000ff]_width[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_width[/COLOR] + target_mc.[COLOR=#000080]draggerShell[/COLOR].[COLOR=#0000ff]_width[/COLOR] + [COLOR=#000080]4[/COLOR];
            target_mc.[COLOR=#000080]imageMover1[/COLOR].[COLOR=#0000ff]_height[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_height[/COLOR] + target_mc.[COLOR=#000080]draggerShell[/COLOR].[COLOR=#0000ff]_height[/COLOR] + [COLOR=#000080]4[/COLOR];
            target_mc.[COLOR=#000080]hit_image1[/COLOR].[COLOR=#0000ff]_x[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR]._x-[COLOR=#000080]2[/COLOR];
            target_mc.[COLOR=#000080]hit_image1[/COLOR].[COLOR=#0000ff]_y[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR]._y-[COLOR=#000080]2[/COLOR];
            target_mc.[COLOR=#000080]hit_image1[/COLOR].[COLOR=#0000ff]_width[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_width[/COLOR]+[COLOR=#000080]4[/COLOR];
            target_mc.[COLOR=#000080]hit_image1[/COLOR].[COLOR=#0000ff]_height[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_height[/COLOR]+[COLOR=#000080]4[/COLOR];
            target_mc.[COLOR=#000080]over_image1[/COLOR].[COLOR=#0000ff]_x[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR]._x-[COLOR=#000080]2[/COLOR];
            target_mc.[COLOR=#000080]over_image1[/COLOR].[COLOR=#0000ff]_y[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR]._y-[COLOR=#000080]2[/COLOR];
            target_mc.[COLOR=#000080]over_image1[/COLOR].[COLOR=#0000ff]_width[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_width[/COLOR]+[COLOR=#000080]4[/COLOR];
            target_mc.[COLOR=#000080]over_image1[/COLOR].[COLOR=#0000ff]_height[/COLOR] = target_mc.[COLOR=#000080]box[/COLOR].[COLOR=#0000ff]_height[/COLOR]+[COLOR=#000080]4[/COLOR];
            target_mc.[COLOR=#0000ff]attachMovie[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"UIScrollBar"[/COLOR],[COLOR=#ff0000]"scrollBarMC"[/COLOR],target_mc.[COLOR=#0000ff]getNextHighestDepth[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000])[/COLOR];
            [COLOR=#000000]}[/COLOR]
            [COLOR=#0000ff]if[/COLOR] [COLOR=#000000]([/COLOR]g&lt;width.[COLOR=#000080]length[/COLOR]-[COLOR=#000080]1[/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]{[/COLOR]
                g++;
                initializeElements[COLOR=#000000]([/COLOR]g[COLOR=#000000])[/COLOR];
            [COLOR=#000000]}[/COLOR]
            [COLOR=#0000ff]else[/COLOR][COLOR=#000000]{[/COLOR][COLOR=#000000]}[/COLOR]
        [COLOR=#000000]}[/COLOR]
    text_mcl = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000ff]MovieClipLoader[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
    text_mcl.[COLOR=#0000ff]addListener[/COLOR][COLOR=#000000]([/COLOR]tlistener[COLOR=#000000])[/COLOR];
    text_mcl.[COLOR=#0000ff]loadClip[/COLOR][COLOR=#000000]([/COLOR][COLOR=#ff0000]"boxText.swf?uniqueID="[/COLOR]+[COLOR=#0000ff]getTimer[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR],[COLOR=#ff0000]"holder.box"[/COLOR]+g[COLOR=#000000])[/COLOR];
    [COLOR=#000000]}[/COLOR]
[COLOR=#000000]}[/COLOR]

```

[COLOR=#000000]}[/COLOR]  
[/LEFT]  
[/FONT]

Everything works fine, except the attaching of the scrollBar. Like I said, it works if i just do the this but when i use target\_mc it doesn’t work.
