AS3 MOUSE_OUT called for a movie clip I just removed - actionscript-3

In my current project I'm using few copies of a movie clip that has some buttons on it. One of the buttons is responsible for removing the targeted copy.
It's working well but as the copy disappears it calls the MOUSE_OUT event on itself, and I'm getting Error #1009 as a result.
Found one workaround (I'm killing the copy as a part of MOUSE_OUT event) but it's still not letting me sleep - what is the proper way to handle the situation?

... have you tried clip.removeEventListener(MouseEvent.MOUSE_OUT, yourmouseoutevent);...

Related

Adobe Animate Actionscript 3.0 "clicktogotonextscene" code not working

So I have the following code for a button called "n2" and as you can see it's supposed to take me to the next scene when I click it, but it isn't working. It is inside Scene 2 and I'm trying to get to the next one and whenever I test the scene and click it, I don't even get an error, it just doesn't work.
Btw, it's a GIF defined as a movie clip and then as a button. Could that be causing the problem?
n2.addEventListener(MouseEvent.CLICK, fl_ClickToGoToNextScene);
function fl_ClickToGoToNextScene(event:MouseEvent):void
{
MovieClip(this.root).nextScene();
}
If you put a trace in the function and comment out "MovieClip(this.root).nextScene();" you could then see if the function gets called on a button click.
I've not used animate before, but in flash you have to name your button/movieclip and then also name the instance. This allows you to create the object twice with two seperate names to be referred to by actionscript.
Not sure if this helps but thought I'd give you some things to try, good luck

Looping frames, and using keyboard listener to continue to next frames

Im still rather new to flash.
Im currently working on animation that I want to use to present my work with. I want to run short clip, consisting of 180 frames, that continually loops while I talk. Then when I press left key on the keyboard, the animation must continue.
I can get to loop the clip, using gotoAndPlay, but as soon as add the addEventListener. The I tried to incorporate a Boolean value, but that fails as well. Any help/suggestion would be greatly appreciated
Should be as simple as creating a new symbol that will contain your animation of 180+ frames. Inside this symbol/movieclip you can add code on frames which you need to loop (F9). So on frame 180 you'd write gotoAndPlay(1);. And when you need to continue from the parent call clip.gotoAndPlay(181);

actionscript 3: calling function for second time wont work

I'm new to actionscript 3, I have sequences of frames and two buttons to control which sequence to play, it first works properly, but have problem when a sequence is being played for the second time. I have used gotoAndPlay function for my navigation. can anyone help me?
From your description I have a hunch about what may be happening...
Firstly I would ask you if the buttons are present at all frames along the timeline? If they are not (ie, sometimes the timeline shows a frame where the buttons are not present before returning to them ) you should realise that when they come back into view again, they are not the same buttons as the ones from before. That means that the event listeners you attached the first time are not going to respond to clicks on these new buttons.
This happens because flash always totally recreates timeline objects when they come into view again. Flash can sometimes cope with a "jump" over a "gap" when a symbol is the same, but this is extremely unreliable and should be avoided for this reason.
You can avoid this problem by keeping the ui on the stage at all times, and revealing and hiding the buttons when you need them. Even better, create an instance of your ui in code and add it to the stage when you need it. This way you know there is only one instance, and you are in control of it.

As3 preload/render a single movieclip before addChild to stage

I have some problems. I want to preload a single movieclip instead of preloading the whole project. Is there a way to that.
Concept Game.
Intro Displayed - Intro removed - Title Dislplayed - Title removed "after pressing on screen"
[[[[[[[PRELOAD CUT SCENE]]]]]]] if completed display CUT SCENE.
Thats the plan, but i do not know how.
Yes, there is a way to do that. But you need several SWFs for that, each containing a single movie clip that you want to be separately preloaded. You make a Loader object for each one, you have an URL for each one, then you call Loader.load() at appropriate time (say, after successfully preloading previous one) and assign a Event.COMPLETE listener that would fire once the movieclip is loaded. Don't forget to assign an error event loader as well, otherwise your game would stuck should it fail to preload a cut scene. More in the documentation for Loader class.

AS3: Sound.play() stops animation, why?

I have a working Flash movie, using a couple of AS3 scripts. The main stage has some animation going on. My player.as plays some mp3 clips when I click a button. The problem is, the stage animation stops as soon as the sound starts ie. Sound.play() starts, then animation starts again when the sound ends.
The animation is based on
this.addEventListener(Event.ENTER_FRAME,loop3D);
so I gather something happens to ENTER_FRAME due to Sound.play(). What is weird is everything works perfectly on the Flash Test movie (ctrl+Enter). The animation does NOT stop during sound. What to do to make sure the animation goes on always?
There is no inherent problem with playing sound and animation at the same time, nor is there one with combining a (however large) number of class files - you have another problem. There must be an error causing the Flash player to suspend execution of ActionScripts, and it is most probably one of these:
A security sandbox violation.
An IO error or a problem related to playing stuff that has not yet completed loading.
A problem related to loading classes from a separate SWF.
Some other problem causing a null pointer exception.
To debug this, first check your flashlog.txt. If you don't have one, set up the Flash content debugger plugin. See what error codes are thrown, go on from there.