2 Replies Latest reply on Oct 4, 2010 1:02 PM by Fajza

    Array elements that respond as links

    Fajza

      I have a small applet that I need help with.  It is a large gear that rotates CCW when you click the top button and CW when you click the bottom button.  Clicking the buttons also retrieves the next element in an array called 'title' and displays it next to the gear.  The elements of the array are titles of videos.  I need to be able to click on these titles (as hyperlinks) and have them open up a video window to display the video that corresponds to that title.

       

      I am using flash CS5 and I am a beginner.  The applet can be seen at http://machinevids.net/selector.swf and the AS code is below.  Any help on this would be much appreciated.

       

      // ------ IMPORT ----- \\
      import mx.transitions.Tween;
      import mx.transitions.easing.*;

       


      //-------Initialize Variables-------\\
      var title = new Array("HYPERDRIVE", "THE BETAFISH PROJECT", "LIFE'S BURDEN", "HOT TUB MASSACRE", "HYDRO DESPERATION", "ASSASSINS", "GOING UP", "BREAKING AND ENTERING");
      var i:Number = 0;
      var startR:Number = gear._rotation;
      var endR:Number = 0;
      var currentBtn = forward;
      var displayText;

       


      // ----- FUNCTIONS ----- \\
      function moveGearFwd() {
          switch(startR) {
              case -355 >= startR <= 5:
                  startR = 0;
                  break;
                 
              case 40 >= startR <= 50:
                  startR = 45;
                  break;
                 
              case 85 >= startR <= 95:
                  startR = 90;
                  break;
                 
              case 130 >= startR <= 140:
                  startR = 135;
                  break;
                 
              case 175 >= startR <= 185:
                  startR = 180;
                  break;
                 
              case 220 >= startR <= 230:
                  startR = 225;
                  break;
                 
              case 265 >= startR <= 275:
                  startR = 270;
                  break;
                 
              case 310 >= startR <= 320:
                  startR = 315;
                  break;
                 
              default:
                 
          }
         
          endR = startR + 45;
          new Tween(gear,"_rotation",Strong.easeOut,startR,endR,1,true);
      }

       

      function moveGearBack() {
          switch(startR) {
              case 355 >= startR <= 5:
                  startR = 0;
                 
              case 40 >= startR <= 50:
                  startR = 45;
                 
              case 85 >= startR <= 95:
                  startR = 90;
                 
              case 130 >= startR <= 140:
                  startR = 135;
                 
              case 175 >= startR <= 185:
                  startR = 180;
                 
              case 220 >= startR <= 230:
                  startR = 225;
                 
              case 265 >= startR <= 275:
                  startR = 270;
                 
              case 310 >= startR <= 320:
                  startR = 315;
                 
              default:
                  startR = 0;
          }
          endR = startR -45;
          new Tween(gear,"_rotation",Strong.easeOut,startR,endR,1,true);
      }

       

      function fadeInButton() {
          new Tween(forward,"_alpha",Strong.easeIn,0,100,5,false);
          new Tween(backward,"_alpha",Strong.easeIn,0,100,5,false);
      }

       

      //-----BUTTONS----------\\
      forward.onPress = function() {
          moveGearFwd(startR);
          forward._alpha = 0;

       

      }

       

      forward.onRelease = function  () {
          fadeInButton();
          i++;
          if (i == title.length) {
              i = 0;
              displayText.text = title[i];
          } else {
              displayText.text = title[i];
              currentTitle = title[i];
      };

       

      }

       


      backward.onPress = function  () {
          moveGearBack(startR);

       

          currentBtn = backward;
      //    backward._alpha = 0;
      }

       

      backward.onRelease = function  () {
          fadeInButton();
          if (i == 0) {
              i = (title.length - 1);
          } else {
              i--;
      }
      displayText.text = title[i];
      }

        • 1. Re: Array elements that respond as links
          rHemanth Level 2

          Create a dynamic text field to display the movie names and assign tham html text as below

           

          textfield.htmlText= "<a href=\"www.google.com\" target=\"blank\">"+ArrayElementhere(Movie Name)+"</a>"

           

          Since the target is blank this will open the video in a new browser window .U will have to have video player buidl to play the video mereli pointinh to the video will to play it in the browser.

          or embed the videos in a swf provide the swf links

          • 2. Re: Array elements that respond as links
            Fajza Level 1

            I appreciate the feedback.  Sorry so long in getting back.  Lots of projects.  I perhaps didn't mention that I need to play these videos in an internal player that fits into the flash portion of the website page, which is not the entire page.  The flash portion of the page is about 1/4 the size of the overall page and that includes the selector wheel, the up and down buttons, titles and the player itself.  I can already get the videos to play in a new browser window.  I apologize for not saying that before.  http://machinevids.net/selector.swf.

             

            Please tell me what else I need to provide.  I don't see any method for attaching files here so I don't know how I am going to get the .fla file uploaded.  For reference sake, here is the AS code contained within that file.

             

            // ------ IMPORT ----- \\
            import mx.transitions.Tween;
            import mx.transitions.easing.*;
            import fl.video.*;
            /*var flvPlayer:FLVPlayback = new FLVPlayback();
            addChild(flvPlayer);
            //The next line assumes you have copied the skin file to the local directory
            flvPlayer.skin = "./SteelExternalAll.swf"
            flvPlayer.source = "http://www.markivee.com/machinevids/videos/assassins.flv";
            */

             

            //-------Initialize Variables-------\\
            var title = new Array(hyperdrive, thebetafishproject, lifesburden, hottubmassacre, hydrodesperation, assassins, goingup, breakingandentering);
            var i:Number = 0;
            var startR:Number = gear._rotation;
            var endR:Number = 0;
            var currentBtn = forward;

             

            title[i]._alpha = 100;

             


            // ----- FUNCTIONS ----- \\
            function moveGearFwd() {
                switch(startR) {
                    case -355 >= startR <= 5:
                        startR = 0;
                        break;
                       
                    case 40 >= startR <= 50:
                        startR = 45;
                        break;
                       
                    case 85 >= startR <= 95:
                        startR = 90;
                        break;
                       
                    case 130 >= startR <= 140:
                        startR = 135;
                        break;
                       
                    case 175 >= startR <= 185:
                        startR = 180;
                        break;
                       
                    case 220 >= startR <= 230:
                        startR = 225;
                        break;
                       
                    case 265 >= startR <= 275:
                        startR = 270;
                        break;
                       
                    case 310 >= startR <= 320:
                        startR = 315;
                        break;
                       
            //        default:
                       
                }
               
                endR = startR + 45;
                new Tween(gear,"_rotation",Strong.easeOut,startR,endR,1,true);
            }

             

            function moveGearBack() {
                switch(startR) {
                    case 355 >= startR <= 5:
                        startR = 0;
                       
                    case 40 >= startR <= 50:
                        startR = 45;
                       
                    case 85 >= startR <= 95:
                        startR = 90;
                       
                    case 130 >= startR <= 140:
                        startR = 135;
                       
                    case 175 >= startR <= 185:
                        startR = 180;
                       
                    case 220 >= startR <= 230:
                        startR = 225;
                       
                    case 265 >= startR <= 275:
                        startR = 270;
                       
                    case 310 >= startR <= 320:
                        startR = 315;
                       
            //        default:
            //            startR = 0;
                }
                endR = startR -45;
                new Tween(gear,"_rotation",Strong.easeOut,startR,endR,1,true);
            }

             

            function fadeInButton() {
                new Tween(forward,"_alpha",Strong.easeIn,0,100,5,false);
                new Tween(backward,"_alpha",Strong.easeIn,0,100,5,false);
            }

             

            //-----BUTTONS----------\\
            forward.onPress = function() {
                startR = (startR + 45);
                if (startR >= 360){
                    startR = 0;
                }
                moveGearFwd(startR);
                trace(startR);
                forward._alpha = 0;

             

            }

             

            forward.onRelease = function  () {
                fadeInButton();
                title[i]._alpha = 0;
                if (i == title.length -1) {
                    i = 0;
                }else{
                    i++;
            };
                title[i]._alpha = 100;
            }

             


            backward.onPress = function  () {
                startR = (startR - 45);
                if (startR <= -360){
                    startR = 0;
                }
                moveGearBack(startR);
                trace(startR);
                currentBtn = backward;
            }

             

            backward.onRelease = function  () {
                fadeInButton();
                title[i]._alpha = 0;
                if (i == 0) {
                    i = (title.length - 1);
                } else {
                    i--;
                   
            }
            title[i]._alpha = 100;
            }