Dynamic image positioning in Flash

Luna

OSNN Senior Addict
Joined
6 Jan 2004
Messages
303
I am trying to design a simple interface for a site I help run in Flash MX 2004.


http://www.luna-fx.com/Untitled-2.html

This is what I have so far, a small sample of what I am trying to turn into a simple little interface. The flash box itself takes up 100% of the screen so it will fit any resolution, and I added a little script to keep the images from rescaling along with the actual movie size. I know it's not animated very well right now, but that's not the point.


I want the images to space themselves out based on the screen size. The images on the left would still be on the left, but the middle image would align to the center of the page, and then right images would move to the right side of the page. My original problem was that the images resized themselves along with the flash window and became really huge, but a noscale script fixed that.
I have tried using the align features in Flash, but it only snaps them to the left/center/right of my actual box in flash which is 800x590.

So what I would like to know is if this is possible, and two how might I go about doing it. It's not a huge deal, but it would be nice if it could be done.
 
it could be - just individually script each image (inside of a MC, because its sexier) to go to a specific size-ratio point, based on the movie's size, something along the lines of:

//a point after the movie loads; image1, for this example, being the top right image in your movie
_root.image1._x = (_root.system.capabilities.screenResolution.x-(200))
//the blue text can be swapped out for a variable that has that same number( _root.system.capabilities.screenResolution.x) in it(for simplicity in this line of script). "200" being the width of the clip (150, for example), plus whatever size buffer you want against the side of the movie (50)... this is where you could insert another small formula to have that buffer be dynamic as well


//example:
_root.image1._x = (ScreenRezX-(150+((ScreenRezX-(150x3))/4))

//the formula in red in this line of script does this: width of MC + buffer size, which is dynamic, taking away first the widths of the MCs from the total, then dividing up the remaining space to be used for the four buffer spaces between the MCs and the side of the movie (or each other). Of course, this script is only for the top right clip, but it can be easily modified for the other four (for y positioning of the clips, it can be changed as well)

I hope this helps a little, or is a good place to start from - if this doesn't work the way you would like, or I coded wrong, or if you would like some info on how to get the other scripts for the MC positioning to work, just drop a line (ooo, a pun! :p )
 
Hmm

I'm fairly new to Flash MX. I understand the code to a certain degree having taken a few C++ classes, but as to how I can make it work in my movie I'm a bit lost.


I tried using the example you put in there into the first frame for image 1, but when I tried to run the movie it just gave me an action script error.

Scene=Scene 1, Layer=1-15, Frame=1: Line 1: ')' expected
_root.image1._x = (ScreenRezX-(150+((ScreenRezX-(150x3))/4))




I'm not sure if that is a syntax error or not. I tried adding a ) after the /4, but that did not help. You have 5 ('s and 4 )'s. I'm also a tad lost to the definition of MC. I've only been working with it for a few days now so I don't understand it all that well, but I'm getting there. I'm not even sure if I am designing this like I should be.


Anyway, here is the flash file I am using at the moment. I don't know if it would help anyone to look at it and see how I can use this code in my design.

http://www.luna-fx.com/Digital/osnn/Untitled-2.fla
 
Well, lucky me - I tried cooking up a replicant of your movie with the script from above in it, building from the ground up so that you could have a copy with script formatting examples, nifty tricks, good storage habits, etc... but for some odd reason "System.capabilities.screenResolution.x" only returns "undefined", rather than an integer, which is pretty irritating...

the only thing I can suggest is that you go out, pick up an actionscripting book [ The two books written for Macromedia Press are great, and this one by Derek Franklin is fantastic... from it you can learn all the formatting, fun things, etc etc. That's the best way to go (those three books show up in a lot of libraries, so it's convenient too)]

Then you won't have to deal with my inadequacies, either :p
 

Members online

No members online now.

Latest profile posts

Also Hi EP and people. I found this place again while looking through a oooollllllldddd backup. I have filled over 10TB and was looking at my collection of antiques. Any bids on the 500Mhz Win 95 fix?
Any of the SP crew still out there?
Xie wrote on Electronic Punk's profile.
Impressed you have kept this alive this long EP! So many sites have come and gone. :(

Just did some crude math and I apparently joined almost 18yrs ago, how is that possible???
hello peeps... is been some time since i last came here.
Electronic Punk wrote on Sazar's profile.
Rest in peace my friend, been trying to find you and finally did in the worst way imaginable.

Forum statistics

Threads
62,015
Messages
673,494
Members
5,621
Latest member
naeemsafi
Back