banner



How To Stop Scene Then Move To Next Scene Adobe Animate

This affiliate is from the volume

Moving from Scene to Scene

Be careful with scenes: Most animators, and Macromedia likewise, don't recommend using scenes except with long animations. We're discussing it here only because you should know how to do it.

Let's say our consignment is to create a Flash version of a PowerPoint presentation. It'southward for Buzzkill Industries, a young, edgy company that makes safety equipment. Someone else has created the slides for the presentation, and it's our job to make sure the presenter can move from slide to slide. For the purposes of this tutorial, we'll only deal with the first three slides of the presentation, shown in Effigy 3–4.

Figure 04Figure three–4 All 3 slides of the Buzzkill presentation

  1. Open the file chapter3/buzzkill1.fla.

  2. Notice that in that location are three scenes—one for each slide. Each scene has 1 frame activeness on its last frame: stop().

  3. Click on the last frame in the actions layer in each scene, and then open the Actions panel to see the ActionScript. The only ActionScript yous'll see is stop(). This stop method halts the playhead in its tracks. That is, it stops the Wink moving picture from playing further.

  4. Get alee and play with the movie, using Control Test Motion picture.

    Notation

    Always test your movies with Control Test Movie, since that's the only way you tin can properly test your actions.

  5. Notice that there's no manner to become beyond the kickoff scene/slide.

  6. Close the window with the movie playing.

  7. Go to the concluding frame in Scene 1 of the pic (frame 60) on the button layer.

  8. Insert Keyframe.

  9. Window Library.

  10. Elevate the Forward Button symbol onto the empty button layer. Make certain you lot're still on frame 60. Position the push button wherever you want.

  11. Click on the push button.

  12. Open the Deportment console.

  13. Enter the following code:

    on(release) { 			gotoAndPlay("Scene 2","slide2"); }
  14. Command Exam Movie. Once the pic is playing, pressing the button should send you to the adjacent scene.

Let's look at this code in detail. The first thing you encounter is the on(release); on is what'southward known as an event handler. If something happens, like the user pressing downward the mouse button or hitting the keyboard, that'southward called an event. An effect handler is some lawmaking that is executed when an event happens. For buttons in Flash, their consequence handler is the on(event) role. There are near a dozen events (for a consummate listing, run into Appendix A, "ActionScript Reference"), but the only i we're dealing with is release, which is short for "when the user presses the mouse button and then releases it."

Once the user releases the mouse push, everything between the curly braces that follow the on(release) is executed. Equally information technology happens, there's only one line of lawmaking: gotoAndPlay("Scene two", "slide2"). Equally you might have guessed, this command tells the playhead to jump to Scene 2 and offset playing from the frame that has the label "slide2". In this case, frame 1 holds the "slide2" label.

Unfortunately, Flash isn't smart plenty to look through all the scenes in your movie and find the right frame if you've labeled it, then gotoAndPlay("slide2") wouldn't take worked. If you direct Wink to a frame label that doesn't exist, it'll start playing at frame one.

Here'south another way to do information technology:

on(release) { 			gotoAndPlay("Scene 2", i); }

In this case, Flash goes to Scene ii and starts playing at the commencement frame. I recommend using frame labels—it lets you move stuff around without having to proceed track of frame numbers.

Notation

Labels and deportment do non have to become on their ain layers. Withal, it'southward a good way to stay organized, specially equally your movies get more and more complex. I recommend doing it, fifty-fifty if there'due south only i frame label or just i frame activity. I also strongly recommend always using frame labels—don't apply frame numbers. Your ActionScript is less probable to have bugs down the road if yous use frame labels.

Now permit'due south add the two buttons on the second scene/slide.

  1. Open up Scene 2.

  2. Open up up the Library if it isn't already open.

  3. Go to the last frame in the motion picture (40) on the empty push button layer.

  4. Insert Keyframe.

  5. Elevate the Backward button and the Forward button to the stage and place them wherever you like.

  6. Click on the Forward button.

  7. Open up the Actions panel if it isn't open.

  8. Enter the following code:

    on(release) { 			gotoAndPlay("Scene 3","slide3"); }
  9. Click on the Backward push button.

  10. Enter the post-obit code:

    on(release)										 { 			gotoAndPlay("Scene one","slide1"); }
  11. Relieve the file and Command Exam Movie.

For the terminal step, let's add the last button to the final slide.

  1. Open up upwards Scene iii.

  2. Open up up the Library (Window Library) if it isn't already open up.

  3. Go to the last frame in Scene three on the push layer (frame 45).

  4. Drag the Backward button to the stage and place it wherever you lot like.

  5. Click on the Astern push button.

  6. Open up upward the Actions panel if information technology isn't open.

  7. Enter the following code:

    on(release) { 			gotoAndPlay("Scene two","slide2"); }
  8. Control Test Film!

At present y'all can really move from scene to scene inside your motion picture, and you learned something almost buttons and effect handlers along the way! At present permit'southward brand this a little more complex: It turns out that, since they are used to using PowerPoint, the presenters forget that they have to printing buttons on the screen to move from scene to scene. They want to be able to printing the space bar and correct arrow to move forward and the left arrow to move back, just as in PowerPoint.

This isn't a trouble at all. All we're doing here is adding events (the user is pressing keys on the keyboard), and so we can modify the buttons we already have to deal with those events.

  1. Go dorsum to the Forward Button on frame sixty of Scene 1.

  2. Click on the button and open its Actions console.

  3. Add the following lawmaking:

    on(release, keyPress "<infinite>")  { 			gotoAndPlay("Scene 2", "slide2"); }
  4. Control Test Movie.

The new event we have hither is keyPress, and role of using keyPress is maxim immediately afterwards which key we're looking for. By using the <> brackets and spelling out space, we've made this lawmaking easier to read than if it were keyPress " ".

Now permit's add together the right arrow:

  1. Enter the following code:

    on(release, keyPress "<space>", keyPress "<right>") { 			gotoAndPlay("Scene two", "slide2"); }
  2. Control Examination Movie.

Whoops! Y'all received an mistake. Flash doesn't similar to have ii of the same events in the same on() argument. Fifty-fifty though our 2 keyPress events are for dissimilar keys, they still count as the same kind of event. And then we have to rewrite our code slightly:

on(release, keyPress "<infinite>")  { 			gotoAndPlay("Scene ii", "slide2"); }  on(keyPress "<correct>")  { 			gotoAndPlay("Scene 2", "slide2"); }

Test the movie again to make sure it's working correctly.

Now that we have the first push working, getting the others to work won't take much extra effort. Hither'due south the code for them:

Scene 2 Backward Push

// This button simply needs one function, since simply // one key can be used to go backwards, as opposed to // ii keys to go forrad. on(release, keyPress "<left>")  { 			gotoAndPlay("Scene 1", "slide1"); }

Scene 2 Frontward Push

on(release, keyPress "<infinite>")  { 			gotoAndPlay("Scene 3", "slide3"); }  on(keyPress "<right>")  { 			gotoAndPlay("Scene iii", "slide3"); }

Scene three Backward Push button

on(release, keyPress "<left>")  { 			gotoAndPlay("Scene 2", "slide2"); }

To see the final film, check out buzzkill2.fla.

Comments

Did you find we introduced ane new element? For the Scene 2 Backward Button, there are a few lines that start with two slashes. Those two slashes signal that the rest of the line is a comment, which Flash completely ignores. Comments are just for programmers, not for the computer. Using comments accordingly is called documenting your code. Documenting your code is important, since at some bespeak you'll have to set up your own onetime code when you might non remember how it works anymore, or someone else might accept to work on your code. Programmers who document their lawmaking well are happy programmers.

on(issue)

As a final note, hither are all of the events that the on event handler can recognize:

  • press
  • release
  • releaseOutside
  • rollOver
  • rollOut
  • dragOver
  • dragOut
  • keyPress

These are discussed in greater detail later in the book and in Appendix A.

Source: https://www.informit.com/articles/article.aspx?p=32065&seqNum=2

Posted by: hernandezplingers.blogspot.com

Related Posts

0 Response to "How To Stop Scene Then Move To Next Scene Adobe Animate"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel