# How to center resizable flash content with gallery

**URL:** <https://forum.kirupa.com/t/how-to-center-resizable-flash-content-with-gallery/317390>\
**Category:** flash\
**Created:** [December 18, 2010, 7:41pm UTC](https://forum.kirupa.com/t/how-to-center-resizable-flash-content-with-gallery/317390 "2010-12-18T19:41:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Klay](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@Klay](https://forum.kirupa.com/u/Klay)\
**Post date:** [December 18, 2010, 7:41pm UTC](https://forum.kirupa.com/t/how-to-center-resizable-flash-content-with-gallery/317390/1 "2010-12-18T19:41:48Z")

</div>

Hi there…

I’m trying to center my flash site horizontally to be resizable using actions, but I have a SimpleViewer gallery to load at some point on the timeline inside a movieclip. Everything is working without the gallery on stage… but when I jump to the frame point where it is loaded… the center alignment is gone like the gallery is overwriting it or something…

The centering action in the first frame:

[COLOR=DarkRed]var myStage:Stage = this.stage;  
myStage.scaleMode = StageScaleMode.NO\_SCALE;  
myStage.align = StageAlign.TOP;

function initialDisplay(event:Event):void{

```
var swfWidth:int = myStage.stageWidth;
var swfHeight:int = myStage.stageHeight;

var frameYPos:Number = swfHeight - frame.height;
var frameXPos:Number = swfWidth - frame.width;
var artgalXpos:Number = swfWidth - frame.width;

frame.y = frameYPos / 2;
frame.x = frameXPos / 2;

artgal.x = frameXPos / 2;

```

}

addEventListener(Event.ENTER\_FRAME, initialDisplay);[/COLOR]

artgal - stands for the movieclip inctance name and its centering the gallery , but than the background and everything else stays in place :S

Inside the artgal movieclip I load the gallery with a simpleviewer.swf like this:  
Maybe the problem is here? :S  
[COLOR=DarkRed]  
var svAPI:Object; //svAPI is the object to call API methods on  
var svLoader:Loader = new Loader();  
addChild(svLoader);  
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);  
svLoader.load(new URLRequest(“simpleviewer.swf”));

function onViewerInit(e:Event):void{  
var options:Object = Object(svLoader.content).embedOptions;  
options.galleryURL = “gallery1.xml”;  
}  
/\*\*

- Fired when gallery has completely loaded. API is now available.  
\*/  
function onGalleryLoaded(e:Event):void{  
svAPI = Object(svLoader.content).api;  
svAPI.setSize(640,480);  
}  
[/COLOR]

So how can I make the first code to work there too where I have the gallery?  
First Flash site attempt ever, so I’d love some help… ty 🙂
