How can I send control of the playhead back to a parent timeline from a movieclip using createJS? - html

I'm making a multi-part introductory animation for a game. It works when I preview in Flash, but not when I export using the CreateJS toolkit to get HTML5 output.
On my scene's timeline, I have this.stop(); on the first frame, as well as a movie clip that contains several seconds of animation (and which may have to change in length as we develop).
My second frame is labeled "sc2" and I would like the animation to pick up there when the first movieclip is finished. To accomplish this, I went into the first movie clip and put this on the last frame:
_parent.gotoAndPlay("sc2");
This works fine in Flash, but perhaps I can't use the _parent object in JS? Is there an alternative way to access the flow of control or another way to accomplish this? My goal is to avoid doing animation on the main timeline and to control the flow by scripting there so that if the length of the individual sections of animation changes, I don't have to change the start and end frames of the various sections in several places.

Related

Avatar Layering and Animating in Flash

So for my latest Flash project, I'm designing a game. The dimetric character can move in 8 directions. I've been given the spritesheets for the hats, hair styles, etc., that the player can wear.
The spritesheets contain the images for each direction, AND they contain four frames of animation (four per direction) for when the player is walking. This is basically the layout of the Spritesheet (and all of the files and "frames" are the same size, which makes things easier):
[IDLE] [WALKING]
[S][SE][E][N][NW][W][S1][S2][S3][S4][SE1][SE2]...
My goal is to embed all of the items in a single file other than the main one. But I need to implement walking animation.
One thought I had is to set the main SWF's framerate to 7 FPS, then use an Event.ENTER_FRAME handler to alternate between the walking ones. Programmatically animating.
Another thought is to create SWFs for each item of clothing, then use motion tweening to move the spritesheet symbol over the stage.
What I'd really like it so avoid using Adobe Animate entirely. Even if there's an approach that requires the use of Flex, I'd take it if it meant saying goodbye to graphically-designing.
using flash builder (flex) does not mean that good bye graphic! there is a relationship between Adobe Flash and any As3 Ide like FlashBuilder or FlashDevelop.
exporting movieclips and everything in library with .swc format, and then importing it by the IDE, read this
My goal is to embed all of the items in a single file other than the
main one. But I need to implement walking animation.
One thought I had is to set the main SWF's framerate to 7 FPS, then
use an Event.ENTER_FRAME handler to alternate between the walking
ones. Programmatically animating.
i dont undrestand! why 7 fps and also why Event.ENTER_FRAME
there might be a character movieclip, whit above frames in its time line, well! to playing any animation (for particular direction) you have to call mc.gotoAndPlay("walk_S"); then it will be played automatically, if you need lower frame rate, only select each frame by mouse pointer and then press [F5] in time line to insert a blank frame gape between keyframes.
as i said before, you must use a callback script at the end frame of the each loop animation like walk_s walk_ne ...
also idle animations must be called like it: mc.gotoAndStop("idle_s");

AS3 : MovieClip script stop when done playing

I am a beginner with AS3 and I'm having a problem with MovieClip class.
I have a character that move through a simple script that handles collision, sound etc. Everything was working seemlessly so far but when I started adding animation, the character would stop at the end of the animation cycle.
Does someone comfortable with AS3 knows what's wrong here ?
Thanks in advance =)
Inside the Flash IDE, try clicking the instance of your character that's not looping the way you want it to (and this should be from outside the animation itself; from the container of your character), then look inside the Properties tab/window. Near the bottom, there will be a LOOPING header, and inside there you can modify the behaviour.
In case you have any problems with this, or otherwise want to have more control over the animation playhead, you can include script in the form of e.g. gotoAndPlay(1); which you might add at the last frame of your animation cycle to tell Flash to play from the start again. The frame number parameter doesn't have to be 1 of course. You could for example set up a series of animation sequences on a single timeline, and use gotoAndPlay() to have them loop internally, until an event occurs and you direct the playhead to another animation loop inside the same MovieClip.
Usually when play(); is called, an animation is being repeated all the time.
You should seek in your code for stop(); that essentially makes an animation stop, and remove it.

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'.

Actions are assigned to wrong keyframe in Flash CS5

I am working with Flash CS5, and haven't been using Flash since the age of AS2.
I have a movieclip symbol in which I have an Actions layer, in which I have a keyframe in frame 1 and one in frame 20. Each of these should have a stop(); action assigned, but when i select the one in frame 20 and start writing, the little "a" appears on frame 1 of another layer. When I make a keyframe in frame 20 of that layer and try to assign actions it yields the same result. They appear on frame 1.
Is this a bug or am I missing some vital information about AS3?
AS3 is in fact more picky (for good reason) about how the code is implemented.
You need to select the keyframe you are intending to put code into, and then use your actions window. And as Markus commented, make sure you're using keyframes, and not empty frames. If you try to write code into an empty frame, it will default it to the most recent keyframe.
Furthermore, If you have multiple layers and say, your code is on layer2 and your objects on layer1, if you have keyframes on layer1, and intend to enter code at frame 20, but your layer selection is layer2, it will yield the same result described above. You'll have to make sure the correct layer is active. The actions window will only display the code from the current layer's most recent keyframe.
Hope that clears some things up!

Why would a keyframe in Flash fail to update an object's position as defined in the keyframe when the play head is sent to that frame?

I have a background MovieClip in a custom button class, which moves the play head to a different frame (via gotoAndStop("framename")) depending on which mouse events it receives.
When the mouse up event is received, it sends the play head back to the "release" frame, where the background should shift back to its original location, but instead nothing happens and the background remains where it was. It's as though Flash is not honoring the background's position defined by the key frame it enters.
The only workaround is to add a frame script to each frame which manually sets the x and y position to what it should be, but this defeats the purpose of using keyframes for the position.
What is going on?
Try calling event.updateAfterEvent(), it's supposed to
Instructs Flash Player or Adobe AIR to render after processing of this event completes, if the display list has been modified.
from here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html#updateAfterEvent%28%29
This appears to have been a bug in the Flash IDE, specifically some kind of corruption in a timeline layer.
The corruption originated in Flash CS4, but persisted when opened and compiled in Flash CS5, which is why I suspect it was some kind of content-generation bug, rather than something specific to either IDE version. The IDE probably gets confused when you construct the timeline out of order or drag things around, rename things, copy things in from other files, etc. I think, specifically... it was the fact that I copied this particular object in from another file. And it wasn't even a complex object, it was just a MovieClip that contained a rounded rectangle and had a drop shadow applied, seriously.
Steps I took to resolve the issue were to remove any classes associated with the library item, reverting it back to a standard MovieClip. I then completely removed the problematic layer. I then reassigned the class to the library object and exported it for ActionScript. Finally, I rebuilt the layer from the first frame, adding subsequent keyframes as necessary. I reapplied filters, and adjusted the clips location on each frame.
Now, everything is functioning as expected. The clip's position, filters, etc. are all updated as expected when the playhead moves to any frame. It's working now as expected, so I wasn't doing anything wrong or not possible. It simply must have been some kind of incrementally constructed key framing confusion within the data structures of the IDE. Glad it's working now.