A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: HELP - Magnifier Problem - Actionscript 2.0

  1. #1
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    HELP - Magnifier Problem - Actionscript 2.0

    Good day all,

    I create a file which has a picture in it and what I'm trying to do is when you use the magnifier to mouse over the image it appears bigger, however I am having a problem with my code and I'm not exactly sure why the code is not working.

    Below is my actionscript 2.0 code, can someone let me know why the code below is not allowing me to move my magnifier movieclip.

    ***** Flash file attached *****

    ------ code -------

    var positionX = 100 / (maplrg_mc.width / (mapsml_mc.width - magnifier.width / 2));
    var positionY = 100 / (maplrg_mc.height / (mapsml_mc.height - magnifier.height / 2));
    var distX = 0;
    var distY = 0;
    var magnifier_fx:Boolean = false;

    // Magnifier movement script
    magnifier.onRollOver = magnifierOver;
    magnifier.onRollOut = magnifierOut;
    magnifier.mouseMove = magnifierMove;

    function magnifierRollOver() {
    magnifier_fx = true; }

    function magnifierRollOut() {
    magnifier_fx = false; }

    function magnifierMove() {
    if (magnifier_fx == true) {
    calculaDist();
    movemagnifier();
    //
    magnifier.x = mouseX - magnifier.width / 2;
    magnifier.y = mouseY - magnifier.height / 2;
    //
    if (magnifier.x < mapsml_mc.x) {
    magnifier.x = mapsml_mc.x;
    } else if (magnifier.x > mapsml_mc.x + mapsml_mc.width - magnifier.width) {
    magnifier.x = mapsml_mc.x + mapsml_mc.width - magnifier.width;
    }
    if (magnifier.y < mapsml_mc.y) {
    magnifier.y = mapsml_mc.y;
    } else if (magnifier.y > mapsml_mc.y + mapsml_mc.height - magnifier.height) {
    magnifier.y = mapsml_mc.y + mapsml_mc.height - magnifier.height;
    }
    //
    magnifier_mask.x = magnifier.x
    magnifier_mask.y = magnifier.y
    }
    }

    // Map Magnification
    function calculaDist()
    {
    distX = (magnifier.x - mapsml_mc.x) / positionX * 100;
    distY = (magnifier.y - mapsml_mc.y) / positionY * 100;
    }
    function movemagnifier()
    {
    maplrg_mc.x = magnifier_mask.x - distX;
    maplrg_mc.y = magnifier_mask.y - distY;
    }

    ---- end of code -----

    Any help would GREATLY be appreciated.

    Thanks,
    Alan
    Attached Files Attached Files

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    its not:
    x
    y
    width
    height

    it's
    _x
    _y
    _width
    _height

    Also your functions calls are wrong. Check the syntax for button and movieClips handlers and be accurate with the actual functions names.

    gparis

  3. #3
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    HELP - Magnifier Problem - Actionscript 2.0

    gparis,

    Thank you for your response. I've made the change you suggested by replacing all the x, y, width, height with _x, _y, _width, _height but the problem still remains with me not being able to move the magnifier around. I doubled check all the names are correct and they are. I also used the check syntax button and it doesn't give me any errors.

    Any thoughts on this? If you could shed some light for me I would appreciate your help.

    Thanks again,
    Alan

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    I'm guessing some form of a loop would help. Maybe post the .fla corrected so far.

    gparis

  5. #5
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    HELP - Magnifier Problem - Actionscript 2.0

    gparis,

    Updated code is below with the changes I mentioned earlier. I double checked all names and they are correct. The magnifier movieclip is however is located inside a movieclip called "panel_mc", not sure if I will need to change the code because of that or not.

    ----- code start -------

    var positionX = 100 / (maplrg_mc._width / mapsml_mc._width - magnifier._width / 2);
    var positionY = 100 / (maplrg_mc._height / mapsml_mc._height - magnifier._height / 2);
    var distX = 0;
    var distY = 0;
    var magnifier_fx:Boolean = false;

    // Magnifier movement script
    magnifier.onRollOver = magnifierOver;
    magnifier.onRollOut = magnifierOut;
    magnifier.mouseMove = magnifierMove;

    function magnifierRollOver() {
    magnifier_fx = true; }

    function magnifierRollOut() {
    magnifier_fx = false; }

    function magnifierMove() {
    if (magnifier_fx == true) {
    calculaDist();
    movemagnifier();
    //
    magnifier._x = mouseX - magnifier._width / 2;
    magnifier._y = mouseY - magnifier._height / 2;
    //
    if (magnifier._x < mapsml_mc._x) {
    magnifier._x = mapsml_mc._x;
    } else if (magnifier._x > mapsml_mc._x + mapsml_mc._width - magnifier._width) {
    magnifier._x = mapsml_mc._x + mapsml_mc._width - magnifier._width;
    }
    if (magnifier._y < mapsml_mc._y) {
    magnifier._y = mapsml_mc._y;
    } else if (magnifier._y > mapsml_mc._y + mapsml_mc._height - magnifier._height) {
    magnifier._y = mapsml_mc._y + mapsml_mc._height - magnifier._height;
    }
    //
    magnifier_mask._x = magnifier._x
    magnifier_mask._y = magnifier._y
    }
    }

    // Map Magnification
    function calculaDist()
    {
    distX = (magnifier._x - mapsml_mc._x) / positionX * 100;
    distY = (magnifier._y - mapsml_mc._y) / positionY * 100;
    }
    function movemagnifier()
    {
    maplrg_mc._x = magnifier_mask._x - distX;
    maplrg_mc._y = magnifier_mask._y - distY;
    }

    ----- end of code -----

    Again any help you can offer is greatly appreciated.

    thanks,
    Alan

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Ok. I see you calling a function 'magnifierOver'
    And i only see a function named 'magnifierRollOver'

    Same for the rest, magnifierRollOut/magnifierOut

    And I don't see any loops, enterFrame or interval that would make things move..

    gparis

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