PHP User Warning: fetch_template() calls should be replaced by the vB_Template class. Template name: bbcode_highlight in ..../includes/functions.php on line 4197
Slide object up on rollover and down on rollout HELP
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
    Posts
    1

    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
    Posts
    3,518
    Code:
    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.y=ends;
    		evt.currentTarget.removeEventListener(Event.ENTER_FRAME, up);
    	} else {
    		evt.currentTarget.y-=diff/12;
    	}
    }
    
    function down(evt:Event) {
    	var diffd:Number=begs-evt.currentTarget.y;
    	if (Math.abs(diffd)<=1) {
    		evt.currentTarget.y=begs;
    		evt.currentTarget.removeEventListener(Event.ENTER_FRAME, down);
    	} else {
    		evt.currentTarget.y+=diffd/12;
    	}
    }

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