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


Categories Creating a Virutal Reality Viewer
Author: Tiran Dagan | Website: http://www.TiranDagan.com |

 
Page 8
«prev 1 2 3 4 5 6 7 8

Putting it all together

Since we do not want the user to have to press any keys, simply use the mouse, we need some form of continuous behaviour which aids in the scrolling functions. The trick is nifty: Each "sensitive area" is an instance of the same MoveClip "VRmove" which contains within it an empty MovieClip. A script is attached to the onFrame event of the empty MovieClip. This event is  triggered every single frame, at a frequency which is dependant on the frame rate you establish for your film. Too slow of a frame rate results in choppy motion. To fast will kill the CPU.

onClipEvent (enterFrame) {
var accelerate=40;
speed_lcl=_parent._parent.speed;
targetSpeed_lcl=_parent._parent.targetSpeed;
if ( (Math.abs(speed_lcl)> 0.05) or targetSpeed_lcl<>0) {
 speed_lcl += (targetSpeed_lcl-speed_lcl)/accelerate;
 currentX=_parent._parent.mainMovie._x;
 newX=currentX + speed_lcl;
 if (speed_lcl<0 and newX<0)
 newX=_parent._parent.startX;
 else if (speed_lcl>0 and newX>_parent._parent.startX)
 newX=0;
 _parent._parent.mainMovie._x=newX;
 _parent._parent.speed=speed_lcl;
 }
}

Fig. 7 - Code for the empty movie clip in "VRMove"

This code does the following:

  1. Evaluate whether we should waste time on moving the large image by examining the current scroll speed. If the speed is faster than 0.05 (we are still moving) or we are being asked to accelerate (targetSpeed_lcl<>0) then perform the remaining of the routine. The reason we dont check for speed_lcl=0 is that our various routines might not hit "0" because of the deceleration effect.
  2. Acceleration/deceleration: Calculate the destination "x" position for the large image, and increase/decrease the speed according to user's mouse position.

As I mentioned - this code is reused in the 7 instances of "VRmove" (the pink shaded squares above). The only difference between each instance is the target speed they establish. In order to save on coding time, I take advantage of the instance name to determine the functionality of each instance of "VRmove" as following:

on (rollOver) {
var slow=2;
var medium=5;
var fast=10;
instance=this._name;
if (instance=="Stop") {
 _parent.targetSpeed=0;
} else if (instance=="Left") {
 _parent.targetSpeed=slow;
} else if (instance=="LeftF") {
 _parent.targetSpeed=medium;
} else if (instance=="LeftFF") {
 _parent.targetSpeed=fast;
} else if (instance=="Right") {
 _parent.targetSpeed=-1 * slow;
} else if (instance=="RightF") {
 _parent.targetSpeed=-1 * medium;
} else if (instance=="RightFF") {
 _parent.targetSpeed=-1 * fast;
}
}
on (rollOut) {
_parent.targetSpeed=0
}

Note: The rollOut event saves us from the case in which a user abruptly moves their mouse out of the window and gets frozen in continuous scrolling

I added a "Guides" button to this movie which demonstrate the position of the "sensitive areas". If you have any other questions about this code drop me a line at tiran@TiranDagan.com and visit my website www.6footmedia.com. If you are interrested in further development of this concept, feel free to contact us.

«prev 1 2 3 4 5 6 7 8

» Level Intermediate

Added: : 2001-10-12
Rating: 8.56 Votes: 128
Hits: 5468
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (755 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