# Define alias for object in code

**URL:** <https://forum.kirupa.com/t/define-alias-for-object-in-code/312821>\
**Category:** flash\
**Created:** [August 13, 2010, 11:06am UTC](https://forum.kirupa.com/t/define-alias-for-object-in-code/312821 "2010-08-13T11:06:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![McLucky](https://avatars.discourse-cdn.com/v4/letter/m/779978/32.png) [@McLucky](https://forum.kirupa.com/u/McLucky)\
**Post date:** [August 13, 2010, 11:06am UTC](https://forum.kirupa.com/t/define-alias-for-object-in-code/312821/1 "2010-08-13T11:06:39Z")

</div>

Hi,

Don’t know if alias is the right word here but I would like to replace a long target path with short variable to make my code more readable/managable.

So I have the following (working) code but it’s getting really complicated :

```auto
function scaleUp(e:Event)
{
    if(MovieClip(root).radioButton_01.selected){
        MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).width = MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).width * 1.01;
        MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).height = MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).height * 1.01;
    }
    if(MovieClip(root).radioButton_02.selected){
        MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).width = MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).width * 1.01;
        MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).height = MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).height * 1.01;
    }
}

function scaleDown(e:Event):void
{
    if(MovieClip(root).radioButton_01.selected){
        MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).width = MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).width * 0.99;
        MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).height = MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0).height * 0.99;
    }
    if(MovieClip(root).radioButton_02.selected){
        MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).width = MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).width * 0.99;
        MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).height = MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0).height * 0.99;
    }
}

```

Now I would like to do something like this to reduce the enormous code above to a shorter code:

```auto
**Var image_01:"data type ?"** = MovieClip(root).movieclip_01.imageLoader_01.getChildAt(0)
**Var image_02:"data type ?"** = MovieClip(root).movieclip_02.imageLoader_02.getChildAt(0)

function scaleUp(e:Event)
{
    if(MovieClip(root).radioButton_01.selected){
        **? image_01**.width = image_01.width * 1.01;
        **? "image_01"**.height = image_01.height * 1.01;
    }
    if(MovieClip(root).radioButton_02.selected){
        **? [image_02]**.width = image_02.width * 1.01;
        **? (image_02)**.height = image_02.height * 1.01;
    }
}

```

So how can I put this long object path (MovieClip(root)…) into a short variable. I can’t find anything on which datatype to use or how to use such a variable in the code.

Thanks in advance.
