A Flash Developer Resource Site














Internet Commerce

Partners & Affiliates














Developer Channel

internet.com


Featured Flash FLA
Gallery Downloads 11255 Flash Movies | 9 New Flash Movies Added
What's New | Top 100

Featured FLA

» Author: Knife Butterfly
» Title: SkullCandle
» Description: Simple Skull with a candle burning on it.
» More by Knife Butterfly


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

Featured Site

» Posted in the Flash Kit Links section
» Title: Cesar Kobashikawa - online portfolio
» Comments: Cesar Kobashikawa's Portfolio


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

» FLV Converter for Mac
» After Effects Quality Effect using AS3
» FLV to 3GP: Convert video files from FLV (Flash Video) to 3GP for Mac
» create Christmas business flash presentation with hyperlinks
» Let Photos Show Your Happy Family this Christmas and Upload YouTube
» PowerPoint show to DVD slide show--- PPS to DVD
» How to burn FLV to DVD for Mac
» How to Create Christmas Flash Greeting Ecard with photos and music
» Getting Started In Flash
» Unknown Tag: Title10
Random Tutorial | Add Site

bbm.netBBM.net is designed to save you time and deliver the highest quality royalty-free music for your multimedia projects. Features include: over 450 Music Loop Packages from some of the best composers in the business, our music search engine to speed your selection process, alternate music versions & bonus sounds to use for rollovers or transitions, free technical support and free consulting.

Click here for details »

Web Page Production
Aquent
US-MD-Owings Mills

Justtechjobs.com Post A Job | Post A Resume


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

Search Tutorials


Categories Virtual Tours using Flash and panoramic pictures.
Author: Matt Byrnes | Website: http://www.inflash.com |

 
Page 4
«prev 1 2 3 4 5 next»

Repositioning Pictures

Let's take a look at how the ActionScript handles repositioning the pictures.

Frame 8 contains the following code for when the "Right" button is pushed:
Set Variable: "leftmcX" = GetProperty ( "/leftmc", _x )
Set Variable: "centermcX" = GetProperty ( "/centermc", _x )
Set Variable: "rightmcX" = GetProperty ( "/rightmc", _x )
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




First, the computer determines what the position each movie clip is at on the X-axis. It takes that position and stores it in a variable.
Set Variable: "leftmcX" = GetProperty ( "/leftmc", _x )
Set Variable: "centermcX" = GetProperty ( "/centermc", _x )
Set Variable: "rightmcX" = GetProperty ( "/rightmc", _x )

Thus, the X position of the the movie clip "/leftmc" is stored in the variable, "leftmcX."

Next the computer looks at whether any part of the movie clip is on the stage, starting with the right movie clip.
If (rightmcX>=(-1*rightmcwidth) and rightmcX<=stagewidth)
Set Property ("/rightmc", X Position) = rightmcX+10
Set Property ("/centermc", X Position) = (rightmcX-centermcwidth)+10
End If


Let's look at the first section of the conditional:
If (rightmcX>=(-1*rightmcwidth)

This part of the script is asking, is the movie clip as far left as it is wide? If we take the X position and add the width of the movie clip to the X position, will the tail of the movie clip be on the stage? In other words, if the movie clip's X position is -500, that means it's X position is way off the stage. But if the movie clip is 600 pixels long, that means there are 100 pixels of the movie clip still on the stage. If it's still on the stage it has to be repositioned.

You might be asking yourself, "why is a -1 being multiplied times the width of the movie clip?" I'll try my best to explain it, but math isn't my strong suit, much less being able to explain things in mathematical terms. We're testing to see how close to zero the movie clip's tail end position is when the movie clip is set at the current "X" position. We're only concerned with how far left the movie clip is, and far left is below zero, below zero is a negative number. Thus, we need to convert the movie clip to a negative number to make a correct comparision.

If (rightmcX>=(-1*rightmcwidth)


If the X position is closer to zero, return true, if the movie clip width as a negative number is closer to zero, that means it's off the stage and false is returned, and we don't care about it.

The second part of the conditional test:

and rightmcX<=stagewidth)

checks to see if the X position is left of the far right side of the stage. Assuming a stage 540 pixels wide, this could be any number less than 540. If the X position is over 540, skip to the next conditional test. If it is under, then both parts of the conditional test return true and the movie clip must be repositioned for the viewer:

Set Property ("/rightmc", X Position) = rightmcX+10
Set Property ("/centermc", X Position) = (rightmcX-centermcwidth)+10



Just add 10 pixels to the movie clip's X position in the above script and presto! A scrolling effect.

But what's this here: (rightmcX-centermcwidth)+10

The tricky part here is that we're moving the movie clips according to their X position, but we're aligning the tail end of one movie clip to the X position (beginning) of another.

So how do we do this?

We 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.

«prev 1 2 3 4 5 next»

» Level Advanced

Added: : 2001-05-31
Rating: 8.47 Votes: 81
Hits: 11685
» Author
No details available.
» Download
Download the files used in this tutorial.
Download (647 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.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers

Whitepapers and eBooks

Symantec Whitepaper: Converging System and Data Protection for Complete Disaster Recovery
Intel Whitepaper: Comparing Two- and Four-Socket Platforms for Server Virtualization
IBM Solutions Brief: Go Green With IBM System xTM And Intel
HP eBook: Simplifying SQL Server Management
IBM Contest: Are You the Next Superstar? Join the "Search for the XML Superstar" Contest to Find Out
Intel PDF: Quad-Core Impacts More Than the Data Center
Intel PDF: Virtualization Delivers Data Center Efficiency
Go Parallel Article: PDC 2008 in Review
Avaya Article: Communication-Enabled Mashups: Empowering Both Business Owners and IT
Intel Whitepaper: Building a Real-World Model to Assess Virtualization Platforms
PDF: Intel Centrino Duo Processor Technology with Intel Core2 Duo Processor
Microsoft Article: Build and Run Virtual Machines with Hyper-V Server 2008
  Go Parallel Article: Q&A with a TBB Junkie
IBM Whitepaper: Innovative Collaboration to Advance Your Business
Internet.com eBook: Real Life Rails
IBM eBook: The Pros and Cons of Outsourcing
Internet.com eBook: Best Practices for Developing a Web Site
IBM CXO Whitepaper: The 2008 Global CEO Study "The Enterprise of the Future"
Avaya Article: Call Control XML in Action - A CCXML Auto Attendant
IBM CXO Whitepaper: Unlocking the DNA of the Adaptable Workforce--The Global Human Capital Study 2008
Adobe Acrobat Connect Pro: Web Conferencing and eLearning Whitepapers
Symantec Whitepaper: Comprehensive Backup and Recovery of VMware Virtual Infrastructure
MORE WHITEPAPERS, EBOOKS, AND ARTICLES