0

I want to load a lot of photos use UILoader component, and I have to change the registration point, so how can I do that? It's there any code for that?

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 = "smallWildlife/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
{   
uiLoader.x = stage.stageWidth/6 - uiLoader.content.width/6;
uiLoader.y = stage.stageHeight/100 - uiLoader.content.height/700;
new Tween(uiLoader,"rotationX",Elastic.easeOut,90,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 = 58, then do something...
if (imageNumber == 58)
{
    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 = "smallWildlife/0" + imageNumber + ".jpg";
checkNumber();
}

back_btn.addEventListener(MouseEvent.CLICK, backImage);

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

stop();

Please help me! I need make my gallery phose in the center.

Lily Mm
  • 7
  • 6
  • There is no code to change the registration point. Just do what you do in your example code - shift x and y position by half the width/height - but center iuLoader inside a Sprite and rotate the sprite not uiLoader –  Feb 03 '13 at 02:26

1 Answers1

0

First, drag a UILoader component to the stage; then name it "uiLoader".

package {

    import fl.containers.*;
    import fl.transitions.*;
    import fl.transitions.easing.*;
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;

    public class Main extends Sprite {

    private var spr:Sprite;

    // Your URL here
    private var url:String = "http://joanmiro.com/wp-content/uploads/2009/05/joanmiro1.jpg";

    public function
    Main() {
        var request:URLRequest = new URLRequest( url );

        uiLoader.addEventListener( Event.COMPLETE, completeHandler );
        uiLoader.load( request );

        spr = new Sprite();

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

        addChild( spr );
    }

    private function
    completeHandler( e:Event ):void {
        // Center uiLoader in spr
        uiLoader.x = - uiLoader.width / 2;
        uiLoader.y = - uiLoader.height / 2;
        new Tween( spr, "rotation", Elastic.easeOut, 1080, 0, 12, true );
    }
    }
}
khailcs
  • 328
  • 1
  • 9
  • It's AS3. You can place the Sprite spr anywhere, the important thing is you center uiLoader in spr. – khailcs Feb 07 '13 at 20:13
  • I there is a URLoader, I don't have URLoader, and I try put in with my code, give alot errors. Packge is the problems. – Lily Mm Feb 07 '13 at 21:54
  • There is a UILoader instance I dragged to the stage ( I use flash CS5 ). If you don't have UILoader you can use Loader class instead of UILoader but declare and add it to the stage in Main. – khailcs Feb 07 '13 at 22:01
  • I use Cs5 too, and I did name the UILoader to uiLoader. bradmarkel.net and I working with wildlife gallery now. – Lily Mm Feb 07 '13 at 22:07
  • Error 1083 is "else is unexpected". It must come from somewhere else in your code. Could you post it? – khailcs Feb 07 '13 at 22:57
  • You mean Main, my gallery is not on the Main. "packge is unexpected". – Lily Mm Feb 07 '13 at 23:25