1. Computing & Technology

Discuss in my forum

Making Your Own Flash Slingshot Target Game: III

By , About.com Guide

Flash needs to do a second thing when that collision test returns a value of true: it needs to go to the frame of the clip inside of squishie1 that begins the impact-reaction animation (breaking the loop set up that avoids it), and it needs to play from there. For this we’ll add a gotoAndPlay command:

onClipEvent (enterFrame) {
if (this.hitTest (_root.squishie1) ) {
_root.squishie1.stop ( ) ;
_root.squishie1.squishie1_1.gotoAndPlay (77) ;
}
}

Looks a little different from the gotoAndPlay that we’re used to, doesn’t it? It’s hierarchal, and the series of identifiers separated by periods tells Flash to start at the top and work its way downards. It’s basically a very simple road map, that tells Flash:

Go to the root/top level. When you get there, look for a movie clip instance named “squishie1”, and turn in there. Once you’re in there, look for another movie clip instance named “squishie1_1” and turn in there, too. Now drive all the way down squishie1_1’s timeline until you get to frame 77, park it there, and start to play.

Frame 77 on my timeline is where the bouncing ends and the impact-reaction animation begins; it may be different on yours.

©2012 About.com. All rights reserved.

A part of The New York Times Company.