我一直在研究这个问题三天三夜。 我必须为uni建立一个网站,我已经完成了我的布局和内容等。 菜单也很完整,除了我无法做到我想做的事情。
一些帮助将不胜感激,因为我在AS3是一个完整的新手,不知道如何解决我的问题。
这就是我想要发生的事情:
关于我的菜单的一些细节:
动画本身(活动图像滑入和滑出视图)和超链接工作正常,但我不知道如何编写它来做其他事情。
它由背景图像组成,背景图像基本上是非活动状态的按钮。 它包含菜单中每个项目的不可见命中框,因为活动图像位于可见菜单区域之外(隐藏在主要内容区域后面) 活动图像从左侧滑入视图,覆盖其各自(非活动)按钮的背景区域。
我希望有道理^^
到目前为止,这是我的代码:
import fl.transitions.Tween;
import fl.transitions.easing.*;
hit_home.addEventListener(MouseEvent.ROLL_OVER, OverHome);
hit_resume.addEventListener(MouseEvent.ROLL_OVER, OverResume);
home.addEventListener(MouseEvent.ROLL_OVER, OverHome);
home.addEventListener(MouseEvent.ROLL_OUT, OutHome);
home.addEventListener(MouseEvent.CLICK, ClickHome);
home.addEventListener(MouseEvent.MOUSE_DOWN, DownHome);
resume.addEventListener(MouseEvent.ROLL_OVER, OverResume);
resume.addEventListener(MouseEvent.ROLL_OUT, OutResume);
resume.addEventListener(MouseEvent.CLICK, ClickResume);
resume.addEventListener(MouseEvent.MOUSE_DOWN, DownResume);
hit_resume.buttonMode = hit_home.buttonMode = home.buttonMode = resume.buttonMode = true;
hit_resume.useHandCursor = hit_home.useHandCursor = home.useHandCursor = resume.useHandCursor = true;
//i was trying to save the x-position of the home button prior to the animation.
//var home:int=x=0;
//var home_original:int=home.x;
// I failed miserably.
var animation:Tween;
// home button stuff
function OverHome (e:MouseEvent):void
{
animation = new Tween(home, "x", Elastic.easeOut, home.x, 124, 1, true);
}
function OutHome (e:MouseEvent):void
{
animation = new Tween(home, "x", Elastic.easeOut, home.x, -124, 1, true);
}
function ClickHome(e:MouseEvent):void
{
navigateToURL(new URLRequest(""), "");
}
function DownHome(e:MouseEvent):void{
home.gotoAndStop(1);
}
//resume button stuff
function OverResume (e:MouseEvent):void
{
animation = new Tween(resume, "x", Elastic.easeOut, resume.x, 124, 1, true);
}
function OutResume (e:MouseEvent):void
{
animation = new Tween(resume, "x", Elastic.easeOut, resume.x, -124, 1, true);
}
function ClickResume(e:MouseEvent):void
{
navigateToURL(new URLRequest(""), "");
}
function DownResume(e:MouseEvent):void{
resume.gotoAndStop(1);
}
是的,这个剧本很臃肿,超级笨拙,但这就是我能管理的。
关于如何正确完成任务的任何建议?
先谢谢。
P.S .: 如果你需要查看.swf文件,请告诉我,我将提供一个链接。
编辑:
我想我现在设法解决它^^但也许你可以帮我清理我的代码所以它不再那么臃肿了吗?
// Import classes needed for tweening
import fl.transitions.Tween;
import fl.transitions.easing.*;
hit_home.addEventListener(MouseEvent.CLICK, ClickHome);
hit_resume.addEventListener(MouseEvent.CLICK, ClickResume);
home.addEventListener(MouseEvent.CLICK, ClickHome);
hit_home.addEventListener(MouseEvent.MOUSE_UP, UpHome);
resume.addEventListener(MouseEvent.CLICK, ClickResume);
hit_resume.addEventListener(MouseEvent.MOUSE_UP, UpResume);
hit_resume.buttonMode = hit_home.buttonMode = home.buttonMode = resume.buttonMode = true;
hit_resume.useHandCursor = hit_home.useHandCursor = home.useHandCursor = resume.useHandCursor = true;
//i was trying to save the x-position of the home button prior to the animation.
//var home:int=x=0;
//var home_original:int=home.x;
// I failed miserably.
var animation:Tween;
// home button stuff
function ClickHome (e:MouseEvent):void
{
animation = new Tween(home, "x", Elastic.easeOut, home.x, 124, 1, true);
navigateToURL(new URLRequest(""), "");
}
//function OutHome (e:MouseEvent):void
// {
// animation = new Tween(home, "x", Elastic.easeOut, home.x, -124, 1, true);
// }
function UpHome(e:MouseEvent):void{
animation = new Tween(resume, "x", Elastic.easeOut, resume.x, -124, 1, true);
home.gotoAndStop(1);
}
//resume button stuff
function ClickResume (e:MouseEvent):void
{
animation = new Tween(resume, "x", Elastic.easeOut, resume.x, 124, 1, true);
navigateToURL(new URLRequest(""), "");
}
//function OutResume (e:MouseEvent):void
// {
// animation = new Tween(resume, "x", Elastic.easeOut, resume.x, -124, 1, true);
// }
function UpResume(e:MouseEvent):void{
animation = new Tween(home, "x", Elastic.easeOut, home.x, -124, 1, true);
resume.gotoAndStop(1);
}