Tally List : mailing list management, archiving, and analysis
click for archive home
 
Archive of:
Flash
Macromedia Flash List
 
home
24 hour view
quick stats
weekly updates
 
all tallylists
corporate solutions
archive your favorite
help / feedback


Search the Tallylist search by keyword:

About Flash :
product's home
product's list home
 
  Archived TallyList / Flash: 
Subject: RE: Trouble centering a scaled movie clip
Matthijs Koevoets (7p/+0r)     Posted: Tuesday 02 Jan 2001
This post: 7 views, +0 rating

hi there kevin,

had the same problem some time ago my solution doesn't require heavy maths but is rather course i suppose here we go first i set some variables, they are hard coded boundaries if the draggable object (the map in your example) has not been scaled then these are the boundaries within which it is allowed to move.

in my example the map and mask are centered on stage the width and height of the map would be: 420 (positioned at: top -140, left -140) the width and height of the mask: 140 the width and height of the movie: 140

which leaves me with these boundaries:

Set Variable: "maxRight" = "210" Set Variable: "maxLeft" = "-70" Set Variable: "maxBottom" = "210" Set Variable: "maxTop" = "-70" Set Variable: "startW" = "420"

now i start a loop: this to get the current width of the map: Set Variable: "w" = getProperty("../theMap",_width) next i want to see what the difference is between the original width of the map and the current width and divide that by two to get a number that holds the change in position Set Variable: "shift" = (w - startW) / 2 let me explain suppose the current width is 430 we know the original width was 420 that leaves us with a difference of 10 which means (since the map is scaling from the center) that 5 pixels have been added to the left and right the map will have moved 5 pixels to the left and top these pixels will need to be added to(/subtracted from) the boundaries: the map is allowed to move five pixels further than before

next i set two variables to hold the current x and y positions of the map: Set Variable: "X" = getProperty("../theMap",_x) Set Variable: "Y" = getProperty("../theMap",_y) and here finally i start comparing the x and y positions to the updated boundaries if the map crosses a boundary it is returned to that boundary: If (X < maxLeft - shift) Set Property ("../theMap", X Position) = maxLeft - shift End If If (X > maxRight + shift) Set Property ("../theMap", X Position) = maxRight + shift End If If (Y> maxBottom + shift) Set Property ("../theMap", Y Position) = maxBottom + shift End If If (Y < maxTop - shift) Set Property ("../theMap", Y Position) = maxTop - shift End If that's it, keep this looping and you're OK hope it's all clear. if not, don't hesitate to ask good luck and happy new year to you and the other flashers

matt

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ flasher is generously supported by... ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ flashforward2000 and the Flash(tm) Film Festival November 27-29, 2000, LONDON, National Film Theatre

Produced by United Digital Artists and lynda.com -Sponsored by Macromedia, Adobe Systems and Apple Computer -http://www.flashforward2000.com or UK tel. +44 (0870) 751 1526 Register before November 10 and save £200 http:// www.flashforward2000.com ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ To unsubscribe or change your list settings go to http://www.chinwag.com/flasher or email help@chinwag.com


Similar Subject Line Posts (+/- two weeks of this post)
RE: Trouble centering a scaled movie clip  02 Jan 2001 (this post)   (7 v/ +0 r)
Trouble centering a scaled movie clip  31 Dec 2000   (3 v/ +0 r)
 

Send a reply to the Flash list!
click to send a reply! NOTE: Many lists will reject your post unless you have already registered with them. Also - don't forget the right account to send from (for those with multiple emails!)

Feedback: If this post was exceptionally helpful, please help by giving this post a positive review.

 

TallyList : copyright Ububik - 2000