AS 2 help with positioning loaded clips on stage resize
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: help with positioning loaded clips on stage resize

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    340

    help with positioning loaded clips on stage resize

    Hi,

    I really don't understand how resizing works depending on the final screen scale, but I was passed this code where only one of the clips I'm loading remains where it should (sintonitzadorHolder). I thought the rest of the clips might not be repositioned because I was using the same movieClipLoader for all my clips in the movie, but I have just given them new names and still nothing changes whenever I switch my screen's resolution to test the file(On the contrary, they all reposition way off to the right side of the screen). Only the sintonitzadorHolder and they are all loaded in the same frame.

    I know i will also need to resize the clips, but I will worry about that when I have an idea of what is going on with the repositioning.

    How does this work?

    I keep visualizing an example with even proportions where the stage would be 200 x 200 and the loaded clip was a 50 x 50 square or a circle on a 10._x position. Then if the screen resized to 400 x 400 that would give me 400 - the original width of the loaded movie?

    The result is 350. Sorry if my post is not clear, I'm very confused with this and even though I have googled pretty much, most everywhere give the same explanation. The stage's width - the loaded movie's width. Sometimes divided by 2...

    Anyway, I will understand it if I get no reply. This is driving me "loco".

    Code:
    function StageResize()
    {
    	backGround._width = Stage.width;
    	backGround._height = Stage.height;
    	backGround._x = 0;
    	backGround._y = 0;
    	
    	digitalTimeHolder._x = Stage.width - digitalTimeHolder._width;
    	localTime._x = Stage.width - localTime._width;
    	pilotaHolder._x = Stage.width - pilotaHolder._width;
    	searchHolder._x = Stage.width - searchHolder._width;
    	clocksHolder._x = Stage.width - clocksHolder._width;
    	englishHolder._x = Stage.width - englishHolder._width;
    	spanishHolder._x = Stage.width - spanishHolder._width;
    	catalanHolder._x = Stage.width - catalanHolder._width;
    	sintonitzadorHolder._x = Stage.width - sintonitzadorHolder._width;
    }
    
    SizeListener = new Object();
    SizeListener.onResize = function()
    {
    	StageResize();
    };
    
    Stage.addListener(SizeListener);
    my page: http://webs.ono.com/jpdurba
    Last edited by capdetrons; 12-31-2013 at 08:16 AM.

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,150
    Hi Cap,

    The reason your clips go way off screen to the right is because the function has no idea what width your clips are until they have been loaded, hence giving them to an _x value of Stage.width (far right side);

    so if you used the cliploaders correctly, you can invisible them until they are loaded then place them on the screen.(Stage.width - clip._width), /2 is for centering usually.
    Once your clips have been loaded once then your resize function works fine.

    Hope this makes sense for you.

  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    340
    Good afternoon,

    Hi, Fruitbeard,

    thanks for the reply. It makes sense, but I am creating the containers in the exact same frame for all those files just like the sinonitzadorHolder and they are loaded in that frame as well.

    I even created several more movieClipLoaders to load those files.

    I'll keep looking... it's just that I don't really understand the basics of resizing or scaling I'm very confused with it.

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,150
    Hi Cap,

    Here is a small *.fla showing how repositioning works when resizing the screen, hopefully it will guide you through doing the same thing when loading clips.

    Essentially when loading external clips, the dimensions are not know until it has loaded, unless you declare the dimensions before.
    So when you resize your screen before a clip has loaded it will position it at Stage.width(far right) missing out the clip width.

    so play with the example file, test it, drag the screen size around move the clips, see what happens.
    Last edited by fruitbeard; 12-31-2013 at 11:20 AM.

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

Poll by Flashkit.com