A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Popup auto resize upon load

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    53

    Popup auto resize upon load

    Hi all,
    I'm working on a project that contains lots of photos with different widths/heights. When a thumbnail image within flash (which is a button) is pressed the popup will open a detailed image inside it. The popup should resize to the size of the photo loaded within it.

    Any scripts/tuts out there to do this?

    Cheers.

  2. #2
    haven't got a clue
    Join Date
    Nov 2004
    Location
    Toulouse - France
    Posts
    58
    Hi swap_meet,

    i'm not sure if i understand exactly what you need but i have an idea regarding the code for the pop-up:

    I've created a .fla file and attached it here so that it might help a bit more.

    1st i've declared 2 variables on the 1st frame, which are "var xscale and var yscale".

    Then i've created 2 thumbnails images. Converted them both to a movie clip (or button if you want to. Either will do as you can attach an "on (rollover)" handler).
    I also created a movie clip with the images (which are 2 different sizes), full size (the idea is that when you rollover a thumnail, it tells this movie clip to jump to certain frame and stop). To this movie clip I've attached a script:
    onClipEvent (enterFrame) {
    _root.xscale = this._width;
    _root.yscale = this._height;
    }
    What this is doing is that at every moment of the clip it is setting the 2 variables declared at the start to it's width and height. As the 2 images in the clip are different sizes, the variables will change when going from one image to the next.
    Finally, i've created a last movie clip (the popUp) as a border for the images and i've attached the following code:
    onClipEvent (enterFrame) {
    this._width = _root.xscale+3;
    this._height = _root.yscale+3;
    }
    This is setting it's width and height to the the variables value + 3, so that it looks like a border.

    And that's it. Hope this helps.

    OnAir
    Attached Files Attached Files

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    53
    Hi OnAir,
    Thankyou for your script..that helped alot.
    How difficult would it be to create a popup through javascript that auto resize depeding on the image loaded?

    Cheer again.

  4. #4
    haven't got a clue
    Join Date
    Nov 2004
    Location
    Toulouse - France
    Posts
    58
    Hi again,

    glad that script helped you out.
    Unfortunatly I won't be able to help you out on the javascript question, as i don't actually know any javascript (even though actionScript is supposed to be similar to it).
    Hopefully someone else will be able to help you out on that one.

    Laters'

  5. #5
    chibi-flasher
    Join Date
    Oct 2004
    Location
    Uruguay
    Posts
    41
    Hi Swap_meet

    i had the exact same problem with a project of mine
    Unfortunatly I won't be able to help you out either

    Moving the thread UP!!!!
    I wanna know how to do this tooo!

    Ahhh... and to OnAir

    could you save as the file in MX format if its not too much trouble? i wanna see the example file u did
    Thanks

  6. #6
    haven't got a clue
    Join Date
    Nov 2004
    Location
    Toulouse - France
    Posts
    58
    Hi myka,

    i've resaved the file in MX only format. Hope it helps.
    Let me know if it doesn't work
    Attached Files Attached Files

  7. #7
    chibi-flasher
    Join Date
    Oct 2004
    Location
    Uruguay
    Posts
    41
    does not work
    unespected file format

  8. #8
    haven't got a clue
    Join Date
    Nov 2004
    Location
    Toulouse - France
    Posts
    58
    which version of flash are you using ?

  9. #9
    chibi-flasher
    Join Date
    Oct 2004
    Location
    Uruguay
    Posts
    41
    just plain old MX

  10. #10
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    OnAir, I can't open it either on MX only... Are you on Mac?
    If so your MX only .fla also has to be zipped up to be able to open it on PC.
    If you're on PC, then you didn't save it as a MX only format.

  11. #11
    haven't got a clue
    Join Date
    Nov 2004
    Location
    Toulouse - France
    Posts
    58
    I'm on Pc, not Mac.

    I've tried saving it again but i don't actualy think it'll work.
    I went to "File - Save As" and in the "Save as type", choose Flash MX document. It then gives a message saying:
    "This file contains the following data that will be lost if saved in the Flash MX format:

    -Unicode
    -ActionScript 2.0
    -Persistent Library Data

    Continue with save?"

    1st time round i thought it was a standard message. Is it ?

    Anyway, i'll attach another file, just in case.
    Attached Files Attached Files

  12. #12
    chibi-flasher
    Join Date
    Oct 2004
    Location
    Uruguay
    Posts
    41
    It opens just fine!!

    thank u!
    now i have to investigate it a little
    to see what it does and how

    Again, million thanks

    Myka

  13. #13
    haven't got a clue
    Join Date
    Nov 2004
    Location
    Toulouse - France
    Posts
    58
    Cool, glad it works. To be honest, the scripting really isn't anything amazing. Just a few clipEvents.

    Any questions, don't hesitate contacting me by PM if you want.

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