A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Slide object up on rollover and down on rollout HELP

  1. #1
    Junior Member
    Join Date
    Jun 2010

    Slide object up on rollover and down on rollout HELP

    I have a site im making that has the text which i want to slide up on rollover and slide back down on rollout, I was able to get it to slide up but not back down all the way or back up all the way once it slid down halfway. It also doesn't wait for rollover to slide up if i leave the page and come back.

    Here is my code:
    Actionscript Code:
    var endhome = 582.6

    addEventListener(MouseEvent.ROLL_OVER, roll);

    while roll(evt:MouseEvent){

    addEventListener(Event.ENTER_FRAME, up)

    function up(evt:Event){
        var diff = hometext.y - endhome;
        hometext.y -= diff/12

    var homedown = 732.6

    addEventListener(MouseEvent.ROLL_OUT, rolldown);

    function rolldown(evt:MouseEvent){
    addEventListener(Event.ENTER_FRAME, down)

    function down(evt:Event){
        var diffdown = homedown - hometext.y;
        hometext.y += diffdown/12

  2. #2
    Join Date
    Dec 2002
    var ends:Number=82;
    var begs:Number=32;
    hometext.addEventListener(MouseEvent.ROLL_OVER, roll);
    hometext.addEventListener(MouseEvent.ROLL_OUT, rolldown);
    function roll(evt:MouseEvent) {
    	evt.currentTarget.addEventListener(Event.ENTER_FRAME, up);
    	evt.currentTarget.removeEventListener(Event.ENTER_FRAME, down);
    function rolldown(evt:MouseEvent) {
    	evt.currentTarget.addEventListener(Event.ENTER_FRAME, down);
    	evt.currentTarget.removeEventListener(Event.ENTER_FRAME, up);
    function up(evt:Event) {
    	var diff:Number=evt.currentTarget.y-ends;
    	if (Math.abs(diff)<=1) {
    		evt.currentTarget.removeEventListener(Event.ENTER_FRAME, up);
    	} else {
    function down(evt:Event) {
    	var diffd:Number=begs-evt.currentTarget.y;
    	if (Math.abs(diffd)<=1) {
    		evt.currentTarget.removeEventListener(Event.ENTER_FRAME, down);
    	} else {

Tags for this Thread

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