A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11336 Flash Movies | 2 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Surjit Dhami
» Title: Book
» Description: Book
» More by Surjit Dhami


Random FLAs | Add Flash Movie
Featured Flash Site
Gallery Downloads 5848 Flash Sites | 0 New Flash Links
What's New | Top 100 Flash Site

Featured Site

» Posted in the Flash Kit Links section
» Title: All-American Rejects
» Description: Get to know this great band by exploring their "practice room".


Random Links | Add your own Flash Related Links
Flash Tutorials 1277 Tutorials 7 New Tutorials Added!
What's New | Top100

» Create xml slideshow with free template
» How to Insert a Multilingual Subtitle Into Your Flash Video Studio
» How to Create Cool Halloween Slideshow
» Debugging flash using the Firebug console
» Create Flash Slideshow on Blogger
» FLASH TRICKS IN WEB ADVERTISING: FLASH BANNERS
» HTML Photo Gallery Tutorial
» Create your first flash site – PART 1
» How to Make a Flash Photo Gallery
» Unknown Tag: Title10
Random Tutorial | Add Site

Sr Instructional Designer D2L-Moodle,Clearance
WSI Nationwide, Inc.
US-NJ-Fort Monmouth

Justtechjobs.com Post A Job | Post A Resume


Tutorials Home What's New Top Rated Submit myTutes Random!

Search Tutorials


Tutorials Tutorials » Interactivity

Categories Scrolling A Movie 2: Throw Effect
Author: Jake Gelbman | Website: allforjake.cjb.net |

 
Page 3
«prev 1 2 3 4 next»

Explaining The Script

The first thing that's new is a variable name friction in the load section. I set it to 0.9, the way this whole throwing thing will work is that when you release the scroller the program calculates the speed you threw it at. Then each frame after, the speed gets added to the y location of the scroller. Also each time the speed gets multiplied by this friction variable causing it to decrease (When you multiply a number by a decimal the number decreases ex: 1*.5=.5).

The next thing that's new in the script is a whole bunch of stuff under the enter frame event handler.

During the time you're scrolling we will be calculating your speed.This is simply done by subtracting the old y location from the new y location. First we set the newY variable to the y location of the scroller. Then we have the script subtract the old Y location from the new one. The multiplying it by 0.5 just makes the speed a little slower, it'll look better that way, but the script will work fine with out multiplying it. The old y hasn't been defined yet, so after the small calculation for yspeed set oldY to newY. This is done in this order so that first get the y value. Then we subtract the old Y value to get the speed. Then we make the old Y variable the new y variable (which is old since its after the equation). Then the next time the script comes around if you moved the scroller 10 pixels down, the speed will calculate to 5 (remember that we multiply it by a half).good? good.

Next thing we do is tell the script that the scroller is not done moving. (the done variable is just used so the script wont repeat itself when its not doing anything - it makes the movie faster :))

When you release the scroller, The next part of the script will deal with slowing the scroller down to a smooth stop. First it defines oldypos to the scrollers y position. Then it adds the amount of speed to it.still good? cool.


if (yspeed<-0.2 || yspeed>0.2) {
 yspeed *= friction;
} else {
 yspeed = 0;
 done = true;
}

This snippet of the code asks if the speed is a substantial amount (greater than 0.2 or less than -0.2(going upwards). If i didnt ask this, this will go on forever because its practically the same as zeno's paradox (if you go half way every time to a point you'll never get to the point) ) Then i decrease the speed amount by multiplying it by the friction variable. If its not going so fast I make the yspeed 0 and i set done to true so the script wont have to do anything later.
if (newyposbottom) {
 yspeed = -1*yspeed*friction;
 newypos = bottom;
}

This part of the code makes it so that if the scroller hits its boundaries, it will go the opposite way. Its not that hard, all it does is ask if the newypos variable (which holds the next location of the scroller) is going to be less than the top (for the top bounce) or more than the bottom (for bottom bounce). In both situations we multiply the speed by -1 to make the scroller go the other way. then i make the newypos equal to the top (or bottom if bouncing off the bottom). This just makes sure that you dont miss whats on top (or bottom) before going the opposite way.

OK nows the easy part that wraps everything up. We set the scrollers y position equal to the newypos variable. then we call the updateScrollbar() function which we created in the last tutorial. This script just makes the content to be in the right place according to where the scroller is.

«prev 1 2 3 4 next»

» Level Intermediate

Added: : 2001-12-10
Rating: 7.46 Votes: 48
Hits: 4616
» Author
Jake is a 16 year old Flasher. Skills include Flash, Photoshop, and javascript. He also can lasso a bull blindfolded in 5 seconds flat.
» Download
Download the files used in this tutorial.
Download (251 kb)
Get conversion and unzipping tools for PC and Mac here!

» Forums
More help? Search our boards for quick answers!

Please rate this tutorial, 10 is the top rating, you can also click the comments link to read/write a review.
10 9 8 7 6 5 4 3 2 1
Read or Post Comments
 
   
 

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs