View Full Version : MovieClip follow menu items
andy killer
June 16th, 2009, 04:49 AM
Hello Guys.
I'm quitte new to the forum, so be gentle ;)
I'm making a Website, where the the menu will have a luminous movieclip which follows the menu items around and stays there.
This is what I have so far:
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
function mouseMove(event:MouseEvent) {
menubar_mc.x = menubar_mc.parent.mouseX;
}
I actualy have no ideia how to make this in AS3 :(
If you know some tutorial or could help me out I'd be really thankfull ;)
marc_
June 16th, 2009, 05:24 AM
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
function mouseMove(event:MouseEvent) {
menubar_mc.x = mouseX;
}
or
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
function mouseMove(event:MouseEvent) {
menubar_mc.x = stage.mouseX;
}
if stage is not known yet. wait for it.
addEventListener(Event.ADDED_TO_STAGE,init);
function init(e:Event):void{
//heres the stage
}
andy killer
June 16th, 2009, 05:41 AM
Thanks Marc.
Do you know a way of blocking the movement of the movieclip?
I want the movement to be confined to just the area of the movieclip where the menu items are. Once the mouse leaves the area, the movement stops.
Do you know a way?
Thanks ;)
[QUOTE=marc_;2476615]
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
function mouseMove(event:MouseEvent) {
menubar_mc.x = mouseX;
}
marc_
June 16th, 2009, 06:00 AM
you can create an invsible box or you can just check the current x/y pos.
//box method:
var startX:int = 100;
var startY:int = 100;
var areaWidth :int = 500;
var areaHeight:int = 400;
var box:Sprite = new Sprite();
box.graphics.beginFill(0xff0000,0);
box.graphics.drawRect(0,0, areaWidth, areaHeight);
box.graphics.endFill();
addChild(box);
box.addEventListener(MouseEvent.MOUSE_OVER,startMo ve);
box.addEventListener(MouseEvent.MOUSE_OUT,stopMove );
function startMove(e:MouseEvent):void{
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
}
function stopMove(e:MouseEvent):void{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
}
//other method
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMove);
function mouseMove(event:MouseEvent) {
var startX:int = 100;
var startY:int = 100;
var areaWidth :int = 500;
var areaHeight:int = 400;
if(mouseX < startX) return;
if(mouseX > startX+areaWidth) return;
menubar_mc.x = mouseX;
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.