A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Keep object in stage center while scrolling

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    996

    Keep object in stage center while scrolling

    I have a situation where i have a horizontal scrolling container that has a video object inside it. the video object has to stay inside the scrolling content for another reason i don't want to get into here. Now the client wants me to keep the video in the center of the stage even when the clip its inside of is scrolling. Normally I would just take it out of the scrolling clip and place it above the scrolling content but i cant do that here.

    I tried this math but it didn't work exactly.
    on an enter frame when the video is open I have this code;
    Actionscript Code:
    if( vid ) vid = ( stage.stageWidth/2 - vid.width/2)   - scrollingContainer.x;

  2. #2
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    I tried a simple test of your math and it works just fine. What exactly is vid? maybe your code isn't moving the vid properly. Like maybe you need to put in vid.x because everything after vid= I think is just perfectly fine.
    .

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    996
    Ah I missed typed yes it should be vid.x. It works for me when I test it in another file but in my movie its not working correctly.

    I found another way around it which worked out for me. I took it out of the scrolling move and added some scaling Math to it separately.

    Thanks for the help and testing the code.

  4. #4
    Senior Member
    Join Date
    Feb 2005
    Posts
    1,834
    if you show more code maybe I can help you figure it out better. I mean what exactly is the setup. I suppose unless it's a big project...
    .

  5. #5
    Senior Member
    Join Date
    Apr 2001
    Posts
    996
    Thanks swak, Yea the project is way to big to post. At Least I Know my code works. Thanks for the help

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