AS3 / Using different movieClips in one frame - actionscript-3

For a project I have several movie clips into one frame in those movieClips you will find a button to go to the next movieClip.
All pages (movieClips) overlap each other.
The movie clips in this case are all different pages that I want to connect through a button.
When I click on the button in the movie clip I can not use gotoAndPlay because I want everything in the same frame. I think I should use removeChild for the other movie clips to remove them and only show the one i need when I press the button?
So is there an alternative for gotoAndPlay(); or should i just use removeChild(); if you click the button?
I have little experience with AS3 so I do not know exactly how I should do it.

You can either:
set the visibility with .visible = false/true;
set their alpha with .alpha = 0 - 1; (if they are interactive, they will stay interactive so careful about that)
remove them and add them (as you already proposed)
move them off screen (bad solution)
I would probably set their visibility. Or you can do it with removeChild. There is no gotoAndPlay() for this scenario.

Related

MovieClip sticks to all frames

I have a MovieClip with 5 frames. On it are some other movieclips, quite a few of them. On every frame of the first MovieClip they are positoned differently and when I change the frame they change location. Everything works great until I change something within the actionscript.
If I try to color the child MovieClip or do anything with it and then change the frame, the MC stays on the same spot, it does not change location like it should (and does if I dont change it).
Why is this happening? Can I do something to fix it?
Thank you :)
Try changing the position of the movieclips dynamically, using actionscript on each frame, instead of directly on the stage.
[movieclip].x = [Number];
[movieclip].y = [Number];
I'm pretty sure objects that have been referenced in actionscript tend to ignore the IDE positioning in later frames, so you need to dynamically move them. I've seen it happen to me heaps of times.

How do i get my UILoader to play an .SWF once then disappear?

How do i get my UILoader to play a .swf file once then disappear until called upon again?
I am creating a guitar tutorial app that shows you chords and the transitions between them. to display the chords I'm using standard Flash graphics and for the transitions i am using a UI Loader to display the .swf files for instance, on the C chord frame, the fingers are in position and the UI Loader is a layer on top of it, when the chord transition is selected from the list component it loads the chordtransition.swf.
The problem is that once the swf is loaded it plays on loop, ive added "stop();" in many different places as people suggest and it doesn't make a difference.
I would like to be able to click "C-D" on the component list then for the .swf to play once then disappear.
Any ideas??
A strategically placed stop() should work (last frame on the timeline in the swf). You'll need to stop the right movieclip - if your movie has nested clips you might be stopping the wrong clip.
However, creating multiple swf's just to show different chords looks like overkill to me.
Create clips showing all chords on the main timeline, and add frame labels to indicate where they start and put stop() at the end of every chord animation (are you using animations?).
Use movieclipWithChords.gotoAndPlay("chord_C");
If you are not using animations you can use movieclipWithChords.gotoAndStop("chord_C");
Of course you can also create labels like 'C' and 'D', and use those as a direct mapping of the chords.
Update: After reading your question again I realize you are actually showing clips of a transition from one chord to another. In that case you can still use my suggestion as above, only your labels will not be for the individual chords, but for the chord transitions e.g. 'transition_C-D' or 'transition_G-B'.

AS3 mouseClick ignore a movieclip

Is there a way in AS3 to make a the mouse ignore a certain movieclip? I need it to be on top of the other movieclips (due to transparancy effects), but have it in a way that allows clicking on the movieclips underneath it. I know about ".mouseChildren = false", but that only makes all the stuff inside that movieclip unclickable, but it still functions as a "barrier" on top of all the others buttons.
Is there a way to do this, or do I need to remove it completely ?
You need to set both .mouseChildren and .mouseEnabled to false before you can click on objects behind the MovieClip. This makes the mouse ignore the objects within the MovieClip and the MovieClip itself.
Source: http://pixelfumes.blogspot.com/2008/01/clicking-through-movieclips-to.html
EDIT: Oops, didn't see that comment by Alex, sorry.

As3: Button only working in certain locations?

I really don't know how to explain this problem. I'm really stumped as to what is causing it.
Here is the code:
var abutton:AButton = new AButton; //Where AButton is a button defined in my library
addChildAt(abutton, numChildren);
abutton.addEventListener(MouseEvent.CLICK, attack);
It doesn't want to work when certain movie clips are underneath it, but I don't want to make it more complicated by switching to another screen. Is it possible to make the button work with movieclips underneath?
What do you mean by "certain movieclips"? What do you mean by not working? The CLICK event isn't firing? Normally if a click isn't working on a button, it means that something else it trapping the mouse click above your button. This can be another Sprite, MovieClip or TextField.
Add a click listener to the stage, and have it print out target and currentTarget. Then, when you button doesn't work, the stage listener will still fire and you'll be able to see the object that's blocking your button.

How to click through a display object in Flash with AS3?

I am creating a photo editor app where, at some point, the photo you edit is supposed to be dropped between two layers of DisplayObjects (a background image and an image mask.)
There is a problem, though. When the image you are editing is dropped between the background and the image mask layers, it becomes unclickable, and therefore gets stuck there, with no chance of dragging it again. (The photo editor uses TransformManager library.)
I am looking for a way to allow you to select the image you are editing no matter if there is another DisplayObject on top of it. And that probably means finding some way to click through the image mask.
Is there a way to do that?
I tried setting mouseChildren = false on imageMask, but that didn't have the desired effect.
Many thanks.
I had similar problems and I managed to solve it by using both
displayobject.mouseChildren = false;
and
displayobject.mouseEnabled = false;
on the object that you want to click through.
How about this?
mask.mouseEnabled = false;
You can always attach a Mouse Click listener to the container, and then either use GetObjectsUnderPoint and check for your object or do a hit test and see if the mouse position is over your intended object.
The hit test would look something like this !this.YourPhoto.hitTestPoint(stage.mouseX, stage.mouseY, false)
b
If I understand your problem, this handy class should solve it:
http://www.mosessupposes.com/utilities/InteractivePNG.html
Take a look at what senocular does here, specifically in the handleUpdate method. Basically: getting a list of everything under the mousePoint to find your object.
I think I stumbled upon similar problem, although in as2.
In flash when you position movie clip over movie clip, and the movie clip on the top has any mouse events implemented, it captures all mouse events so they never reach occluded movie clip.
The solution is not to have any mouse events for the top movie clip and have the movie clip positioned at the bottom capture mouse event and redirect some of them to the top movie clip (you can check mouse position with hitTest to determine if they should be redirected).
i had a strange bug i used;
movieClip.mouseEnabled = false;
but wasn't working for some reason.. was driving me crazy!! as i have used it so many times before. tried lots of different things nothing worked then i deleted the MovieClip and the created a new one and worked.. so the MovieClip's contents must have been corrupt or something as it had a old dynamic Text Area box embedded within the MovieClip.
hope this helps someone out there..