OK, I give up... I need help!

  • Abelius
  • Proficient
  • Proficient
  • User avatar
  • Posts: 260
  • Loc: Miami Beach, FL, USA

Post 3+ Months Ago

I have been searching in this forum for two days now, and I didn't find my answer...
Here is the problem:

I created a dynamic mc using _root.attachMovie and I placed two buttons on the main stage. One of them sends the object a little up, theother one a little down, using easing with destX and destY. Everything is fine and here is the code if you need it:

Code: [ Select ]
this = _root.attachMovie("box_1_mc", "mc", layerNumber);
layerNumber++;
// ==============================================
function move_down(obj, initpos) {
    var destY = initpos + 55;
    move_y(obj, destY);
}
function move_up(obj, initpos) {
    var destY = initpos - 55;
    move_y(obj, destY);
}
// ==============================================
function move_y(obj, destY) {
    eval(obj).onEnterFrame = function() {
        eval(obj)._y += (destY - eval(obj)._y) / 4;
        Math.ceil(eval(obj)._y) == destY ? delete eval(obj).onEnterFrame : doNothing();
    };
}
// ==============================================
_root.down_btn.onRelease = function() {
    move_down(_root.mc, getProperty(_root.mc, _y));
};
_root.up_btn.onRelease = function() {
    move_up(_root.mc, getProperty(_root.mc, _y));
};
  1. this = _root.attachMovie("box_1_mc", "mc", layerNumber);
  2. layerNumber++;
  3. // ==============================================
  4. function move_down(obj, initpos) {
  5.     var destY = initpos + 55;
  6.     move_y(obj, destY);
  7. }
  8. function move_up(obj, initpos) {
  9.     var destY = initpos - 55;
  10.     move_y(obj, destY);
  11. }
  12. // ==============================================
  13. function move_y(obj, destY) {
  14.     eval(obj).onEnterFrame = function() {
  15.         eval(obj)._y += (destY - eval(obj)._y) / 4;
  16.         Math.ceil(eval(obj)._y) == destY ? delete eval(obj).onEnterFrame : doNothing();
  17.     };
  18. }
  19. // ==============================================
  20. _root.down_btn.onRelease = function() {
  21.     move_down(_root.mc, getProperty(_root.mc, _y));
  22. };
  23. _root.up_btn.onRelease = function() {
  24.     move_up(_root.mc, getProperty(_root.mc, _y));
  25. };

All I have in my library is the element called "box_1_mc" with its linkage, and the button.
I click on the button UP and it goes up, easing nicely. Same with the down button. So far, so good...

But how do I make it ease up, stop then ease down...?

I tried this code:
Code: [ Select ]
_root.bounce_btn.onRelease = function() {
    move_up(_root.mc, getProperty(_root.mc, _y));
    move_down(_root.mc, getProperty(_root.mc, _y));
};
  1. _root.bounce_btn.onRelease = function() {
  2.     move_up(_root.mc, getProperty(_root.mc, _y));
  3.     move_down(_root.mc, getProperty(_root.mc, _y));
  4. };

Doesn't work... Pleeease, please, please. Any ideas?
  • still learning
  • Born
  • Born
  • still learning
  • Posts: 3

Post 3+ Months Ago

try this:

Code: [ Select ]
function move_upDown(obj, origin) {
  var destY = origin-55;
  eval(obj).onEnterFrame = function() {
   eval(obj)._y += (destY - eval(obj)._y) / 4;
   if(Math.ceil(eval(obj)._y) == destY) {
     delete eval(obj).onEnterFrame;
     move_down(_root.mc, getProperty(_root.mc, _y));
   }
  };
}

_root.bounce_btn.onRelease = function() {
  move_upDown(_root.mc, getProperty(_root.mc, _y))
};
  1. function move_upDown(obj, origin) {
  2.   var destY = origin-55;
  3.   eval(obj).onEnterFrame = function() {
  4.    eval(obj)._y += (destY - eval(obj)._y) / 4;
  5.    if(Math.ceil(eval(obj)._y) == destY) {
  6.      delete eval(obj).onEnterFrame;
  7.      move_down(_root.mc, getProperty(_root.mc, _y));
  8.    }
  9.   };
  10. }
  11. _root.bounce_btn.onRelease = function() {
  12.   move_upDown(_root.mc, getProperty(_root.mc, _y))
  13. };

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 21 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.