Copy link to clipboard
Copied
Hi,
I'm having this issue throughout my program. I'm not well versed in Flash. Here's the code:
import flash.events.MouseEvent;
stop();
emer_cont_btn.enabled = true;
emer_exit_btn.enabled = true;
emer_help_btn.enabled = true;
emer_glossary_btn.enabled = true;
emer_mm_btn.enabled = true;
emer_btn.enabled = true;
emer_cont_btn.addEventListener(MouseEvent.CLICK, Cont2e);
function Cont2e(event:MouseEvent):void
{
emerstory01.stop();
gotoAndStop("3E");
}
emer_btn.addEventListener(MouseEvent.CLICK, Emer2e);
function Emer2e(event:MouseEvent):void
{
emerstory01.stop();
gotoAndStop("1E","Emer");
}
emer_exit_btn.addEventListener(MouseEvent.CLICK, Scene2e);
function Scene2e(event:MouseEvent):void
{
emerstory01.stop();
gotoAndStop("one","Scene2");
}
emer_mm_btn.addEventListener(MouseEvent.CLICK, MainMenu2e);
function MainMenu2e(event:MouseEvent):void
{
emerstory01.stop();
gotoAndStop("onea","MainMenu");
}
emer_help_btn.addEventListener(MouseEvent.CLICK, Help2e);
function Help2e(event:MouseEvent):void
{
emerstory01.stop();
gotoAndStop("oneb","Help");
}
emer_glossary_btn.addEventListener(MouseEvent.CLICK, Glossary2e);
function Glossary2e(event:MouseEvent):void
{
emerstory01.stop();
gotoAndStop("onec","Glossary");
}
I'm pulling the video from an external source and when I click continue the video doesn't stop and keeps playing. Is there a way to write this so that no matter what link/button I click the video stops playing?? I will need to do this throughout my program it seems so any help would be amazing!!!
Here's the errors I got for this output:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MySafeSchool_fla::MainTimeline/Emer2e()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MySafeSchool_fla::MainTimeline/Cont2e()
Copy link to clipboard
Copied
emerstory01 doesn't exist when Emer2e() executes.
(for more complex situations you can pinpoint the line number with the error by clicking file>publish settings>swf and ticking permit debugging. the problematic line number will be in the error message).
Copy link to clipboard
Copied
That makes sense now! How do I make it exist so that it stops running when the user clicks the different buttons? FOr instance, when they click the continue button the movie emerstory01 stops playing. I want it to stop if the user clicks the Fire button instead of Continue. What would the code be to make that movie stop no matter what button they click?
Copy link to clipboard
Copied
emerstory01.stop(); is the correct code to stop emerstory01 from playing, but you should NOT execute that code when emerstory01 no longer exists. and it probably no longer exists when the main timeline changes frames.
Copy link to clipboard
Copied
That code was all for one keyframe. How do I get it to stop no matter what button the user clicks? I think I understand what you're saying about it no longer existing once the code is written for it to stop. If I just write it for the first button action, will be then applied to every button on that keyframe or do I need to write code for each button to stop the movie from playing. If I do, how do I do it? Thanks for the help btw.
Copy link to clipboard
Copied
do your buttons exist when you change frames/scenes? if so, you have a problem because emerstory01 doesn't exist when you change frame/scenes and you need to fix your code.
you'll find it easier to understand if you rename, what you think is, emerstory01 in each scene/keyframe that contains it.
Copy link to clipboard
Copied
The buttons do exist on different key frames. Do I need to rename the buttons on each frame and fix the code accordingly? Ugh, if true.
Copy link to clipboard
Copied
one way to ensure that all emerstory01 buttons are the same instance is to clear all key frames except the first that contains emerstory01. make sure emerstory01's instance name is in the properties panel when that button is selected. then add the needed keyframes to emerstory01's layer being careful to NOT remove it frame any keyframe.
if there are frames where you want emerstory01 to not be visible, use actionscript to assign its visible property to false. again, do not remove it from the timeline.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now