views:

410

answers:

3

hei,

I am not able to restrict this code to scroll only the front_mc and back_mc, in the front_mc are nested buttons that work and showing content on click - but the mouse-movement gets captured all the time so also content of the menu gets scrolled, when mouse is moved. please help me guys, I am not fit enough to deal with it.

root.addEventListener(MouseEvent.MOUSE_MOVE,f);

var t:Timer=new Timer(40,0); t.addEventListener(TimerEvent.TIMER,moveF); function f(e:MouseEvent) { t.stop(); t.start(); } var speed:Number = .9;

function moveF(e:TimerEvent) { front_mc.x =speed*front_mc.x+(1-speed)*(stage.stageWidth-front_mc.width)*root.mouseX/stage.stageWidth; back_mc.x = speed*back_mc.x+(1-speed)*(stage.stageWidth-back_mc.width)*root.mouseX/stage.stageWidth; if (Math.abs(front_mc.x- (stage.stageWidth-front_mc.width)*root.mouseX/stage.stageWidth)<1 && Math.abs(back_mc.x-(stage.stageWidth-back_mc.width)*root.mouseX/stage.stageWidth)<1) { front_mc.x = (stage.stageWidth-front_mc.width)*root.mouseX/stage.stageWidth; back_mc.x = (stage.stageWidth-back_mc.width)*root.mouseX/stage.stageWidth; t.stop();

}
e.updateAfterEvent();

}

A: 

unfortunatly, it doesn't change the behaviour :( but thank you very much for this hint

what it does & should do: this front_mc is horizontally scrolling a menu if the mousesY is 90 and 250 (its row of buttons is longer than the stage) the buttons and their common timeline are nested as menu_mc inside the front_mc.

if I go sidewards over the menu and its scrolling left/right & I hit a button the content is drawn, but when I head back to the menu and it's scrolling, so does the drawn content, analogue to the menu (synched). I must have organized it wrong.

front_mc.addEventListener(MouseEvent.MOUSE_MOVE,f); var t:Timer=new Timer(30,0); t.addEventListener(TimerEvent.TIMER,moveF);

function f(e:MouseEvent) { if(root.mouseY > 90 && root.mouseY < 250) { t.start(); } else { t.stop(); } } var speed:Number = .9; function moveF(e:TimerEvent) { front_mc.x =speed*front_mc.x+(1-speed)*(stage.stageWidth-front_mc.width)*root.mouseX/stage.stageWidth; back_mc.x = speed*back_mc.x+(1-speed)*(stage.stageWidth-back_mc.width)*root.mouseX/stage.stageWidth; if (Math.abs(front_mc.x- (stage.stageWidth-front_mc.width)*root.mouseX/stage.stageWidth)<1 && Math.abs(back_mc.x-(stage.stageWidth-back_mc.width)*root.mouseX/stage.stageWidth)<1) { front_mc.x = (stage.stageWidth-front_mc.width)*root.mouseX/stage.stageWidth; back_mc.x = (stage.stageWidth-back_mc.width)*root.mouseX/stage.stageWidth; t.stop();

} e.updateAfterEvent(); }

A: 

solved.

since _root.gotoAndStop(); from AS1-2 got removed, the easiest way in Actionscript3 AS3 to reference e.g. a Button inside a mc to call content to stage is

MovieClip(root).gotoAndStop("Marker1");

I thought I don't have a Movieclip on the Main Timeline MTL, but it realy works, set it as the action for your nested buttons and you are free from surprises: like in my case

I nested the scrolling menu (front_mc) inside a mc on MTL and the content gets called on the mainstage, without being hijacked by my moving front_mc

A: 

You use too much words and code. You can add simple if(hitTest) exception.

Konrad