Copy link to clipboard
Copied
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
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);
}
////////////////////////////////////////////////
Copy link to clipboard
Copied
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);
}
//////////////////////////////////////////////////////
Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
you're welcome.
Copy link to clipboard
Copied
Unexpectedly I'm fighting now with the Bounce Checkers...
do you have some smart solution?
Edit:
I invented this:
/////////////////////////
navL_mc.addEventListener(MouseEvent.MOUSE_OVER, navL_Over);
navL_mc.addEventListener(MouseEvent.MOUSE_OUT, navL_Out);
function navL_Over(e:MouseEvent){
if(scena_mc.x == 0){
scena_mc.x += 0;
}
else if(scena_mc.x <= 0){
scena_mc.x += 10;
navL_mc.addEventListener(Event.ENTER_FRAME, runL);
}
}
function runL(e:Event):void{
if(scena_mc.x == 0){
scena_mc.x += 0;
}
else if(scena_mc.x <= 0){
scena_mc.x += 10;
}
}
//////////////////////////////////
and it works
Copy link to clipboard
Copied
but the movement of the scene is chopped, not smooth do anybody know any solution how to fix it? probably with different way than "scena_mc.x += 10;"
Copy link to clipboard
Copied
the boundary check should be in runL and you typically do not want to do an exact position check.
if you don't understand how to implement your boundary check(s), what are the boundaries and what do you want to happen if a boundary is reached?
Copy link to clipboard
Copied
I know what are the boundaries, but I dont have lots of sexperience with AS - I dont know lots of possibilities, so I have to invented my own solution in my head and use google, if it is possible
If you can give me "lerarning lesson" abou implementing boundaries, I will by glad to you
Copy link to clipboard
Copied
what are the boundaries and what do you want to happen if a boundary is reached?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
i can't see your app. i do not know the x value of scena_mc when your app starts and at what value of x scena_mc should stop changing its x value because of a boundary.
Copy link to clipboard
Copied
scene_mc start at x = -550... x wide is 2164 px
now I have this and its working...
/////////////////////////////////////////
navL_mc.addEventListener(MouseEvent.MOUSE_OVER, navL_Over);
navL_mc.addEventListener(MouseEvent.MOUSE_OUT, navL_Out);
function navL_Over(e:MouseEvent){
if(scena_mc.x == 0){
scena_mc.x == 0;
}
else if(scena_mc.x <= -10){
scena_mc.x += 10;
navL_mc.addEventListener(Event.ENTER_FRAME, runL);
}
}
function runL(e:Event):void{
if(scena_mc.x == 0){
scena_mc.x == 0;
}
else if(scena_mc.x <= -10){
scena_mc.x += 10;
}
}
function navL_Out(e:MouseEvent){
navL_mc.removeEventListener(Event.ENTER_FRAME, runL);
}
//
navR_mc.addEventListener(MouseEvent.MOUSE_OVER, navR_Over);
navR_mc.addEventListener(MouseEvent.MOUSE_OUT, navR_Out);
function navR_Over(e:MouseEvent){
if(scena_mc.x == -1164){
scena_mc.x == -1164;
}
else if(scena_mc.x >= -1154){
scena_mc.x -= 10;
navR_mc.addEventListener(Event.ENTER_FRAME, runR);
}
}
function runR(e:Event):void{
if(scena_mc.x == -1164){
scena_mc.x == -1164;
}
else if(scena_mc.x >= -1154){
scena_mc.x -= 10;
}
}
function navR_Out(e:MouseEvent){
navR_mc.removeEventListener(Event.ENTER_FRAME, runR);
}
////////////////////////////////////
Copy link to clipboard
Copied
sounds good.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now