A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 29

Thread: [RESOLVED] object stuck to the edge of the movie

  1. #1
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352

    [RESOLVED] object stuck to the edge of the movie

    hi!
    i`ve asked this before and someone gave me the code below but i couldnt make anything of it

    Code:
    // create a new object which will be our stage listener.
    var sl:Object = new Object();
    // assign a onResize handler to the sl Object
    // this executes the code within it when the stage is resized.
    sl.onResize = function() {
    	// reposition the clip so that it is "stuck" to the right edge of the movie.
    	clip._x = Stage.width-clip._width;
    };
    // make sl the stage listener.
    Stage.addListener(sl);
    can someone pls help me make a mc stick to the right or bottom edge of the movie???

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    clip._x = Stage.width - clip._width;
    clip._y = Stage.height-clip._height;
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    thanks for the reply but i still dont get it. i had that code as a part of the code i posted erlyer

    can u pls make somtething out of the fla i ve attached?
    Last edited by vladdddd; 02-09-2009 at 09:52 AM.

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    That code did not work. It will work only when you resize the stage.
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    sry i had wrong publish settings and now the object sticks to the edge of the browser; even so i still have 2 problems
    1. when i resize the window, as the object stick to the edge it resizes as well. i dont want that.
    2. how do i point the event only to one object. in the fla attached i have 2 objects and they both resize and reposition

    thanks alot cancerinform!!! u ve been quite a friend since my first post here
    Last edited by vladdddd; 02-09-2009 at 09:52 AM.

  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I cannot open your fla, but the reason for resizing I think is because you set the publish settings under HTML to 100%/100%. Set it to match movie in pixels.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    your right. i ve attachet a jpg with my publish settings. the only thing is that when i set it to Match Movie (px) the clip doesnt stick to the edge no more, nothing happends when i scale the window
    Last edited by vladdddd; 02-09-2009 at 09:52 AM.

  8. #8
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    That is probably the limitation of what you can do.
    - The right of the People to create Flash movies shall not be infringed. -

  9. #9
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    ok, your last statement wasnt very helpfull and i stil have my problem

    is there anything else i can do or just quit and move on to the next forum?

  10. #10
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Well at least I made a statement. As far as I can see these are the limits which you have when you use the Stage.resize method. I spent quite some time to test out all the possibilities. So if you think in a different forum you will get an answer, then please. But do not double post on Flashkit.
    Last edited by cancerinform; 10-28-2006 at 12:28 PM.
    - The right of the People to create Flash movies shall not be infringed. -

  11. #11
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    One possibility, which you still have, is that you scale your objects when the stage is scaled, so they have always the same height and width.
    - The right of the People to create Flash movies shall not be infringed. -

  12. #12
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    i was a little dissapointed. Thanks alot anyway. i knew that it can be done, but it overwelms me as u put it.

    thanks alot!

  13. #13
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I am always surprised what people think can be done with Flash. There are limitations and you find them everywhere in forums. HTML is one such limitation and recently security issues calling files from foreign domains. And there are more like simple button within buttons executions, which however are now possible with AS3.

    As I indicated with AS you can adjust the size of your objects relative to the stage. In that sense it is possible and you can figure it out. It is a matter of a little bit geometrie and calculations. But you cannot do it with the stage size and scale methods, because they simply are limited and the existing ones don't allow it.

    If you need a stronger program than Flash you might want to consider to look into Director and create Shockwave movies.
    - The right of the People to create Flash movies shall not be infringed. -

  14. #14
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    u know better
    i ve seen objects sticking to a window edge relly often and i thought it was not so hard to do (i havent taken everything into consideration i guess)

    www.supperclub.com

    about adjusting the size of objects relative to the stage - good ideea but i have no clue about how it is done what so ever

    u can teach me a thing or two about that also if u please

    THANKS ALOT!

  15. #15
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    The example you show is irrelevant, because the objects also change their size. Apart from that you could be cheated by the different size of the objects. In addition you want some special treat like putting the mcs in the corner.

    If you want to find out the AS for what you want, start with an onEnterFrame event where you trace the stage width and height and then try out how you can adjust the size of the mcs relative to the stage by adding when you loose or loosing when you add.
    - The right of the People to create Flash movies shall not be infringed. -

  16. #16
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    here you are:
    Code:
    Stage.scaleMode="noScale";
    screen = new Object();
    screen.w = 900;
    screen.h = 600;
    
    list_resize = new Object();
    list_resize.onResize = function () { 
    	//center movieClip
    	var pos = get_pos(Stage.width/2-mc_sample_a._width/2,Stage.height/2-mc_sample_a._height/2);
    	mc_sample_a._x = pos.x;
    	mc_sample_a._y = pos.y;
    	
    	//place this movieCLip in the upper left corner
    	var pos = get_pos(0,0);
    	mc_sample_b._x = pos.x;
    	mc_sample_b._y = pos.y;
    
    }
    Stage.addListener(list_resize);
    
    //sub function to get the resized coordinates
    get_pos = function(x,y){
    	return( {x:int((screen.w-Stage.width)/2+x) ,y:int((screen.h-Stage.height)/2+y )});
    }
    important notes:
    the
    Code:
    screen = new Object();
    screen.w = 900;
    screen.h = 600;
    is very important otherwise the calculation later is wrong. These numbers are the stage size you work on in flash the size you publish originally your flash movie.

    The function get_pos calculates the absolute position of the screen. Usually when you set coordinates in a flash movie that is resized and has Stage.scaleMode set to "noScale" those coordinates aren´t anymore in the very upper left corner,- but instead somewhere else.
    So if your original movie had a width of 400 but the resized movie in the browser is 800 you´d have to say movieClip._x = -200; to place it at the absolute x=0 position. This is because the stage was centered.

    in the html file you could use this if you want to have the flash movie filling all the window:
    Code:
    <object codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="100%" height="100%">
            <param name="movie" value="test_01.swf" />
            <param name="quality" value="high" />
            <embed src="test_01.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="100%" height="100%"></embed>
          </object>
    I hope this is what you were looking for

  17. #17
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    - The right of the People to create Flash movies shall not be infringed. -

  18. #18
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    This is definitly something!
    but i want my object to stick to the bottom edge instead of left or center; is there any way to do this with this code?
    i gave it a look, but my as is poor so..

    Thanks alot guys!

  19. #19
    Student
    Join Date
    Apr 2001
    Location
    -
    Posts
    4,756
    bottom center
    Code:
    //center movieClip at the bottom
    var pos = get_pos(Stage.width/2-mc_sample_c._width/2,Stage.height-mc_sample_c._height);
    mc_sample_c._x = pos.x;
    mc_sample_c._y = pos.y;
    or bottom right corner:
    Code:
    //center movieClip at the bottom
    var pos = get_pos(Stage.width-mc_sample_d._width,Stage.height-mc_sample_d._height);
    mc_sample_d._x = pos.x;
    mc_sample_d._y = pos.y;
    important note for you:
    All hotspots/ pivots of the sample MovieClips (e.g "mc_sample_d") have to be in the upper left corner of that movieClip (x:0,y:0)- just in case you did this different and wonder why its not accurate

    i gave it a look, but my as is poor so..
    start learning AS then

  20. #20
    Senior Member vladdddd's Avatar
    Join Date
    Aug 2004
    Location
    in space
    Posts
    352
    works perfectly! i even managed to switch corners

    THANKS ALOT!

    p.s. for cancerinform - once again flashkit came through!!!

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