Topic: Center a gallery on Flash
Please help, i've follow Felix's advice to review the FLA included in the examples but still cant figure out how to make the gallery appear in the center of the screen
this is how far i've gotten with the code.
/**
* Fired when preloader is available
* Can set gallery flashvars at this point
*/
function onViewerInit(e:Event):void{
Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);
var options:Object = Object(svLoader.content).embedOptions;
options.galleryURL = "gallery-mtk.xml";
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
//add svLoader to the "mcLoader" stage movieclip on the main timeline
mcLoader.addChild(svLoader);
//listen for SWF loaded
svLoader.contentLoaderInfo.addEventListener(Event.INIT, onViewerInit);
function resizeHandler(e:Event):void
{
svLoader.x = (svLoader.stage.stageWidth / 2) - (svLoader.width / 2);
svLoader.y = (svLoader.stage.stageHeight / 2) - (svLoader.height / 2);
}}
//example resizing code
stage.addEventListener(Event.RESIZE,onResize);
onResize(null);
//called on stage resize
function onResize(e:Event){
//strecth bkgnd to match stage dimensions
MC.width = stage.stageWidth;
MC.height = stage.stageHeight;
//resize mcLoader
mcLoader.width = stage.stageWidth;
mcLoader.height = stage.stageHeight;
}
/**
* Fired when gallery has completely loaded. API is now available.
*/
function onGalleryLoaded(e:Event):void{
svAPI = Object(svLoader.content).api;
svAPI.setSize(800,600);
}
OR this one
* Fired when preloader is available
* Can set gallery flashvars at this point
*/
function onViewerInit(e:Event):void{
Object(svLoader.content).addEventListener("svComplete", onGalleryLoaded);
var options:Object = Object(svLoader.content).embedOptions;
options.galleryURL = "gallery-mtk.xml";
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
function resizeHandler(e:Event):void
{
mcLoader.x = (mcLoader.stage.stageWidth / 2) - (mcLoader.width / 2);
mcLoader.y = (mcLoader.stage.stageHeight / 2) - (mcLoader.height / 2);
}
}
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.addEventListener(Event.RESIZE,onResize);
stage.dispatchEvent(new Event(Event.RESIZE));
//example resizing code
stage.addEventListener(Event.RESIZE,onResize);
onResize(null);
//called on stage resize
function onResize(e:Event){
//resize mcFrame insude mcLoader
mcLoader.width = 800;
mcLoader.height = 600;
//resize SV to match frame size
if (svAPI != null ) svAPI.setSize(mcLoader.MC.width,mcLoader.MC.height);
}
/**
* Fired when gallery has completely loaded. API is now available.
*/
function onGalleryLoaded(e:Event):void{
svAPI = Object(svLoader.content).api;
svAPI.setSize(800,600);
}
Please HELP