4 Replies Latest reply on Apr 8, 2011 7:12 AM by Drew747

    beginner help

    oneL0ve_

      Hi,

       

      I have a simple video gallery set up connected to an xml file to load my assets (video path, title, description).  Rather than using small thumbnails to change the videos and corresponding info, I have two arrow buttons that should change the videos in order back and forth.  (so 0 > 1 > 2 > 0 etc, and backwards with the left arrow)

       

      My assets are connected and I know this is simple and I have learned it but I am having trouble with my assets changing to my button click events.  I was thinking of using if statements (which work on the first 2 assets but then fail after that).

       

      protected function button1_clickHandler(event:MouseEvent):void
                  {
                      if (myVideo.source == "assets/media/" + myData[0].path;
                      myLabel1.text == myData[0].desc;
                      titleLabel1.text == myData[0].title;)
                      {
                      myVideo.source = "assets/media/" + myData[1].path;
                      myLabel1.text = myData[1].desc;
                      titleLabel1.text = myData[1].title;
                      }

       

      in my head i was thinking of then using "else if" myData[1] then it changes to [2] like this:

       

      else if (myVideo.source = "assets/media/" + myData[1].path;
                      myLabel1.text = myData[1].desc;
                      titleLabel1.text = myData[1].title;)
                  { myVideo.source = "assets/media/" + myData[2].path;
                      myLabel1.text = myData[2].desc;
                      titleLabel1.text = myData[2].title; }

       

      but i seem to be doing something wrong.

       

      can anyone help me with the code to loop them all together?

       

      thanks!

        • 1. Re: beginner help
          Level 2

          sounds a little hardcoded number wise !

           

          why not use variables, knowing how many are loaded (store that in a variable) and increment up to the count and decrement back toward 0 or 1

           

          this way your source code does not need to change if you go from 3 videos to say 30

          • 2. Re: beginner help
            Level 2

            you might also check this out:

             

            http://activeden.net/item/infinite-3d-image-and-media-carousel/21732

             

            $10.   I bought it a few years ago since it was AS3. His stuff comes with SWC's so you should be able to plop it into Flex / FB

             

            the main point is that for chump change you can learn a lot about loading from XML and displaying different media types (movies, pictures, swfs)

            1 person found this helpful
            • 3. Re: beginner help
              oneL0ve_ Level 1

              Thanks for the help, and in any other situation I would probably not be doing it this way, but it's for a school project so I don't want to buy or use other scripts like that.

               

              Therefore the hardcoding also isn't an issue for now because I have a set number of videos which won't be changing for the time being.  I really just wanted to know if I was using the if statements correctly?? At the moment I'm getting errors at every line that has "else if" written on it.... here is the full function as I have it now:

               

              protected function button1_clickHandler(event:MouseEvent):void
                          {
                              if (myVideo.source == "assets/media/" + myData[0].path;
                              myLabel1.text == myData[0].desc;
                              titleLabel1.text == myData[0].title;)
                              {
                              myVideo.source = "assets/media/" + myData[1].path;
                              myLabel1.text = myData[1].desc;
                              titleLabel1.text = myData[1].title;
                              }
                         
                              else if (myVideo.source = "assets/media/" + myData[1].path;
                              myLabel1.text = myData[1].desc;
                              titleLabel1.text = myData[1].title;)
                          { myVideo.source = "assets/media/" + myData[2].path;
                              myLabel1.text = myData[2].desc;
                              titleLabel1.text = myData[2].title; }
                         
                          else if (myVideo.source = "assets/media/" + myData[2].path;
                              myLabel1.text = myData[2].desc;
                              titleLabel1.text = myData[2].title;)
                          { myVideo.source = "assets/media/" + myData[0].path;
                              myLabel1.text = myData[0].desc;
                              titleLabel1.text = myData[0].title; }
                          }

               

              I know I'm doing something wrong but can't figure it out??

              • 4. Re: beginner help
                Level 2

                i think you have an issue with the closing parens on the if stmt

                but if you want ot send me a zip with the whole proj i could bang it out in 10 min

                 

                drewpierce@live.com

                 

                Date: Fri, 8 Apr 2011 08:07:44 -0600

                From: forums@adobe.com

                To: drewpierce@live.com

                Subject: beginner help

                 

                Thanks for the help, and in any other situation I would probably not be doing it this way, but it's for a school project so I don't want to buy or use other scripts like that.

                 

                Therefore the hardcoding also isn't an issue for now because I have a set number of videos which won't be changing for the time being.  I really just wanted to know if I was using the if statements correctly?? At the moment I'm getting errors at every line that has "else if" written on it.... here is the full function as I have it now:

                 

                protected function button1_clickHandler(event:MouseEvent):void

                            {

                                if (myVideo.source == "assets/media/" + myData[0].path;

                                myLabel1.text == myData[0].desc;

                                titleLabel1.text == myData[0].title;)

                                {

                                myVideo.source = "assets/media/" + myData[1].path;

                                myLabel1.text = myData[1].desc;

                                titleLabel1.text = myData[1].title;

                                }

                             

                                else if (myVideo.source = "assets/media/" + myData[1].path;

                                myLabel1.text = myData[1].desc;

                                titleLabel1.text = myData[1].title;)

                            { myVideo.source = "assets/media/" + myData[2].path;

                                myLabel1.text = myData[2].desc;

                                titleLabel1.text = myData[2].title; }

                             

                            else if (myVideo.source = "assets/media/" + myData[2].path;

                                myLabel1.text = myData[2].desc;

                                titleLabel1.text = myData[2].title;)

                            { myVideo.source = "assets/media/" + myData[0].path;

                                myLabel1.text = myData[0].desc;

                                titleLabel1.text = myData[0].title; }

                            }

                 

                I know I'm doing something wrong but can't figure it out??

                >