Internet Commerce

Partners & Affiliates

Developer Channel


Featured Flash FLA
Gallery Downloads 11401 Flash Movies | 5 New Flash Movies Added
What's New | Top 100

Featured FLA

»  Author: Nick Kouvaris
»  Title: Znax
»  Description: Znax is a board game. Click 4 tiles of the same color and form squares as big as you can. You will erase all the tiles inside the square and collect points. Get maximum score if you make a square with game edges.
»  More by: Nick Kouvaris


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

Featured Site

»  Author Agence WOP Digital Agency
»  Title: Electricdrum
»  Description: French WOP Agency, 3D websites, Flash (Papervision, Away 3D), event or institutional projects. The agency operates on all digital projects: consulting, design, graphic design, development, online communication. The WOP agency follows you on the implementation of original, creative and optimized digital projects.


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

» How To Make A Simple Animation Using Christmas Clips
» Simple Step by step flash game tutorial Spot the diffrence
» How To Make A Moving Text Slide
» Create Flash Banner With Text Float Effect
» How To Make Zoo Photos Slideshow
» How To Make A Dolphin Photos Slideshow
» How To Make A Fathers Day Slideshow
» How To Make A Transparent Background of Your Flash File
» Create Flash Banner With Text Disco Light Effect Today we will introduce you a Text Disco Light eff
» Unknown Tag: Title10
Random Tutorial | Add Site


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.33 Votes: 49
Hits: 4627
» 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