SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Location
    Melbourne, Australia
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Should this be done with Action Script?

    Hi

    I have what I think is a simple request but cannot find any tutorials to see if I should create it with action script.

    I have a vector based house plan that I want to present in a 550 X 430 px stage.

    I want to be able to drag the house plan (which I can do), as well as have a zoom in button and zoom out button and reset. I wnat to know if I can apply actionscript to the zoom in button to make it zoom say 25% larger than the original then 50% larger etc. The zoom out button would zoom smaller by 25% etc and obviously the reset button would reset to the original size.

    If action script is the best way to handle this can some one please set me in the right direction to a good tutorial.

    Thanks in advance
    Jamiec

  2. #2
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi,
    You can use the following code to bring in your effect.

    Zoom In
    Code:
     
    on(release){ 
     
    _root.myHouse._width+=0.25+_root.myHouse._width;
    _root.myHouse._height+=0.25+_root.myHouse._height;
     
    }
    Zoom Out
    Code:
    on(release){
     
    _root.myHouse._width-=(0.25+_root.myHouse._width);
    _root.myHouse._height-=(0.25+_root.myHouse._height);
     
    }
    Reset
    Code:
      
    on(release){
     
    _root.myHouse._width= _root.OriginalWidth;
    _root.myHouse._height=_root.OriginalHeight;
     
    }
    OriginalWidth and OriginalHeight will be two variables defined in the root and will be equal to the original width and height of the house. Let me know in case of further issues.
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.

  3. #3
    SitePoint Zealot tconley79's Avatar
    Join Date
    Feb 2004
    Location
    Miami
    Posts
    176
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've worked on a few zoomable maps...Here's an example that might help.
    Attached Files Attached Files

  4. #4
    SitePoint Enthusiast
    Join Date
    Jun 2002
    Location
    Melbourne, Australia
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the suggestions guys. They are both great.

    Jim, your works great except that I can't get the zoom out button to do anything, and what would I change to change the amount it zooms (the sacle ie. 25%). Is it also possible to put a limit on the amount it zooms.

    Thanks for all you help
    Jamiec

  5. #5
    SitePoint Wizard jim_morrison3's Avatar
    Join Date
    Apr 2004
    Location
    UK
    Posts
    2,324
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't get the zoom out button to do anything
    Hmmm..... I'll have to try my code to see what's wrong.

    what would I change to change the amount it zooms (the sacle ie. 25%)
    Nothing! Its already there in the code, 25% = 25/100 = 0.25

    Is it also possible to put a limit on the amount it zooms
    Yes it is possible, for that you need an if condition which specifies that if your movie clip's width and height exceeds the stage dimension then stop the scaling process. Here's an example:

    if (myHouse._width > 550 || myHouse._height>400){

    myHouse._width=myHouse._width;
    myHouse._height=myHouse._height;

    }
    Good Luck!
    There are things known and Things unknown
    And in between are the Doors.
    I love hand Coding.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •