10 Replies Latest reply on Sep 16, 2010 9:05 AM by Subeesh Arakkan

    Click event

    FFerreira86

      Hi, i'm currently using flex 4 to build an application where i'm need to :

       

      click on the scrool bar, choose one number from 1-20. When choosen, the video called x(where x is the number choosen from the scroll down box) should appear and start, when i pressed play.

       

      The thing is. I can make the scroolbar, i can populate it, but i can't seem to get it to work with the video loading.

       

      Any help?

        • 1. Re: Click event
          FFerreira86 Level 1

          Please guys, im really stuck on this.

           

          This is the example code for this action only i have so far

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:s="library://ns.adobe.com/flex/spark">
             

           

              <mx:ComboBox id="comboBox" dataProvider="{arr}" paddingRight="6" paddingLeft="50" cornerRadius="6" x="92" y="39"/>
              <s:VideoPlayer x="539" y="175" dropShadowVisible="false" width="300" height="250" autoPlay="false">
                 
              </s:VideoPlayer>
             
              <mx:Array id="arr">
                  <mx:Object label="One" />
                  <mx:Object label="Two" />
                  <mx:Object label="Three" />
                  <mx:Object label="Four" />
                  <mx:Object label="Five" />
                  <mx:Object label="Six" />
                  <mx:Object label="Seven" />
                  <mx:Object label="Eight" />
                  <mx:Object label="Nine" />
                  <mx:Object label="Ten" />
              </mx:Array>
             
          </mx:Application>

           

           

          I just need the videoplayer to load the apropriate video. The videos are labeled the same as the object labels.

          • 2. Re: Click event
            Subeesh Arakkan Level 4

            Listen for the change event of ComboBox and set the videoPlayer source

             

            <mx:ComboBox id="comboBox" change="comboBoxChangeHandlder()"...............

             

            private function comboBoxChangeHandlder():void

            {

                 videoPlayer.source = comboBox.selectedItem.label + ".flv";

            }

            • 3. Re: Click event
              FFerreira86 Level 1

              I apologise, but after i implemened that code, it gave me an error, saying videoplayer.source was undefined, and while i tried to change some things i cannot find out what is going wrong here.

               

              Would it be too much to ask for you to provide a wider code range for the new things to insert?

               

              IT would be quicker to understand what im doing wrong here.

               

              Thanks for the quick reply.

              • 4. Re: Click event
                Subeesh Arakkan Level 4

                what is your video format.  you need to set the correct path . In your src folder, if it is under videos and the if the file format is .flv, it would be something like

                 

                videoPlayer.source = "videos/" + comboBox.selectedItem.label + ".flv";

                • 5. Re: Click event
                  FFerreira86 Level 1

                  it still doesn't work. Here is whast i built so far

                   

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:s="library://ns.adobe.com/flex/spark">
                  <mx:Script>
                    <![CDATA[
                     import mx.events.ListEvent;

                     private function comboBoxChangeHandler():void
                     {
                        videoPlayer.source = comboBox.selectedItem.label + ".flv";
                       
                       }

                    

                    ]]>
                  </mx:Script>


                   


                  <mx:ComboBox id="comboBox" dataProvider="{arr}" paddingRight="6" paddingLeft="50" cornerRadius="6" x="92" y="39" change="comboBoxChangeHandler()"/>


                  <mx:Array id="arr">
                    <mx:Object label="One" />
                    <mx:Object label="Two" />
                    <mx:Object label="Three" />
                    <mx:Object label="Four" />
                    <mx:Object label="Five" />
                    <mx:Object label="Six" />
                    <mx:Object label="Seven" />
                    <mx:Object label="Eight" />
                    <mx:Object label="Nine" />
                    <mx:Object label="Ten" />
                  </mx:Array>

                  <mx:VideoPlayer x="448" y="86" dropShadowVisible="false" width="300" height="250" autoPlay="false" source="videos/ + comboBox.selectedItem.label + .flv">
                   
                  </mx:VideoPlayer>


                  </mx:Application>

                  • 6. Re: Click event
                    Subeesh Arakkan Level 4

                    what is the actual path to the video file


                    • 7. Re: Click event
                      FFerreira86 Level 1

                      They are in the videos folder. The names of the files are from 1.flv to 10.flv

                      • 8. Re: Click event
                        Subeesh Arakkan Level 4

                        try videoPlayer.source = "videos/" + (comboBox.selectedIndex + 1).toString() + ".flv" in the change handler method

                        • 9. Re: Click event
                          FFerreira86 Level 1

                          Still gives me the same error. While i thank you for your help, do you think you could try it on your workplace? Maybe it would be easier to debug this little program.

                          • 10. Re: Click event
                            Subeesh Arakkan Level 4

                            okay. post your code and the video file path.