# Relative positioning external loaded elements

**URL:** <https://forum.kirupa.com/t/relative-positioning-external-loaded-elements/246099>\
**Category:** flash\
**Created:** [December 7, 2007, 1:01am UTC](https://forum.kirupa.com/t/relative-positioning-external-loaded-elements/246099 "2007-12-07T01:01:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tezzutezzu](https://avatars.discourse-cdn.com/v4/letter/t/df705f/32.png) [@tezzutezzu](https://forum.kirupa.com/u/tezzutezzu)\
**Post date:** [December 7, 2007, 1:01am UTC](https://forum.kirupa.com/t/relative-positioning-external-loaded-elements/246099/1 "2007-12-07T01:01:52Z")

</div>

I’m trying positioning external loaded images from an XML and position them according to the stage dimensions.  
Here’s what I’ve come so far: creating a loader for each image and then position them according to their size.  
Is there any way to do this avoiding to create a multidimensional array (that’s to say two arrays one for the images name and one for the loaders)?

```auto

private function loadBg():void {
            for each (var image:XML in xml.BG..IMG) {
                var loader:Loader = new Loader();
                loader.load(new URLRequest(image.@url));
                loader.addEventListener(Event.COMPLETE, positionBg);
                addChild(loader);
            }
        }
        
        private function positionBg(e:Event):void {
            .....
            switch (?????) {
                    case "bg_br.jpg":
                    loader.x=stage.stageWidth-loader.width;
                    loader.y= stage.stageHeight-loader.height;
                    break;
                    case "bg_bl.jpg":
                    loader.x=stage.stageWidth-loader.width;
                    loader.y= stage.stageHeight-loader.height;
                    break;
                    case "bg_tr.jpg":
                    loader.x=stage.stageWidth-loader.width;
                    loader.y= 0;
                    break;
                }
            ......
        }

```
