# XML photogallery help

**URL:** <https://forum.kirupa.com/t/xml-photogallery-help/262397>\
**Category:** Uncategorized\
**Created:** [June 5, 2008, 4:38pm UTC](https://forum.kirupa.com/t/xml-photogallery-help/262397 "2008-06-05T16:38:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rich\_Selavy](https://avatars.discourse-cdn.com/v4/letter/r/aca169/32.png) [@Rich\_Selavy](https://forum.kirupa.com/u/Rich_Selavy)\
**Post date:** [June 5, 2008, 4:38pm UTC](https://forum.kirupa.com/t/xml-photogallery-help/262397/1 "2008-06-05T16:38:12Z")

</div>

(also sorry about double posting)

So I’m trying to make an xml photogallery.

I made a separate AS file that I’m referencing in the time line to call up and display the xml info.

on my AS file (which I’ve saved as "GALLERYscript.as) i have:

```auto
package {
    public class Test {
        
    }
}
    import flash.display.Sprite;
    import flash.display.SimpleButton;
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    
    public class Main extends Sprite
    {
        protected var _data:XML;
        protected var _images:Array;
        
        public function Main():void
        {
            init();
        }
        
        protected function init():void
        {
            var urlLoader:URLLoader = new URLLoader();
            urlLoader.addEventListener(Event.COMPLETE, dataLoaded, false, 0, true);
            urlLoader.load(new URLRequest("images.xml"));
        }
        
        protected function dataLoaded(e:Event):void
        {
            _data = new XML(e.currentTarget.data);
            _images = new Array(_data.photo.length());
            
            build();
        }
        
        protected function build():void
        {
            previous_btn.addEventListener(MouseEvent.CLICK, traverseImage, false, 0, true);
            next_btn.addEventListener(MouseEvent.CLICK, traverseImage, false, 0, true);
            
            loadImage(0);
        }
        
        protected function loadImage( index:int ):void
        {
            if (_images[index])
            {
                replaceImage(_images[index]);
                return;
            } else
            {
                var loader:Loader = new Loader();
                loader.load(new URLRequest(_data.photo[index].img));
                _images[index] = loader;
                replaceImage(loader);
            }
        }
        
        protected function replaceImage( obj:DisplayObject ):void
        {
            while(picture_mc.numChildren) picture_mc.removeChildAt(0);
            
            picture_mc.addChild(obj);
        }
        
        protected function traverseImage(e:MouseEvent):void
        {
            var index:int = _images.indexOf(container_mc.getChildAt(0));
            
            if (e.currentTarget == previous_btn) index--;
            else if (e.currentTarget == next_btn) index++;
            
            index %= _images.length;
            if (index < 0) index = _images.length - 1;
            
            loadImage(index);
        }
}

```

and in my timeline i have:

```auto

import GALLERYscript;

var obj:GALLERYscript;

obj = new GALLERYscript();

obj.identify();

```

When I export my movie though I’m getting the error:

> 1114: The public attribute can only be used inside a package.
