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 Miguel Panos
»  Title: Tarta
»  Description: It is a circle graph or pie chart that takes the data entered by user
»  More by Miguel Panos


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

Featured Site

»  AuthorDeft Creative Ltd
»  Link: Home Page
»  Description: Portfolio site for .DeftCreative Ltd. A UK based web design studio specialising in flash websites, games and interactive CDROMs. With an emphasis on making things different.


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

» Making Automatic Training Screen Capture Easily
» Create Undersea Life Animation
» Making Deinterlace Video with a low bitrate Easily
» 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
» Unknown Tag: Title10
Random Tutorial | Add Site


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

Search Tutorials


Tutorials Tutorials » Interactivity/Other

Categories More Scrolling Function in Flash 5
Author: Dan Ludwig | Website: http://www.danludwig.com |

 
Page 9
«prev ... 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 next»

The third line of code here is the key; it triggers the action loop inside of logic, which uses Mick's percentages equation to continuously update the _y position of our target MC. Keep in mind that the second frame inside logic is labeled "scroll_logic" (which has absolutely NOTHING to do with the fact that logic's parent symbol is also named scroll_logic). The code could be written as "logic.gotoAndPlay(2);" and the script would still function the same way. As long as the mouse button remains pressed over top of scroll_shape in the SWF, logic will loop infinitely. This is because also attached to Frame 3 of the logic MC is a "gotoAndPlay("scroll_logic")" action.

The code after the "on (release)" handler stops both the drag and the logic loop after the user releases the mouse button. Inside logic, Frame 1 is labeled "pause" and has a "stop();" action attached to it. So, again, the last line of code could just as easily say "logic.gotoAndStop(1);." Without this "on (release)" handler and its embedded actions, the drag and logic loop would continue forever (and that would be bad). Now finally, here's the bread and butter percentages equation that makes the magic happen. It is attached to Frame 2 ("scroll_logic") of the logic MC:

eval(target)._y = clip_top-(((_root.scroll_shape._y-top)/bar_length)*clip_height);

This is the equation that gets looped, and it continually updates the _y position of var_mc according to the _y position of scroll_shape. Remember that the variables used here were established in Frame 1 of the main timeline, in the functions layer. Saying "eval(target)._y" is a more object-oriented way of saying "setProperty(target, _y, ...)," but using a "setProperty" action would still work in place of the "eval" code. (Thanks again Mick!) In this expression, the percentage of scroll_shape's _y displacement (movement) is multiplied by the variable clip_height, then the whole value is subtracted from clip_top. The value is subtracted because we want var_mc to move in the opposite direction as scroll_shape, and subtracting gives us a negative value. (Unlike traditional coordinate systems, going "down" along the y axis of the Flash stage increases the _y value, in case you hadn't noticed.)

So, can you see how these actions control the drag scrolling like they did in Mick's Flash 4 tutorial? Now we are going to add continuous feedback buttons to give the user more scrolling options. Since we already have a working drag scroll interface, we can design our buttons to draw upon the power of the working elements that are already established.

«prev ... 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 next»

» Level Intermediate

Added: : 2000-12-08
Rating: 7.53 Votes: 94
Hits: 3568
» Author
Me Like Flash 5. Flash 4 good. Flash 5 better.
» Download
Download the files used in this tutorial.
Download (229 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