View Full Version : Need Help with Scrolling Menu (runs off stage)
bumble bee
December 5th, 2008, 02:51 AM
Can someone please help. This scrolling menu runs off the page and I don't know how to keep it in the boundaries of the stage. Any suggestions? I'll take anything. thank you!
Here is the AS and I have attached the file below!
var myShape:Shape = new Shape()
myShape.graphics.beginFill(0x7E00E3);
myShape.graphics.drawRect(50,10,450, 100)
addChild(myShape)
menu_mc.mask=myShape
stage.addEventListener(Event.ENTER_FRAME, movemenu);
function movemenu(myevent:Event):void {
menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 40;
}
scottc
December 5th, 2008, 03:06 AM
if(menu_mc.x > 0){
menu_mc.x = 0;
}
will cap it to 0
just do the same with your max cord...
bumble bee
December 5th, 2008, 03:33 AM
Thanks. Do you mean this?
if(menu_mc.x > 0){
menu_mc.x = 0;
}
if(menu_mc.mask > 0){
menu_mc.mask = 0;
}
I found this works, but it only stops the left side from running off. Can you explain more. Thanks!
scottc
December 5th, 2008, 03:45 AM
"if x is less then 0" (less than sign is ">")
"then x will be set to 0"
if(menu_mc.x > 0){
menu_mc.x = 0;
}
....
"if x is greater then 300" (greater than sign is "<")
"then x will be set to 300"
bumble bee
December 5th, 2008, 10:57 AM
Ok, I understand this part, but how do I determine what the maximum coordinate is? Would it be the size of the stage? or the size of the movieclip? By the way, thank you very much. I really appreciate it.
"if x is less then 0" (less than sign is ">")
"then x will be set to 0"
ActionScript Code:
if(menu_mc.x > 0){
menu_mc.x = 0;
}
....
"if x is greater then 300" (greater than sign is "<")
"then x will be set to 300"
bumble bee
December 5th, 2008, 11:20 AM
Does the registration point need to be in a specific spot? No matter what coordinate number I set the statement to, it still runs off the stage on the right side.
scottc
December 5th, 2008, 04:49 PM
Does the registration point need to be in a specific spot? No matter what coordinate number I set the statement to, it still runs off the stage on the right side.
if the reg point is on the left...
if(mc.x < stagewidth - mc.width){
if its on the right remove the "- mc.width"
and if its in the middle width/2
bumble bee
December 6th, 2008, 11:07 PM
it is Still not working properly. Again, I can get it to stop from running off on the right, but not on the left side.
Here is the current actionscript:
var myShape:Shape = new Shape()
myShape.graphics.beginFill(0x7E00E3);
myShape.graphics.drawRect(50,10,450, 100)
addChild(myShape)
menu_mc.mask=myShape
stage.addEventListener(Event.ENTER_FRAME, movemenu);
function movemenu(myevent:Event):void {
menu_mc.x = menu_mc.x + (0.5 * myShape.width - mouseX) / 10;
if (menu_mc.x>300) {
menu_mc.x=300;
}
if(menu_mc.x < stagewidth - menu_mc.width/2){
}
}
I'm also getting an error message from the last line "Variable stagewidth is not defined"
Thanks again for your help...I am new!
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.