Virtual Reality Tours in Flash

Page 3 of 3
Matt Byrnes
This user is yet to take control of their account and provide a biography. If you are the author of this article, please contact us via support AT actionscript DOT org.
View all articles by Matt ByrnesWe can determine the tailend position of a movie clip by taking it's X position and adding that number to the movie clip's width. Thus, a movie clip with an X position of 100 that is 500 pixels wide would have a tail end that would land on the X axis at 600.
That gives us access to lining up the tail end of one movie clip with the X position of another movie clip.
For example, take the center movie clip (centermc) and the right movie clip (rightmc). The computer takes the X position of the right movie clip, we'll say it's 200, subtract that from the width of the center movie clip, we'll say that's 1000, and we get -800. -800 is the x position of the center movie clip for perfect alignment with the right movie clip.
Since the pictures are constantly being positioned relative to one another, it's necessary to line them up at the beginning in perfect alignment. If they're out of aligment to begin with, they'll be perfectly out of alignment throughout. The starting positions are the absolutes that all the relative re-positioning are based on.
To finish up the rest of the conditional statements in the keyframe, which is basically a rehash of everything above.:
The computer checks the position of each movie clip to the other and will perform the same operations as above if the condition returns true.
If (rightmcX>=(-1*rightmcwidth) and rightmcX<=stagewidth)
Set Property ("/rightmc", X Position) = rightmcX+10
Set Property ("/centermc", X Position) = (rightmcX-centermcwidth)+10
End If
If (leftmcX>=(-1*leftmcwidth) and leftmcX<=stagewidth)
Set Property ("/leftmc", X Position) = leftmcX+10
Set Property ("/rightmc", X Position) = (leftmcX-rightmcwidth)+10
End If
If (centermcX>=(-1*centermcwidth) and centermcX<=stagewidth)
Set Property ("/centermc", X Position) = centermcX+10
Set Property ("/leftmc", X Position) = (centermcX-leftmcwidth)+10
End If
Play
Each If statement checks to see if the X position returned indicates any part of the movie clip is on the stage. If the movie clip has any part of itself on stage, then that movie clip is moved to the right 10 pixels. The movie clip to the left of it gets moved to the right 10 pixels as well. (To move the pictures to the left, the movie clips would be repositioned 10 pixels to the left).
Everything gets positioned relative to everything else. However, there are a two absolutes that make all this relativity possible:
The tour starts with leftmc's tailend aligned seamlessly with the beginning of centermc, and centermc's tailend aligns seamlessly with the beginning of rightmc.
At some point, the tailend of rightmc will align seamlessly with the beginning of leftmc.
By programming the code this way, the computer can manage the presentation itself, without you having to re-calculate everything everytime you import new panoramic pictures into the .fla.
The Buttons A quick step back to the beginning, when the user clicks a button to change the scrolling direction and then we're finished.
The buttons.
In the Fast Forward button is contained the ActionScript:
On (Release)
Set Variable: "right" = "fast"
Go to and Play (2)
End On

So the viewer clicks the Fast Forward to the right button, setting the variable "right" to hold the value "fast." The computer repositions the pictures by executing the code in the keyframe labeled "right" (which we just went over above). Immediately after the keyframe labeled "right" is the keyframe labeled, "Goto right fast." It contains the following code:
If (right eq "fast")
Go to and Play (2)
Else
Play
End If
and in the frame after that (labeled "Goto left slow") is the ActionScript:
Go to and Play (2)
What does all that do? When the viewer clicked on the Fast Forward button, the variable "right" was set to "fast", so the playhead gets sent back to execute the code and reposition the pictures fairly quickly. If "right" isn't set to "fast" it plays another frame before being sent back to execute the code, thus creating a greater delay between the repositioning of the pictures.
I'll let you figure out how to make the pictures go left. It's not much different.
Any questions, let me know!

