private function loadImage(imageID:String):void{
            var gallery:XML = XML(_xml.gallery.(@id == currentGallery));
            var image:XML = XML(gallery.image.(@imageID == imageID));

            if(ima...@bordersize == undefined){ima...@bordersize = "0";}

            Gallery.getInstance().imageInfo._title.text = ima...@title;
            Gallery.getInstance().imageInfo._description.text =
ima...@description;

            imageLoader = new Loader();
            imageLoader.contentLoaderInfo.addEventListener(Event.INIT,
onImageLoad);

            imageLoader.load(new URLRequest(galle...@folder + "/" +
ima...@src));

            function onImageLoad(e:Event):void{
                addEventListener(Event.ENTER_FRAME, positionImage);
            }

            function positionImage(e:Event):void{
                //imageLoader.x = -(imageLoader.width/2);
                //imageLoader.y = -(imageLoader.height/2);

                mainImage.border.width = imageLoader.width;
                mainImage.border.height = imageLoader.height;

                var borderWidth:Number = imageLoader.width +
(Number(ima...@bordersize)*2);
                var borderHeight:Number = imageLoader.height +
(Number(ima...@bordersize)*2);

                //mainImage.border.width = borderWidth;
                //mainImage.border.height = borderHeight;
                //mainImage.border.x = -(borderWidth/2);
                //mainImage.border.y = -(borderHeight/2);

                var tweenX:Tween = new Tween(mainImage.border, "x",
Regular.easeOut, mainImage.border.x, -(borderWidth/2), 1, true);
                var tweenY:Tween = new Tween(mainImage.border, "y",
Regular.easeOut, mainImage.border.y, -(borderHeight/2), 1, true);
                var tweenWidth:Tween = new Tween(mainImage.border, "width",
Regular.easeOut, mainImage.border.width, borderWidth, 1, true);
                var tweenHeight:Tween = new Tween(mainImage.border,
"height", Regular.easeOut, mainImage.border.height, borderHeight, 1, true);

                //TweenLite.to(mainImage.border, 1, {x:-(borderWidth/2),
y:-(borderHeight/2), width: borderWidth, height: borderHeight,
ease:Circ.easeIn});
                //mainImage.addChild(imageLoader);
            }

            currentImage = imageID;

        }

Okay, so here is the problem...

Using the Loader class totally screws up tweening for the width and height
properties of anything... the width/height props are coming back fine from
the event, my border MC will even position itself right if i don't tween it,
but as soon as I try to tween it, it jumps to the end value right away
(doesn't matter what tween class I use, TweenLight, or even the built in
Tween class)...

If you manually set borderWidth and borderHeight before the event handler
and try to tween it that way, it works 100% okay...

I really can't figure this out, this is the weirdest friggin' bug I have
experienced in the last year.

Any pointers?

Thanks!

- Taka
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to