Hi
I am so very stuck, and need your help with relative coordinates please.
I am building a project where I have 15 'islands' inside one big 'ocean' movie clip.
I created navigation buttons so you can explore the Ocean movie clip and look around the islands.
my problem comes when i want to 'zoom into an island'
So basically on the stage i have a movie clip called- Ocean_mc, and inside it are 15 movie clips, one of them (for this example) is a movie clip called GreenIsland_mc.
Passing coordinates relative to stage...Ok, I managed to solve it myself?
Basically I think I manually created the .localToGlobal thing (but i might be wrong on that).
1) I simply defined the ocean_mc original coordinates-
It wasn't a straight forward 0,0 because my movie was not properly centred, so I simply did a trace statement to find where the ocean_mc thinks it is.
2) Then I defined the original coordinates of a central zoom point for the island-
This was done by a non-sophisticated trial and error where I clicked to zoom in the island to set coordinates, and simply changed them little by little till i found the right place on stage, I am sure there is a beautiful smooth way to calculate those coordinates but I found the dirty trial and error way very quick
3) When an Island was clicked to be zoomed, I checked the placement of the ocean_mc clip in relation to it's original place and added that difference to the island's original centre points.
That's it.
In code terms-
1)
// So I started by setting original coordinates for the ocean_mc movie clip-
var origOceaonX:Number = -200;
var origOceaonY:Number = -310;
2)
// Then setting the original coordinates for the zoomed in island
// (this is basically the coordinated that will place the island movie clip centre stage if it is clicked before anything is moved )-
var origIslandX:Number = 180;
var origIslandY:Number = 270;
// and then I defined 4 new vars-
// two to hold a new adjustments for the centre point for the islands-
var centrePointAdjstX:Number;
var centrePointAdjstY:Number;
// and two for setting the new centre point for the islands-
var newCentrePointX:Number;
var newCentrePointY:Number;
3)
// and then when ever the zoom in button was clicked I looked where the ocean_mc movie clip was in relation to it's starting point and simply adjusted // the island's centre coordinates accordingly
No comments:
Post a Comment