Skip to main content
Participating Frequently
January 22, 2014
Answered

Moving scene to left and right - MOUSE_OVER

  • January 22, 2014
  • 1 reply
  • 1012 views

Hi guys,

i dont work in Flash for a 2 years and i forgot lots of my AS 3.0 knowledge.

What is the most effective way to make my scene moving to left and right?

I start file like this:

- wide movieclip "Scena_mc"

- at left and right side there are movieclips for navigation ("Nav_L_mc" and "Nav_R_mc")

/////////////////////////////////////////////////////////

Nav_L_mc.addEventListener(MouseEvent.MOUSE_OVER, Nav_L_Over);

Nav_L_mc.addEventListener(MouseEvent.ENTER_FRAME, run);

function Nav_L_Over(e:MouseEvent){

          Scena_mc.x += 10;

}

function Nav_R_Over(e:MouseEvent){

          Scena_mc.x -= 10;

}

//////////////////////////////////////////////////////

but how can I do it repeatly as lond as the mouse is over?

Thaks guys a lot

This topic has been closed for replies.
Correct answer kglad

use:

/////////////////////////////////////////////////////////

Nav_L_mc.addEventListener(MouseEvent.MOUSE_OVER, Nav_L_Over);

Nav_L_mc.addEventListener(MouseEvent.MOUSE_UT, Nav_L_Out);

function Nav_L_Over(e:MouseEvent){

Nav_L_mc.addEventListener(Event.ENTER_FRAME, run);

          Scena_mc.x += 10;

}

function run(e:Event):void{

Scena_mc.x+=10;

//use a boundary check

}

function Nav_L_Out(e:MouseEvent){

        Nav_L_mc.removeEventListener(Event.ENTER_FRAME, run);

}

//////////////////////////////////////////////////////

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 22, 2014

use:

/////////////////////////////////////////////////////////

Nav_L_mc.addEventListener(MouseEvent.MOUSE_OVER, Nav_L_Over);

Nav_L_mc.addEventListener(MouseEvent.MOUSE_UT, Nav_L_Out);

function Nav_L_Over(e:MouseEvent){

Nav_L_mc.addEventListener(Event.ENTER_FRAME, run);

          Scena_mc.x += 10;

}

function run(e:Event):void{

Scena_mc.x+=10;

//use a boundary check

}

function Nav_L_Out(e:MouseEvent){

        Nav_L_mc.removeEventListener(Event.ENTER_FRAME, run);

}

//////////////////////////////////////////////////////

Participating Frequently
January 22, 2014

Thanks a lot! i find similiarly solution yesterday, but it wasnt working... in your code was also error "Access to properties ENTER_FRAME, possibly undefined, through a reference with static type Class." but I googled it and find the bug - ENTER_FRAME is an Event, not MoiuseEvent.

noow it looks like this and its working totaly great:

////////////

Nav_L_mc.addEventListener(MouseEvent.MOUSE_OVER, Nav_L_Over);

Nav_L_mc.addEventListener(MouseEvent.MOUSE_OUT, Nav_L_Out);

function Nav_L_Over(e:MouseEvent){

Nav_L_mc.addEventListener(Event.ENTER_FRAME, run);

          Scena_mc.x += 10;

}

function run(e:Event):void{

Scena_mc.x+=10;

//use a boundary check

}

function Nav_L_Out(e:MouseEvent){

        Nav_L_mc.removeEventListener(Event.ENTER_FRAME, run);

}

////////////////////////////

Thanks a lot!

Participating Frequently
January 22, 2014

what are the boundaries and what do you want to happen if a boundary is reached?


of course... teoretically I know how to do it, but I dont know the concrete tags for boundaries and cognations to scene and make the scene stop at the boundaries...

Im sory for my stupidity, Im just an artist learning code because of final exams