Copy link to clipboard
Copied
Hello,
I would be most grateful of your help. I'm working on a project for my students, using CS6, AS3 and we are to create a basic button navigation with a submenu. My problem is that the animation won't stop at the given keyframes and just runs on. The submenu doesn't show up either. Thanks in advance for your help.
Here is the AS3 code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import flash.events.MouseEvent;
var scene:String="";
var submenuVisible:Boolean=false;
var myTweenAlpha:Tween;
submenu.mouseEnabled=false;
submenu.mouseChildren=false;
stop();
btn_home.addEventListener(MouseEvent.CLICK, NavigateHome);
function NavigateHome(event:MouseEvent):void
{
scene="Home";
submenuVisible=false;
CheckSubmenu();
play()
}
btn_subjects.addEventListener(MouseEvent.CLICK, NavigateSubjects);
function NavigateSubjects (event:MouseEvent):void
{
scene="Subjects";
submenuVisible=true;
CheckSubmenu();
play();
}
btn_about.addEventListener(MouseEvent.CLICK, NavigateAbout);
function NavigateAbout(event:MouseEvent):void
{
scene="About";
submenuVisible=false;
CheckSubmenu();
play();
}
btn_enquiry.addEventListener(MouseEvent.CLICK, NavigateEnquiry);
function NavigateEnquiry (event:MouseEvent):void
{
scene="Enquiry";
submenuVisible=false;
CheckSubmenu();
play();
}
function CheckSubmenu():void
{
if (submenuVisible==true)
{
myTweenAlpha= new Tween(submenu, "alpha",
Strong.easeInOut, submenu.alpha, 1, 1.5, true);
submenu.mouseEnabled=true;
submenu.mouseChildren=true;
}
else if (submenuVisible==false)
{
myTweenAlpha= new Tween(submenu, "alpha",
Strong.easeInOut, submenu.alpha, 0, 1.5, true);
submenu.mouseEnabled=false;
submenu.mouseChildren=false;
}
}
submenu.btn_subject1.addEventListener(MouseEvent.CLICK),
NavigateSubject1);
function NavigateSubject1 (event:MouseEvent):void
{
scene="Subject1";
play();
}
submenu.btnsubject2.addEventListener(MouseEvent.CLICK
NavigateSubject2);
function NavigateSubject2 (event:MouseEvent):void
{
scene="Subject2";
play();
}
submenu.btn_subject3.addEventListener(MouseEvent.CLICK,
NavigateSubject3);
function NavigateSubject3 (event:MouseEvent):void
{
scene="Subject3";
play();
}
submenu.btn_subject4.addEventListener(MouseEvent.CLICK,
NavigateSubject4);
function NavigateSubject4 (event:MouseEvent):void
{
scene="Subject4";
play()
}
submenu.btn_subject5.addEventListener(MouseEvent.CLICK,
NavigateSubject5);
function NavigateSubject5 (event:MouseEvent):void
{
scene="Subject5";
play();
}
Copy link to clipboard
Copied
I don't see anything in the code that looks like it is supposed to stop an animation. Where does that occur? Also, as far as the submenu not appearing, I cannot answer for that, but I would be concerned with it never disappearing if it does ever appear. YOu might want to check the logic you have for that to make sure you are telling it to appear when you want it to. Also, you are using 1.5 as a parameter for alpha but after 1 you would be wasting effort as visually the alpha cannot get any stronger than 1.
Copy link to clipboard
Copied
Hi Ned,
Thank you very much for your feedback and I'll check out those points.
Regards,
Anna.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now