dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Anchor point

  1. #1
    Say Hello to my little friend. pimpjacksmack's Avatar
    Join Date
    Apr 2002
    Posts
    95

    Anchor point

    Okay, I'm building a image browser (click right arrow, next pic, etc) and I have images loading in a movie clip, but the anchor point is locked in the upperleft so all the images load in the upper left. Is there a way to get an anchor point in the middle so all loaded images are centered on the screen?

  2. #2
    Flash Gordon McUsher's Avatar
    Join Date
    Mar 2001
    Location
    Krautland
    Posts
    1,560
    An image is always loaded aligned left-top to the anchor.

    To get it centered, you would first use the MovieClipLoader class
    to load the image instead of loadMovie. The loader Class fires an
    event, when the image is loaded and ready for manipulation. Then
    you'll align it centered.

    Here is an example code:
    Code:
    this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
    var mclListener:Object = new Object();
    mclListener.onLoadInit = function(target_mc:MovieClip) {
    	// center it:
    	target_mc._x = -target_mc._width/2;
    	target_mc._y = -target_mc._height/2;
    	
    };
    var image_mcl:MovieClipLoader = new MovieClipLoader();
    image_mcl.addListener(mclListener);
    image_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg", image_mc);
    My letters on the F1 key have faded, how are yours today?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center