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 :
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:
**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.