0

I made a photo gallery, and I Use Flash cs5 As3 UILoader component,how can I load all different size photo in the center? The Uiloader component registration on the top left, I need make to to middle? stage 1000 px wide, 420px highth.

My photos are differents size, some are 803x400, some are 580x400, and the uiLoader registration point is on the top left, that is the problem, if I made the 580x400 in the middle, and the 803x400px phone will be far out to the right.

Is there any way to fix this problem?

[www.bradmarkel.net] click wildlife, you will understand what I mean.

Here is my gallery codes, thanks for your time!

import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.MouseEvent;
import flash.events.Event;
import fl.containers.UILoader;
import flash.text.TextField;
import flash.display.SimpleButton;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
stage.colorCorrection = ColorCorrection.ON;
var myImage:String = "smallNews/resized web news photos/00.jpg";
var request:URLRequest = new URLRequest(myImage);
uiLoader.addEventListener(Event.COMPLETE, completeHandler);
uiLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
uiLoader.load(request);

function progressHandler(event:ProgressEvent):void
 {

status_txt.text = "Percentage Loaded: " + Math.round(event.target.percentLoaded);
 }

function completeHandler(event:Event):void
{
var spr = new Sprite();

// Place spr anywhere on the stage
spr.x = stage.stageWidth / 6 - uiLoader.content.width / 6;
spr.y = stage.stageHeight / 235 - uiLoader.content.height / 235;
spr.addChild( uiLoader );

addChild( spr );

// Center uiLoader in spr
uiLoader.x =  -  uiLoader.width / 500;
uiLoader.y =  -  uiLoader.height / 235;
new Tween(spr,"rotationX",Elastic.easeOut,45,0,4,true);
 }
 next_btn.addEventListener(MouseEvent.CLICK, nextImage);

 //variable is a container that holds some value...;
 var imageNumber:Number = 0;

 function checkNumber():void
 {
next_btn.visible = true;
back_btn.visible = true;
//If the imageNumber is = 47, then do something...
if (imageNumber == 24)
{
    trace(imageNumber);
    next_btn.visible = false;
}
//if the imageNumber is = 1, then don't show the back button
if (imageNumber == 0)
{
    trace(imageNumber);
        back_btn.visible = false;
}
      }
      checkNumber();

      function nextImage(evtObj:MouseEvent):void
      {
//Adding to the current value +1
imageNumber++;
uiLoader.source = "smallNews/resized web news photos/0" + imageNumber + ".jpg";
checkNumber();
      }

      back_btn.addEventListener(MouseEvent.CLICK, backImage);

      function backImage(evtObj:MouseEvent):void
      {
//Subtract 1 from the current value
imageNumber--;
uiLoader.source = "smallNews/resized web news photos/0" + imageNumber + ".jpg";
checkNumber();
       }

      stop();
Lily Mm
  • 7
  • 6

1 Answers1

0

You have to arrange uiloader in the center of its container, if I understood do something like this:

function completeHandler(event:Event):void
{
var spr = new Sprite();

// Place spr anywhere on the stage
spr.x = stage.stageWidth / 6;
spr.y = stage.stageHeight / 235;
spr.addChild( uiLoader );

addChild( spr );

// Center uiLoader in spr
uiLoader.x =  -  uiLoader.content.width / 2;
uiLoader.y =  -  uiLoader.content.height / 2;
new Tween(spr,"rotationX",Elastic.easeOut,45,0,4,true);
 }
Serge Him
  • 936
  • 6
  • 8
  • @516, I still have center those photos problems, your codes is help me move the photos around, but my gallery have three kinds size photos, and I need uiLoader load photos in center, so I can use your code more in the right place, do you have any idea how to do this? Right now the registration is on the top left, and how can move it to the middle? Thanks! – Lily Mm Feb 07 '13 at 22:40
  • I still have center those photos problems, your codes is help me move the photos around, but my gallery have three kinds size photos, and I need uiLoader load photos in center, so I can use your code more in the right place, do you have any idea how to do this? Right now the registration is on the top left, and how can move it to the middle? Thanks! – Lily Mm Feb 08 '13 at 18:02
  • You can arrange your uiloader relative to any container, stage was as an example. – Serge Him Feb 11 '13 at 07:06
  • Do you know how to do it? I really need help with this, I work many days with this code, try make it work. please give me little bit more ditails. – Lily Mm Feb 12 '13 at 02:54
  • You need update your question and give more code where you arrange uiloader and what do you exactly mean, I dont understand the problem – Serge Him Feb 12 '13 at 08:06
  • I update my question, I hope you undertand it better, so please help. – Lily Mm Feb 12 '13 at 17:28
  • If you need center uiLoader in your spr container, I gave you result. spr has to be placed at fixed position. – Serge Him Feb 13 '13 at 07:43