7 Replies Latest reply on Oct 21, 2006 8:12 AM by

    geturl not working of ferris wheel effect

    beyondthebrand
      Hi,

      Thanks to Rob i have managed to get the effect i want and he has kindly given me the code to add a geturl to each of the images on the ferris wheel effect. The only thing is that when i view it it does not work so maybe i am missing somthing, see what you guys think:

      // create an onRelease function for each of the movieClips in the
      //objectsInScene array...
      for (i in objectsInScene) {
      objectsInScene.onRelease = function() {
      useLink(this);
      }
      }


      // this function will figure out which pane was clicked on and execute a
      //getURL for a specific URL...

      //substitute your own urls...

      function useLink(thisOne) {
      switch (thisOne) {
      case theScene.pane :
      getURL("firstURL.html", "_blank");
      break;
      case theScene.pane1 :
      getURL("secondURL.html", "_blank");
      break;
      case theScene.pane2 :
      getURL("thirdURL.html", "_blank");
      break;
      case theScene.pane3 :
      getURL("fourthURL.html", "_blank");
      break;
      case theScene.pane4 :
      getURL("fifthURL.html", "_blank");
      break;
      case theScene.pane5 :
      getURL("sixthURL.html", "_blank");
      break;
      case theScene.pane6 :
      getURL("seventhURL.html", "_blank");
      break;
      case theScene.pane7 :
      getURL("eighthURL.html", "_blank");
      break;
      case theScene.pane8 :
      getURL("ninthURL.html", "_blank");
      break;
      case theScene.pan9 :
      getURL("tenthURL.html", "_blank");
      break;
      case theScene.pane10 :
      getURL("eleventhURL.html", "_blank");
      break;
      case theScene.pane11 :
      getURL("twelvthURL.html", "_blank");
      break;
      case theScene.pane12 :
      getURL("thirteenthURL.html", "_blank");
      break;
      break;
      case theScene.pane13 :
      getURL("fourteenthURL.html", "_blank");
      break;
      case theScene.pane14 :
      getURL("fifteenthURL.html", "_blank");
      break;
      default :
      trace ("uh oh");
      }
      }



      Any suggestions please post.

      Thanks,
      Neil
        • 1. Re: geturl not working of ferris wheel effect
          beyondthebrand Level 1
          before anyone says it, i know i have to add my own urls!

          Hehe!
          • 2. Re: geturl not working of ferris wheel effect
            beyondthebrand Level 1
            This is all of my code:



            // create a scene movieclip to contain all 3D elements
            // and center it on the screen.
            this.createEmptyMovieClip("theScene", 1);
            theScene._x = 290;
            theScene._y = 220;

            // now we'r going to create an array to keep track of all the
            // objects in the scene. That way, to position all the objects
            // you just need to loop through this array.
            objectsInScene = new Array();

            var paneArray:Array = ["pane", "pane1", "pane2", "pane3", "pane4", "pane5", "pane6", "pane7", "pane8", "pane9", "pane10", "pane11", "pane12", "pane13", "pane14"];

            var paneArray:Array ;
            paneArray[0] = "pane";
            paneArray[1] = "pane1";
            paneArray[2] = "pane2";
            paneArray[3] = "pane3";
            paneArray[4] = "pane4";
            paneArray[5] = "pane5";
            paneArray[6] = "pane6";
            paneArray[7] = "pane7";
            paneArray[8] = "pane8";
            paneArray[9] = "pane9";
            paneArray[10] = "pane10";
            paneArray[11] = "pane11";
            paneArray[12] = "pane12";
            paneArray[13] = "pane13";
            paneArray[14] = "pane14";


            // no camera, but a rotation will be needed to keep track of the
            // spinning involved (though its the same as the camera)
            spin = 0;

            // focal length to determine perspective scaling
            focalLength = 250;

            // the function for controling the position of a friend
            displayPane = function(){
            var angle = this.angle - spin;
            var x = Math.cos(angle)*this.radius;
            var z = Math.sin(angle)*this.radius;
            var y = this.y;


            var scaleRatio = focalLength/(focalLength + z);
            this._x = x * scaleRatio;
            this._y = y * scaleRatio;

            this._xscale = this._yscale = 40 * scaleRatio;
            // on top of the normal scaling, also squish the
            // _xscale based on where in the rotation the pane is
            // since you would be looking at its side when at a z
            // of 0, it would be at its thinnest which would be
            // 0 since its a completely flat pane. So for that,
            // we can use the trig function of z (sin) to squish the
            // _xscale based on its position in z.

            this.swapDepths(Math.round(-z));
            }


            // attach each pane in a loop and arrange them in a
            // circle based on the circumference of the circle
            // divided into steps
            angleStep = 2*Math.PI/15;
            for (i=0; i<15; i++){

            attachedObj = theScene.attachMovie(paneArray , "pane"+i, i);
            attachedObj.angle = angleStep * i;
            attachedObj.radius = 160;
            attachedObj.x = Math.cos(attachedObj.angle) * attachedObj.radius;
            attachedObj.z = Math.sin(attachedObj.angle) * attachedObj.radius;
            attachedObj.y = 30;
            attachedObj.display = displayPane;
            objectsInScene.push(attachedObj);
            }


            panCamera = function(){
            // rotate camera based on the position of the mouse
            spin += this._xmouse/4000;

            // Now, with the camera spun, you need to perform the rotation
            // of the camera's position to everything else in the scene
            for (var i=0; i<objectsInScene.length; i++){
            objectsInScene
            .display();
            }
            };

            // make each figure run backAndForth every frame
            theScene.onEnterFrame = panCamera;


            // create an onRelease function for each of the movieClips in the
            //objectsInScene array...
            for (i in objectsInScene) {
            objectsInScene.onRelease = function() {
            useLink(this);
            }
            }


            // this function will figure out which pane was clicked on and execute a
            //getURL for a specific URL...

            //substitute your own urls...

            function useLink(thisOne) {
            switch (thisOne) {
            case theScene.pane :
            getURL(" http://www.totalamber.com/default.htm", "_blank");
            break;
            case theScene.pane1 :
            getURL("secondURL.html", "_blank");
            break;
            case theScene.pane2 :
            getURL("thirdURL.html", "_blank");
            break;
            case theScene.pane3 :
            getURL("fourthURL.html", "_blank");
            break;
            case theScene.pane4 :
            getURL("fifthURL.html", "_blank");
            break;
            case theScene.pane5 :
            getURL("sixthURL.html", "_blank");
            break;
            case theScene.pane6 :
            getURL("seventhURL.html", "_blank");
            break;
            case theScene.pane7 :
            getURL("eighthURL.html", "_blank");
            break;
            case theScene.pane8 :
            getURL("ninthURL.html", "_blank");
            break;
            case theScene.pan9 :
            getURL("tenthURL.html", "_blank");
            break;
            case theScene.pane10 :
            getURL("eleventhURL.html", "_blank");
            break;
            case theScene.pane11 :
            getURL("twelvthURL.html", "_blank");
            break;
            case theScene.pane12 :
            getURL("thirteenthURL.html", "_blank");
            break;
            break;
            case theScene.pane13 :
            getURL("fourteenthURL.html", "_blank");
            break;
            case theScene.pane14 :
            getURL("fifteenthURL.html", "_blank");
            break;
            default :
            trace ("uh oh");
            }
            }
            • 3. Re: geturl not working of ferris wheel effect
              blemmo Level 1
              Hi,

              you assign the onRelease to the objects array, not to the single entries. Assign it to 'i' or maybe some better readable version like:
              for (obj in objectsInScene) {
              obj.onRelease = function() {
              useLink(this);
              }
              }

              hth,
              blemmo
              • 4. Re: geturl not working of ferris wheel effect
                beyondthebrand Level 1
                Not sure i understand where to put that please could you help?

                Thanks,
                Neil
                • 5. Re: geturl not working of ferris wheel effect
                  blemmo Level 1
                  The first lines of the code in your first post are:
                  for (i in objectsInScene) {
                  objectsInScene.onRelease = function() {
                  useLink(this);
                  }
                  }

                  As the onRelease shall be assigned to the single objects, you have to assign it to every 'i' (which represents each single object while the loop is running), and not to the array of objects, like it is now.
                  'i' is used mostly for a counting variable, that's why I would recommend to choose a somewhat more descriptive name, e.g. 'obj':
                  for (obj in objectsInScene) {
                  obj.onRelease = function() {
                  useLink(this);
                  }
                  }
                  But you can use 'i' instead of 'obj', it's just a cosmetic thing.

                  cheers,
                  blemmo
                  • 6. Re: geturl not working of ferris wheel effect
                    beyondthebrand Level 1
                    Still confused as i am new to actionscrip. is this correct as it does not work?

                    // create an onRelease function for each of the movieClips in the
                    //objectsInScene array...
                    for (obj in objectsInScene) {
                    obj.onRelease = function() {
                    useLink(this);
                    }
                    }


                    // this function will figure out which pane was clicked on and execute a
                    //getURL for a specific URL...

                    //substitute your own urls...

                    function useLink(thisOne) {
                    switch (thisOne) {
                    case theScene.pane :
                    getURL(" http://www.totalamber.com/default.htm", "_blank");
                    break;
                    case theScene.pane1 :
                    getURL("secondURL.html", "_blank");
                    break;
                    case theScene.pane2 :
                    getURL("thirdURL.html", "_blank");
                    break;
                    case theScene.pane3 :
                    getURL("fourthURL.html", "_blank");
                    break;
                    case theScene.pane4 :
                    getURL("fifthURL.html", "_blank");
                    break;
                    case theScene.pane5 :
                    getURL("sixthURL.html", "_blank");
                    break;
                    case theScene.pane6 :
                    getURL("seventhURL.html", "_blank");
                    break;
                    case theScene.pane7 :
                    getURL("eighthURL.html", "_blank");
                    break;
                    case theScene.pane8 :
                    getURL("ninthURL.html", "_blank");
                    break;
                    case theScene.pan9 :
                    getURL("tenthURL.html", "_blank");
                    break;
                    case theScene.pane10 :
                    getURL("eleventhURL.html", "_blank");
                    break;
                    case theScene.pane11 :
                    getURL("twelvthURL.html", "_blank");
                    break;
                    case theScene.pane12 :
                    getURL("thirteenthURL.html", "_blank");
                    break;
                    break;
                    case theScene.pane13 :
                    getURL("fourteenthURL.html", "_blank");
                    break;
                    case theScene.pane14 :
                    getURL("fifteenthURL.html", "_blank");
                    break;
                    default :
                    trace ("uh oh");
                    }
                    }

                    Thanks for your help,
                    Neil
                    • 7. Re: geturl not working of ferris wheel effect
                      Neil,
                      Did you ever figure out how to get the getURL function to work on the ferris wheel movie? I would like to do a similar effect.