473,412 Members | 2,048 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

How to work out whether to go forward frames or backwards frames?

113 100+
Hi,

I'm creating virtual tour of a house, the part I am working on at the moment involves a 360 spin view of the house (a series of 36 flat frames). Each corner of the house has a hotspot so that the user may click to navigate to that corner. I have completed the code to get the house to spin to the correct hotspot when the user clicks on a hotspot but where I'm struggling is working out the correct code so that if you are on position 1 and want to get to position 4 the house will spin backwards not forwards all the way through points 2 and 3 to get to 4.

Here is my code so far:

Expand|Select|Wrap|Line Numbers
  1. function loadPosition(frame,hotspots,callback) {
  2.     trace("-----------------------------------------------------------------");    
  3.     sequence = mcSequenceContainer.sequence;
  4.     trace("1) loadPosition: "+frame+ " With hotspots: "+hotspots+" Current frame: "+sequence._currentframe);
  5.  
  6.     sequence.onEnterFrame = function() {
  7.  
  8.         // When final frame is reached stop play and load hotspots and or callback
  9.         if(this._currentframe == frame) {
  10.             trace("2) Final frame reached.");
  11.             if(hotspots != null) {
  12.                 trace("3) Loading hotspots...");                
  13.                 loadHotspots(hotspots);
  14.             }
  15.             if(callback != null) {
  16.                 trace("4) Callback not null");
  17.                 callback();
  18.             }
  19.             this.stop();
  20.             delete this.onEnterFrame;
  21.         }
  22.         else {
  23.             // If frame is greater play sequence forwards
  24.             if(this._totalframes - frame >= frame + (this._totalframes - frame)) {
  25.                 trace("Totalframes - frame: "+this._totalframes - frame+" Frame + totalframes - frame: "+frame + (this._totalframes - frame));
  26.                 trace("Forwards: "+this._currentframe+" "+frame);
  27.  
  28.                 // Check currentframe doesn't exceed number of frames
  29.                 if(this._currentframe + 1 > this._totalframes) {
  30.                     // Reset to first frame and continue
  31.                     this.gotoAndStop(1);
  32.                 }
  33.                 else {
  34.                     // Increment frame
  35.                     this.gotoAndStop(this._currentframe + 1);                
  36.                 }
  37.  
  38.             }
  39.  
  40.             // If frame is less than play sequence backwards
  41.             else if(this._totalframes - frame <= frame + (this._totalframes - frame)) {
  42.                 trace("Totalframes - frame: "+(this._totalframes - frame)+" Frame + totalframes - frame: "+(frame + (this._totalframes - frame)));
  43.                 trace("Backwards: "+this._currentframe+" "+frame);
  44.  
  45.                 // Ensure currentframe doesn't become a negative number
  46.                 if(this._currentframe - 1 < 1) {
  47.                     // Reset to first frame and continue
  48.                     this.gotoAndStop(this._totalframes);
  49.                 }
  50.                 else {
  51.                     // Decrement frame
  52.                     this.gotoAndStop(this._currentframe - 1);                
  53.                 }
  54.  
  55.             }            
  56.         }
  57.         // DEV: trace("Current frame: "+sequence._currentframe+" Target frame: "+frame);    
  58.     }
  59. }
  60.  
The code of interest is to the test statement, which im trying to get to work out how many frames it is in each direction to the target frame, then based on that result decide which direction to go:

Expand|Select|Wrap|Line Numbers
  1. if(this._totalframes - frame >= frame + (this._totalframes - frame))
  2.  
Thanks,

Chromis
Dec 23 '08 #1
0 1911

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Justin | last post by:
Hi, I have a simple frameset defined: ---------------- index.html ---------------- <FRAMESET COLS = "225,*"> <FRAME NAME = "a" SRC = "one.html"> <FRAME NAME = "b" SRC = "one.html">...
5
by: imaband | last post by:
Hi, I've got a little Quizzer program that asks a question in the upper frame of a frameset and then lists the answer in the lower frame. Answers can be plain text, straight html, a sound, or a...
2
by: COHENMARVIN | last post by:
Folks, I wrote a simple javascript script, but it doesn't work. First I have a web page that uses frames: ===================== <html> <frameset rows="10%,90%"> <frame src="frame1.htm"...
1
by: Adrian | last post by:
Hi I'm lost! so please help me... I have the following code I want to simply retrieve all the record that matches the SQL statement, I want to know how many records matched and display only...
3
by: schwartzenberg | last post by:
Dear friends, I have just run into a strange DB2 problem. Something i'd some of you would answer, if only shortly. My basic question is: How do i ensure 'insensitive' (ie static) cursors...
12
by: vietgurlqt | last post by:
I don't what is wrong my site but some of my members cant view it on firefox. I been browsing the net for answer but i havent find the solution. Some said add <!DOCTYPE HTML PUBLIC "-//W3C//DTD...
3
jhardman
by: jhardman | last post by:
I have an old site built with frames, and I plan to leave it in frames for now. The problem is that occasionally I find links (from outside) lead me to just the content frame which means most of the...
4
by: Ronald S. Cook | last post by:
I have an old ASP.NET app that I need to rewrite. It uses frames to have an embedded Windows Media Player playing content that is controlled from other frames on the page. And, of course, the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.