Topic: Embed position and scale in flash

I have bought Tiltviewer pro and redid my page in Flash as3. I have also managed to embed Tiltviewer and see images. However I have a few questions regarding how to make it fit in place.

I need to be able to move it around and scale. My page is created in such a way, that it itself dosnt rescale, but it is always in the center with a table in the index.html.

I have tried to play around with the code from the examples. When I cancel out;
 
    //example background resizing code
         -->//stage.addEventListener(Event.RESIZE,onResize);
         --->//onResize(null);
I made the background stay in place, and now I need to find a way to make the images load in the same place. Right now, they load out of place and scale according to the browser.
After some time searching I found this code in the forum, it reminds of my problem of fitting and scaling the tiltveiwer in Flash:

stage.addEventListener(Event.ENTER_FRAME,resizeTiltViewer);
function resizeTiltViewer(e:Event){       
    //example tiltViewer size and position values
    var tvWidth = stage.stageWidth/2;
    var tvHeight = stage.stageHeight/2;
    var tvX = stage.stageWidth/4;
    var tvY = stage.stageHeight/4;       
    ldr.x = tvX;
    ldr.y = tvY;
    var tiltviewer = Object(ldr.content)._app;
    if ( tiltviewer != null){
        tiltviewer.autoSize = false;
        tiltviewer.setSize(tvWidth,tvHeight);
}
And I have tried out the advise in this thread aswell, but without any result http://www.simpleviewer.net/forum/viewtopic.php?id=8680
Please help

Re: Embed position and scale in flash

Are you loading TiltViewer into a fixed size SWF? If so it should be easy. Load the Tiltviewer SWF into your container SWF as per the flash embed example. You will not need any code for resizing or re-positioning.

Felix Turner
SimpleViewer Support Team.

Re: Embed position and scale in flash

Yes, i think thats what im after. Something similar to the actionscript2 code

this.createEmptyMovieClip("container",1);
container._x =563;
container._y =137;
and
unloadMovie("container");



Here is my code as whole:
stop();

import flash.display.*;
import flash.net.URLRequest;

//turn off stage auto resizing
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_RIGHT;       

stage.addEventListener(Event.ENTER_FRAME,resizeTiltViewer);
function resizeTiltViewer(e:Event){       
    //example tiltViewer size and position values
    var tvWidth = stage.stageWidth/2;
    var tvHeight = stage.stageHeight/2;
    var tvX = stage.stageWidth/4;
    var tvY = stage.stageHeight/4;       
    ldr.x = tvX;
    ldr.y = tvY;
    var tiltviewer = Object(ldr.content)._app;
    if ( tiltviewer != null){
        tiltviewer.autoSize = false;
        tiltviewer.setSize(tvWidth,tvHeight);
}

var ldr:Loader = new Loader();
mcLoader.addChild(ldr);
ldr.contentLoaderInfo.addEventListener(Event.INIT, setOptions);
var url:String = "TiltViewer.swf";
var urlReq:URLRequest = new URLRequest(url);
var optionsId:Number = 1;

//example buttons to switch between galleries
mcButton1.addEventListener(MouseEvent.CLICK,onClick1);
function onClick1(e:Event){
    optionsId = 1;
    loadGallery();
}
mcButton2.addEventListener(MouseEvent.CLICK,onClick2);
function onClick2(e:Event){
    optionsId = 2;
    loadGallery();
}
   
function loadGallery(){
    //unload last tiltviewer
    if  (Object(ldr.content)._app != null){
        Object(ldr.content)._app.kill();
        ldr.unload();
    }
    //load new tiltviewer
    ldr.load(urlReq);
}

//SET TILTVIEWER OPTIONS
function setOptions(e:Event){   
    var options:Object = Object(ldr.content).embedOptions;
   
    if (optionsId == 1){       
        //Set example options here
        options.columns = 3;
        options.rows = 2;   
        options.useReloadButton = false;
        options.bkgndTransparent = true;
        options.useFlickr = false;
        options.xmlURL = "gallery.xml";
        options.maxJPGSize = 640;
    }else if (optionsId == 2){
        //Set example options here
        options.columns = 4;
        options.rows = 3;   
        options.useReloadButton = true;
        options.bkgndTransparent = true;
        options.useFlickr = false;
        options.xmlURL = "gallery.xml";
        options.maxJPGSize = 640;
        options.frameColor = 0xFFFFFF;   
    }
}

//example background resizing code
stage.addEventListener(Event.RESIZE,onResize);
onResize(null);
//called on stage resize
function onResize(e:Event){   
    mcBkgnd.width = stage.stageWidth;
    mcBkgnd.height = stage.stageHeight;
    }
}


The code, that i posted in the first thread, is one I have implementet myself after finding it here http://www.simpleviewer.net/forum/viewt … p?id=11217
However, it wont load the images. So Im not sure if Im in the right direction.

Re: Embed position and scale in flash

The flash embed example code should work fine with a fixed size container SWF. What issue are you having?

Felix Turner
SimpleViewer Support Team.

Re: Embed position and scale in flash

U mean loading in the Tiltviewer.swf in a container?
I can load .swf into containers with as2, as postet earlier, but I dont know the code for duing it in as3, and I wouldnt know where to add it between the code from the embed example code to make it work .

All in all what I want is to be able to load Tiltviewer in a size of 550 x 400 pixels, in the middle of my 900x1200 px webpage.