All display objects have registration points (their internal 0,0
coordinates). Also bitmaps.

By default a loaded image (png) has its registration point in the
top-left corner. If you like to get rid of the improperly set
registration point then you may place the loaded image into a parent
container and align the image centrally inside its parent:

 stage -> parent_container -> your_image

You can do this by creating a new Sprite (or MovieClip) in the
Event.COMPLETE handler:

  function loaded(evt:Event):void
  {
           //create the parent
           var parent_container:Sprite = new Sprite();
           // ...and add it to the stage
           addChild(parent_container)
  
           var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
           var displayObject:DisplayObject = loaderInfo.content;
           displayObject.width = 150;
           displayObject.height = 150;

           // instead, move the parent
           //displayObject.x = 1000;
           //displayObject.y = 208;
           parent_container.x = 1000;
           parent_container.y = 208;

           //note that the displayObject is added to parent_container
           parent_container.addChild(displayObject);

           // now, place the displayObject's center over its parent
           // (0,0) point, by moving half width and half height in
           // top-left direction
           displayObject.x = -displayObject.width / 2;
           displayObject.y = -displayObject.height / 2;

           // see what you get:
           trace('parent_container.x: ' + parent_container.x);
           trace('parent_container.y: ' + parent_container.y);
           trace('displayObject.x: ' + displayObject.x);
           trace('displayObject.y: ' + displayObject.y);

           //..
           
           //.. continue with tween etc. but (!) perform all operations on
           // the parent container:
           parent_container.alpha = 0;
           TweenLite.to(parent_container, 1, {x:65, y:117, scaleX:0.5,
           scaleY:0.5, rotation:520, alpha:1});
 }

g


Tuesday, February 09, 2010 (12:55:49 PM) beno- wrote:

> Hi;
> I have this code:

> package
> {
>    import flash.events.Event;
>    import flash.events.ProgressEvent;
>    import flash.events.Event;
>    import flash.events.MouseEvent;
>    import flash.display.MovieClip;
> import flash.display.Loader;
> import flash.display.LoaderInfo;
> import flash.display.DisplayObject;
> import flash.net.URLRequest;
> import flash.display.Shape;
> import flash.geom.*;
> import flash.display.Bitmap;
> import flash.display.BitmapData;
> import flash.filters.GlowFilter;
> import flash.filters.BitmapFilterQuality;
> import flash.geom.Rectangle;
> import com.greensock.*;
>    import com.greensock.easing.*;
> import SpinningWorld;
>  public class GlobalSolutions extends MovieClip
>    {
>       //Import Library Assests
> public var mySpinningWorld:SpinningWorld;
> public var radius:int = 500;
> public var textureMap:BitmapData;
> public var myLogo:Bitmap;
>       public function GlobalSolutions()
>       {
>          init();
>       }

>       public function init():void
>       {
> mySpinningWorld = new SpinningWorld();
> mySpinningWorld.x = -500;
> mySpinningWorld.y = -500;
> mySpinningWorld.alpha = 0;
> addChild(mySpinningWorld);
> TweenLite.to(mySpinningWorld, 1, {x:-100, y:0, scaleX:0.4, scaleY:0.4,
> alpha:1});
> loadImage();
> }

> private function loadImage():void
> {
> var path:String = "images/logo.png";
> var req:URLRequest = new URLRequest(path);
> var loader:Loader = new Loader();
> loader.load(req);
> loader.contentLoaderInfo.addEventListener(Event.COMPLETE,loaded);
> }

> function loaded(evt:Event):void
> {
> var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
> var displayObject:DisplayObject = loaderInfo.content;
> displayObject.width = 150;
> displayObject.height = 150;
> displayObject.x = 1000;
> displayObject.y = 208;
> addChild(displayObject);
> displayObject.alpha = 0;
> TweenLite.to(displayObject, 1, {x:65, y:117, scaleX:0.5, scaleY:0.5,
> rotation:520, alpha:1});
> }
>    }
> }

> For some reason, "logo.png" describes an arc as it spins on its axis,
> similar to, say, the Earth spinning on its axis while simultaneously
> rotating around the Sun. The gent from greensock tells me this is because
> I've misplaced my registration point, but this graphic doesn't have a
> registration point as far as I can see. So what gives? How do I get rid of
> the arcing?
> TIA,
> beno

_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to