A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: rollOver/rollOut button

  1. #1
    Member
    Join Date
    Apr 2003
    Posts
    43

    rollOver/rollOut button

    i am trying to do rollOut/RollOver function...when mouseover the button, it moves and stops at 200...

    I think that i implemented onEnterFrame code wrongly.

    xspeed=5;
    right=200;
    left=50;

    this.ball_mc.onRollOver=overFunction;
    this.ball_mc.onRollOut=outFunction;


    function overFunction() {

    function onEnterFrame() { //i suspect that the way i wrote is wrong..
    this._x+=xspeed();
    if (this._x>right) {
    delete this.onEnterFrame;
    }

    }

    }

    function outFunction() {

    this._x-=xspeed();

    if (this._x<left) {
    delete this.onEnterFrame;
    }

    }

  2. #2
    Prid - Outing Nig 13's Avatar
    Join Date
    Jul 2006
    Location
    Norway
    Posts
    1,864
    onEnterFrame = function(){

    I am back, guys ... and finally 18 :P

    BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS

  3. #3
    Member
    Join Date
    Apr 2003
    Posts
    43
    it seems not to be working..when i mouseover the button, nothing happens..could my code be written wrongly?

    xspeed=5;
    right=200;
    left=50;

    this.ball_mc.onRollOver=overFunction;
    this.ball_mc.onRollOut=outFunction;


    function overFunction() {

    onEnterFrame = function() {
    this._x+=xspeed();
    if (this._x>right) {
    delete this.onEnterFrame;
    }

    }

    }

    function outFunction() {

    this._x-=xspeed();

    if (this._x<left) {
    delete this.onEnterFrame;
    }

    }

  4. #4
    Senior Member
    Join Date
    Nov 2004
    Posts
    928
    xspeed is a variable not a function and you need onEnreFrame in the rollOut function. As a point to note you would get smoother movement using setInterval.
    xspeed=5;
    right=200;
    left=50;

    this.ball_mc.onRollOver=overFunction;
    this.ball_mc.onRollOut=outFunction;


    function overFunction() {

    this.onEnterFrame = function() {
    this._x+=xspeed;
    if (this._x>right) {
    delete this.onEnterFrame;
    }

    }

    }

    function outFunction() {
    this.onEnterFrame = function() {
    this._x-=xspeed;

    if (this._x<left) {
    delete this.onEnterFrame;
    }
    }
    }

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