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


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.55 Votes: 133
Hits: 5475
» 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