A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [F8] Changing the position of my movieclip HELP!

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    222

    [F8] Changing the position of my movieclip HELP!

    Hi guys,

    This is very basic and for some reason it's not working. I am doing a very basic zoom in/out map thing and I have a button where i just want to reset the map to it's original position. So on the reset button I have:

    on (release) {
    lowestScale = 100;// lowest desired scale of map2 in %
    highestScale = 300;// highest desired scale of map2 in %
    _root.position=_root.map2._x=456.3, _root.map2._y=109.8;

    function reset() {
    // calculates scale and sets it

    _root.scale = _root.map2._xscale=_root.map2._yscale=lowestScale;
    _root.slider.scrollMin = _root.range._y-_root.range._height;// minimum _y value possiible for scrollbar
    _root.slider.scrollMax = _root.range._y;// maximum _y value possiible for scrollbar
    _root.slider._y = _root.slider.scrollMin+(_root.slider.scrollMax-_root.slider.scrollMin)/1;// sets starting position of scrollbar (currently half-way)
    scaleFactor = Math.pow(highestScale/lowestScale, 1/(_root.slider.scrollMax-_root.slider.scrollMin));// variable for SetScale
    }

    reset();

    }

    For testing I did the following but it's still didn't work:

    on (release) {
    _root.map2._x=456.3
    _root.map2._y=109.8;
    }

    Any ideas as to what I am doing wrong, this is so basic it's embarrassing.

    Cheers
    You have to think in Flash

  2. #2
    Senior Member
    Join Date
    Jan 2008
    Location
    Montreal
    Posts
    101
    I can see some problems but can't be sure since we may not see the entire code. Mind posting the fla?

  3. #3
    Senior Member
    Join Date
    Apr 2001
    Posts
    222

    Thanks...

    Hey Whyves

    I am trying to get my head around actionscript but I think I need to take a maths class as it's all bloody formulas! Anyway, I couldn't attach because file was too large but here is the file I put on the server:

    http://www.insomniacdesign.com/map.fla

    Thanks so much for looking into this, I appreciate it!
    You have to think in Flash

  4. #4
    Senior Member
    Join Date
    Jan 2008
    Location
    Montreal
    Posts
    101
    Hi,

    I took a look at it and there were few problems. Please, I hope you don't mind me having changed it a bit. I never did that type of project before and felt it was fun to take a look at. So, the major problem I saw with the map is that when you would scale it, the center point did not remain in the center. So, what ever you are looking at is moving out of the screen when you are zooming in. So, in order to solve this, we have to calculate where the center point will be as we zoom in and move the map accordingly. The second problem was when you are panning the map while zoomed in and later on change the zoom factor again. So, we have to calculate the unzoomed center point as you pan the map.

    Resetting the map with the reset button was then as simple as resetting the map coordinates and zoom factor.

    P.S. I also had to change the register point in the map. It made things a lot simpler, especially with the math

    P.P.S I also realize that I did not include the bounding while panning the map. You just have to add the dounding box in the startDrag function. Make sure that the bounding box size is scaled with the scale factor.
    Attached Files Attached Files

  5. #5
    Senior Member
    Join Date
    Apr 2001
    Posts
    222
    Hey Whyves,

    No of course I don't mind you messing with the file and having fun with it. I THANK YOU!!! Smarty Pants

    I'll admit I am more of a flash designer than a programmer and it's just getting too complicated for me! I left the bounds thing out... I couldn't put it back in and your code is great. Thanks so much.

    Cheers!
    Last edited by Shmeed4020; 01-21-2008 at 01:36 PM.
    You have to think in Flash

  6. #6
    Animal Lover, Flash lover eaglevision's Avatar
    Join Date
    Jan 2008
    Location
    In FlashKit
    Posts
    286
    I would love to see the map, but it says "Unexpected file format"
    Anybody know why this is poping up?
    ~11-year old flasher

  7. #7
    Senior Member
    Join Date
    Apr 2001
    Posts
    222
    WOW, that's impressive, 11 years old and you're working in flash! Man I feel old. Or you've been working in flash for 11 years?! You're probably getting that error because you don't have the latest version of flash? What flash version are you using if it's less than flash 8 you won't be able to open it up....good luck!
    You have to think in Flash

  8. #8
    Animal Lover, Flash lover eaglevision's Avatar
    Join Date
    Jan 2008
    Location
    In FlashKit
    Posts
    286
    I have "Flash 8 pro", is that good enough?

    PS: I love flash! thanks, and I am eleven years old I feel good about it...thanks, but I only know the basics.
    ~11-year old flasher

  9. #9
    Senior Member
    Join Date
    Apr 2001
    Posts
    222
    Good for you! Well it's mighty impressive! You'll be a pro in no time! I've saved that file down (we're using CS3) for you so you can have a look at it and hopefully get something out of it. ENJOY!
    Attached Files Attached Files
    You have to think in Flash

  10. #10
    Animal Lover, Flash lover eaglevision's Avatar
    Join Date
    Jan 2008
    Location
    In FlashKit
    Posts
    286
    Nice! I like the look of it...It kind of looks 3D when you zoom in and out, pretty cool
    ~11-year old flasher

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