A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Getting there: How to add coordinates and display order to script?

  1. #1

    Getting there: How to add coordinates and display order to script?

    Ok, I'm trying to make this script work with some pictures. Now I need to add something to this script so that when the pictures is involved, ie moused over or clicked on etc it moves to the front and, when clicked on, moves to the center of the page, then when clicked on again, as it would return to normal scale, also returns to its initial position and order. Any help is great, thanks alot!

    function ZoomButtons() {
    this.onRollOver = function() {
    this.maxScale = 200;
    this.scaleInc = 50;
    this.onEnterFrame = function() {
    if (this._xscale<this.maxscale) {
    this._xscale = this._yscale += this.scaleInc;
    } else {
    this._xscale = this._yscale=this.maxScale;
    delete this.onEnterFrame;
    }
    };
    };
    this.onPress = function() {
    this.scaleInc = 50;
    // set the increments at which you want the mc to scale
    this.onEnterFrame = function() {
    if (this._xscale>150) {
    this._xscale = this._yscale -= this.scaleInc;
    } else {
    this._xscale = this._yscale=150;
    delete this.onEnterFrame;
    }
    };
    };
    this.onRelease = function() {
    if(_level0.button_pressed_once == false){
    this.scaleInc = 50;
    // set the increments at which you want the mc to scale
    this.onEnterFrame = function() {
    if (this._xscale>500) {
    this._xscale = this._yscale -= this.scaleInc;
    } else {
    this._xscale = this._yscale=500;
    delete this.onEnterFrame;
    }
    };
    _level0.button_pressed_once = true;
    } else {
    this.scaleInc = 50;
    // set the increments at which you want the mc to scale
    this.onEnterFrame = function() {
    if (this._xscale>100) {
    this._xscale = this._yscale -= this.scaleInc;
    } else {
    this._xscale = this._yscale=100;
    delete this.onEnterFrame;
    }
    };
    _level0.button_pressed_once = false;
    }
    };
    this.onRollOut = function() {
    this.scaleInc = 50;
    // set the increments at which you want the mc to scale
    this.onEnterFrame = function() {
    if (this._xscale>100) {
    this._xscale = this._yscale -= this.scaleInc;
    } else {
    this._xscale = this._yscale=100;
    delete this.onEnterFrame;
    }
    };
    };
    }

    ButtonArray = new Array (ZoomBtn, ZoomBtn1, ZoomBtn2, ZoomBtn3, ZoomBtn4, ZoomBtn5, ZoomBtn6, ZoomBtn7, ZoomBtn8, ZoomBtn9, ZoomBtn10, ZoomBtn11, ZoomBtn12)

    for (var i = 0; i < ButtonArray.length; i++){
    var who = ButtonArray[i]
    ZoomButtons.apply (who)
    }

  2. #2
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    This is a quick answer, but it should help.

    What you can try doing is changing the onPress handler each time you click on the image. Here's a little example:

    code:

    _global.initMyImage = function() {
    myImage.onPress = function() {
    this._xscale = 200
    this._yscale = 200
    //this is the key:
    this.onPress = function() {
    //now the onPress handler is different
    this._xscale = 300
    this._yscale = 300
    this.onPress = function() {
    this._xscale = 400
    this._yscale = 400
    initMyImage() // this will reinit the image back to the original onPress handler
    }
    }
    }
    }
    initMyImage()



    This should be the way you want to approach your objective.

    Hope this helps!


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  3. #3
    well i see how that can change the positioning, but how about brining an MC to the front since most become obscured

  4. #4
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Use myMovieClip.swapDepths(1000) to change the depth of a MC. Probably just put this on your onPress handler as this.swapDepths(1000) if 1000 doesn't work for you, try a higher number.


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  5. #5
    -Iron Myk- mykrob's Avatar
    Join Date
    Dec 2001
    Location
    Jackson, TN
    Posts
    1,356

    question for lightwave

    Hey,
    how did you do the actionscript formatting a few posts up?

    thanks,
    -myk

  6. #6
    had hibernation.....
    Join Date
    Jul 2000
    Posts
    28
    hey mykrob ,try PHP when u type
    "?" is the most facinating thing in this world.

  7. #7
    -Iron Myk- mykrob's Avatar
    Join Date
    Dec 2001
    Location
    Jackson, TN
    Posts
    1,356
    yeah, i know you can do that:

    PHP Code:
    not what i'm looking for 
    but as showsn above, it shows PHP formatting, not actionscript like in lightwave's post

    reciprocal

  8. #8
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Use &#91;AS&#93; and &#91;/AS&#93; around your ActionScript.


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


  9. #9
    -Iron Myk- mykrob's Avatar
    Join Date
    Dec 2001
    Location
    Jackson, TN
    Posts
    1,356
    thanks!

  10. #10
    actually i dont think this helps. Im trying to change the x and y coordinates so that the enlarged MC is positioned in the center of the frame and then returns to its orignal coordinates when it either is clicked a second time or is moused out of... Also trying to work in that SwapDepths thing. Man, I'm such a newb.
    Any ideas?
    Originally posted by Lightwave Network
    This is a quick answer, but it should help.

    What you can try doing is changing the onPress handler each time you click on the image. Here's a little example:

    code:

    _global.initMyImage = function() {
    myImage.onPress = function() {
    this._xscale = 200
    this._yscale = 200
    //this is the key:
    this.onPress = function() {
    //now the onPress handler is different
    this._xscale = 300
    this._yscale = 300
    this.onPress = function() {
    this._xscale = 400
    this._yscale = 400
    initMyImage() // this will reinit the image back to the original onPress handler
    }
    }
    }
    }
    initMyImage()



    This should be the way you want to approach your objective.

    Hope this helps!

  11. #11
    boink

  12. #12
    bink

  13. #13
    Lifesaver Lightwave Network's Avatar
    Join Date
    Sep 2002
    Location
    Denver, CO, USA
    Posts
    649
    Could you paste the exact scripts you're currently using and explain to me what's happening with your current scripts? I should be able to help from there.


    ... gimme just one more line of code to ease the pain.

    http://www.ln.tv
    http://www.davevillano.com
    http://www.premierloftsdenver.com
    http://www.backyard.cc -- coming soon!


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