Moving a symbol to a sertain location over time?

  • Warshy
  • Newbie
  • Newbie
  • Warshy
  • Posts: 6

Post 3+ Months Ago

HI i really need help with this.
I'm wodering if you could make symbol move to a location i.e. +50 on x over time in a onRelease action. Not making a symbol continously moving in one direction. I would like it to just be in one frame if that is possible. Also using a false/true code to let it know if the sumbol should move back to it's original position. by over time i mean not making the symbol move directly to that specific location, it would have a speed so it smothly slides to that place.

it's har dto explain, one example is in windows XP when you open a normal mapp window there is a menu to the left and when you click on a small button a menu slides down and when you click it again it slides back. Ofcourse it's easy to make in a button but that's not what i want. It should move using actions cript.

Thx! :D
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

onEnterFrame() is what you're looking for I believe.
on the button,
Code: [ Select ]
on(release){
  this._parent.movieClipToMove.easeX(xValue, slowness);
}
  1. on(release){
  2.   this._parent.movieClipToMove.easeX(xValue, slowness);
  3. }

replace "movieClipToMove" with the instance name of the movieclip you want to move. "xValue" is the position to move it to over time, & the lower the number you put for "slowness", the faster the movieclip will move.

Now for that to work you need this prototype in one of your timelines.
Code: [ Select ]
MovieClip.prototype.easeX = function(value, speed) {
  this.onEnterFrame = function() {
   this.xV = Math.floor(value-this._x);
   this.xV ? this._x += this.xV/speed : (this._x=value, delete this.onEnterFrame);
  }
}
  1. MovieClip.prototype.easeX = function(value, speed) {
  2.   this.onEnterFrame = function() {
  3.    this.xV = Math.floor(value-this._x);
  4.    this.xV ? this._x += this.xV/speed : (this._x=value, delete this.onEnterFrame);
  5.   }
  6. }

Nothing needs changed in that unless you want _y instead of _x.
  • Warshy
  • Newbie
  • Newbie
  • Warshy
  • Posts: 6

Post 3+ Months Ago

Thx man, really appreciate your help :) i'll try it out
  • Warshy
  • Newbie
  • Newbie
  • Warshy
  • Posts: 6

Post 3+ Months Ago

i noticed one thing that doesn't work:
Code: [ Select ]
this.lalala.easeY(this._y+80, 7);

insyead of searching for the _y of the button and adding iit with 80 it moves the symbol to "stage position" y80 and not to the button._y plus the 80.

i also tried this but turned out same:
Code: [ Select ]
yValue = this._y+80
this.lalala.easeY(yValue, 7);
  1. yValue = this._y+80
  2. this.lalala.easeY(yValue, 7);


is this something that that function can't nuderstand? with the stuff i'm trying to make i have to use getProperty + "number"


also, this is ez, but i'm new to AS: how can i make a code on the same button so that one symbol with that code of yours move to 2 places, back and forth. like:
if(isup = false)
"your code moving +"
isup = true

if(isup = true)
"your code moving -"
isup = false
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Code: [ Select ]
yValue = this.lalala._y+80
this.lalala.easeY(yValue, 7);
  1. yValue = this.lalala._y+80
  2. this.lalala.easeY(yValue, 7);

It was using the _y of the mC calling the action.

To move to & fro you can use somthing like this,
Code: [ Select ]
on(release){
if(this.lalala.yPos){
  this.lalala.yPos = this.lalala.yPos-80;
  this.lalala.easeY(this.lalala.yPos, 7);
  this.lalala.yPos = false;
}else{
  this.lalala.yPos = this.lalala._y+80;
  this.lalala.easeY(this.lalala.yPos, 7);
}
}
  1. on(release){
  2. if(this.lalala.yPos){
  3.   this.lalala.yPos = this.lalala.yPos-80;
  4.   this.lalala.easeY(this.lalala.yPos, 7);
  5.   this.lalala.yPos = false;
  6. }else{
  7.   this.lalala.yPos = this.lalala._y+80;
  8.   this.lalala.easeY(this.lalala.yPos, 7);
  9. }
  10. }
  • Warshy
  • Newbie
  • Newbie
  • Warshy
  • Posts: 6

Post 3+ Months Ago

yes, i wanted it to use the _y of the button calling the action, won't that work? can i use a "dummy mC" that is equal as big as the button and use that symbol's _y?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

Where is
Code: [ Select ]
this.lalala.easeY(this._y+80, 7);

Is it on the button wrapped like,
Code: [ Select ]
on(release){
 this.lalala.easeY(this._y+80, 7);
}
  1. on(release){
  2.  this.lalala.easeY(this._y+80, 7);
  3. }


Where is lalala ?, is it nested inside of the button ?

Right now it seems as if the _y of the button is 0.
Is the _height of the button 80 by any chance ?
  • Warshy
  • Newbie
  • Newbie
  • Warshy
  • Posts: 6

Post 3+ Months Ago

no, :D i figured it out now, it works for me. it seems that you can't get the _y of a button, right? cuz i made a dummy mC and then it wokred perfectly.
here is the code:
Code: [ Select ]
on (release) {
    if (this.mCtomove.yPos) {
        this.mCtomove.yPos = this.dummymC._y-45;
        this.mCtomove.easeY(this.mCtomove.yPos, 7);
        this.mCtomove.yPos = false;
    } else {
        this.mCtomove.yPos = this.dummymC._y+10;
        this.mCtomove.easeY(this.mCtomove.yPos, 7);
    }
}
  1. on (release) {
  2.     if (this.mCtomove.yPos) {
  3.         this.mCtomove.yPos = this.dummymC._y-45;
  4.         this.mCtomove.easeY(this.mCtomove.yPos, 7);
  5.         this.mCtomove.yPos = false;
  6.     } else {
  7.         this.mCtomove.yPos = this.dummymC._y+10;
  8.         this.mCtomove.easeY(this.mCtomove.yPos, 7);
  9.     }
  10. }


if you take away the dummymC as in your code :P there's a strange way the mC is moving if u stress click on the button. it sorta moves to where ever it wants to :D
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13504
  • Loc: Florida

Post 3+ Months Ago

:scratchhead: I'm just going to read this tomarrow, maybe it will make sense then :lol:
  • Warshy
  • Newbie
  • Newbie
  • Warshy
  • Posts: 6

Post 3+ Months Ago

heh, :D well anyway thx for the help man, now it works like the Xp menu :wink:
[flash width=175 height=365 loop=false]http://hem.bredband.net/elfsoftwilight/menu.swf[/flash]

maybe the flashmovie will help you understand :P
you see there's a small black window on the top left of each button, that's the dummy mC.


oh, and one Q: i recently noticed that the flash tag has the wmode transparent code already in it. i have a invisionfree board and i would like to have that setting too :)

Post Information

  • Total Posts in this topic: 10 posts
  • Users browsing this forum: No registered users and 5 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.