A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: mouse detect doesn't work, please check the code

  1. #1
    Senior Member
    Join Date
    Mar 2002
    Posts
    185

    mouse detect doesn't work, please check the code

    Hi,

    What is wrong with that code , it doesn't work

    if (_root._xmouse > 390) {
    _root.don.gotoAndPlay(6);
    } else if (_root._xmouse < 390) {
    _root.don.gotoAndPlay(2);
    }

    There is a mc, intance name "don", that I want to act depending on mouse position.

    Thanks for your help

  2. #2
    Senior Member sprout74's Avatar
    Join Date
    Oct 2000
    Posts
    134
    in what event does this code live in?

    how often does it run?

    you could put it on the clip event enterFrame on the movie clip
    don, and then change the code from
    Code:
    _root.don.gotoAndPlay(6);
    to
    Code:
    this.gotoAndPlay(6);
    where 'this' is the MovieClip don.
    "If the implementation is hard to explain, it's a bad idea.
    If the implementation is easy to explain, it may be a good idea."
    from The Zen of Python (by Tim Peters)

  3. #3
    Senior Member
    Join Date
    Mar 2002
    Posts
    185
    Thanks for the reply.
    It still doesn't work.I tried to put the code in the first frame of mc"don".
    Normally, I put the code in the first frame of main timeline.

    There is another code on the page which I get from movie from Flashkit that helps the panoramic view.

    That code is;

    // Parametros
    anchoPelicula = 780;
    altoPelicula = 410;
    acel = 40;
    // Operaciones
    fondo_mc._width = anchoPelicula;
    fondo_mc._height = altoPelicula;
    fondo_mc._x = 0;
    fondo_mc._y = 380;
    acel /= 40;
    panoramica_mc._y = 40;
    panoramica2_mc._y = 40;
    mitad = anchoPelicula/2;
    ancho = panoramica_mc._width;
    panoramica_mc._x = 0;
    panoramica2_mc._x = (0-ancho);
    // Al pasar el mouse encima
    fondo_mc.onRollOver = function() {
    mover();
    };
    fondo_mc.onRollOut = function() {
    delete panoramica_mc.onEnterFrame;
    };
    // Funcion Mover
    function mover() {
    panoramica_mc.onEnterFrame = function() {
    if (_xmouse != mitad) {
    if (_xmouse<mitad) {
    inc = Math.abs(_xmouse-mitad)*(acel/10);
    //
    if (panoramica_mc._x>anchoPelicula || panoramica2_mc._x>anchoPelicula) {
    if (panoramica_mc._x>anchoPelicula) {
    panoramica_mc._x = (panoramica2_mc._x-ancho);
    } else {
    panoramica2_mc._x = (panoramica_mc._x-ancho);
    }
    panoramica_mc._x += inc;
    panoramica2_mc._x += inc;
    } else {
    panoramica_mc._x += inc;
    panoramica2_mc._x += inc;
    }
    //
    } else {
    inc = Math.abs(_xmouse-mitad)*(acel/10);
    if (panoramica_mc._x<(0-ancho) || panoramica2_mc._x<(0-ancho)) {
    if (panoramica_mc._x<(0-ancho)) {
    // trace("Paso panoramica 1");
    panoramica_mc._x = (panoramica2_mc._x+ancho);
    } else {
    // trace("Paso panoramica 2");
    panoramica2_mc._x = (panoramica_mc._x+ancho);
    panoramica_mc._x -= inc;
    panoramica2_mc._x -= inc;
    }
    } else {
    panoramica_mc._x -= inc;
    panoramica2_mc._x -= inc;
    }
    }
    }
    };
    }


    That code is for background and my character is on a layer over that one.

    Any idea?

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