Welcome, Guest
  • Author Topic: centering loaded image to empty MC  (Read 3991 times)

    Algreco

    • Seasoned Programmer
    • ***
    • Posts: 123
    • If it 'aint workin blame Flash!
      • View Profile
      • Line Dezine
      • Email
    Re:centering loaded image to empty MC
    « Reply #15 on: 06/30/04, 11:15 »
    Hey Mattias
    tried what you wrote.
    Images are still glued to the left hand corner. the coordinates of the MC changed though, so something there works but not entirelly.
    :'(

    Mattias Robo

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 555
      • View Profile
      • nook
    Re:centering loaded image to empty MC
    « Reply #16 on: 07/01/04, 06:30 »

    Maybe you're missing something out here Al.
    You can't move the image itself. You can only inflict buttons and movieclips with as. The image will always be glued to the upper left corner since you load it dynamicly. I don't know though why you get stucked on that because if you just move the MC in the same way, as a described before, then it will look just like the image is centered on the stage, right?
    It should be no problem.

    :: robo


         "I've figured it out. It's not the fords... it's what's IN them!.."

    Algreco

    • Seasoned Programmer
    • ***
    • Posts: 123
    • If it 'aint workin blame Flash!
      • View Profile
      • Line Dezine
      • Email
    Re:centering loaded image to empty MC
    « Reply #17 on: 07/01/04, 08:18 »
    yes, sorry, I get it.
    So there isn't a way for flash to read the properties (size) of the image loaded and to change the position of the MC accordingly. In this case Jorge was right.
    Creating another MC inside that one will not help since it will still be registered at (0,0).
    I will look for a solution and post something in case i come up with something.
    Thanks for helping,  8)
    Al

    Algreco

    • Seasoned Programmer
    • ***
    • Posts: 123
    • If it 'aint workin blame Flash!
      • View Profile
      • Line Dezine
      • Email
    Re:centering loaded image to empty MC
    « Reply #18 on: 07/01/04, 21:30 »
    Ok, I said I'll get back to you when I found a solution.
    well... I didn't, not really... the only option I could see was to frame my pics and make it so that there's a colored frame around it which is the same as my BG color. But since this solution is a waste of precious bytes and rather annoying I decided to give it up and just load images into my SWF and go frame by frame. More d/l time...
    ::)
    Thanks for the help though

    Mattias Robo

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 555
      • View Profile
      • nook
    Re:centering loaded image to empty MC
    « Reply #19 on: 07/02/04, 04:28 »

    Al. For crying out loud. Didn't you hear me?!  ???

    When you load the image into the empty mc, the mc gets the size of the image. Right?

    Hence

    image_mc._x = Stage.width/2 - image_mc.width/2
    image_mc._y = Stage.height/2 - image_mc.height/2

    will put the mc and the image exactly in the center of the stage, no need of borders.

    But be shure that the image is truly loaded before executing it.
    « Last Edit: 07/02/04, 04:29 by Mattias Robo »
         "I've figured it out. It's not the fords... it's what's IN them!.."

    Algreco

    • Seasoned Programmer
    • ***
    • Posts: 123
    • If it 'aint workin blame Flash!
      • View Profile
      • Line Dezine
      • Email
    Re:centering loaded image to empty MC
    « Reply #20 on: 07/02/04, 04:50 »
    Thanks for caring Mattias ;)
    I will give it a try, although the slide show isn't that crusial for me. right now I have one online that works, only with a d/l time stuck to it. I tried your solution before, it didn't work, although logically it should. maybe I put the script in the wrong place (I put it where Jorge suggested) dono... now i'm facing some other problems with my main site which are killing me....
    Grazie mille though :)

    Mattias Robo

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 555
      • View Profile
      • nook
    Re:centering loaded image to empty MC
    « Reply #21 on: 07/02/04, 07:35 »

    I did some testing myself.
    I found that I missed the underscores!

    image_mc.width should of course be image_mc._width and so on

    But Stage.width is still right. Quite confusing.

    Another stupid thing is that it doesn't work local. But if I upload the swf and images it works fine. Both a loader and centering the image.

    Maybe that's your only problem Al.
    « Last Edit: 07/02/04, 07:39 by Mattias Robo »
         "I've figured it out. It's not the fords... it's what's IN them!.."

    Mattias Robo

    • Moderator
    • Systems Administrator
    • *****
    • Posts: 555
      • View Profile
      • nook
    Re:centering loaded image to empty MC
    « Reply #22 on: 07/02/04, 07:46 »

    Correction.

    The centering part does work locally.
    It's just that the stagesize isn't the same as the documentsize and when you test the movie the stage stretches out (works with "show all" though).

    Maybe better to use a reference mc instead that has the same measurement as the document.

    Like:
    image_mc._x = refMc._width/2 - image_mc._width/2
    image_mc._y = refMc._height/2 - image_mc._height/2
    « Last Edit: 07/02/04, 07:48 by Mattias Robo »
         "I've figured it out. It's not the fords... it's what's IN them!.."