27 Replies Latest reply on Nov 19, 2010 4:43 PM by kglad

    Problem with FLVPlayback

    BobMelnyk Level 1

      I have built an image/video scroller in Flash 8.  It loads images and  flv files from an external xml file.  It allows you to scroll through  the images using a left and right button.  The image in the middle is  clickable, and when you click on it, it loads the cooresponding flv for  that image and plays the flv.  It all works great, except from time to  time, the video control components become unactive - they are there, but  do not work.  Currently, I just have the playpause button.  When this  happens it becomes active again at the end of the video.  It seems to  happen more frequently in FF than in IE. You can see the program working here: http://www.jproscenium.org/image_pager_video.html

      Here is the main code:
      import mx.video.FLVPlayback;
      var picnums;
      var my_format:TextFormat = new TextFormat();
      my_format.font = "Arial";
      var t_format:TextFormat = new TextFormat();
      t_format.font = "Arial";
      var s_format:TextFormat = new TextFormat();
      s_format.font = "Arial";
      var images:Array = new Array();
      var captions:Array = new Array();
      var links:Array = new Array();
      var urlXML:XML = new XML();
      var capCol;
      var mTitle;
      var sTitle;
      var myTitle1;
      var myTitle2;
      var titleCol;
      var stitleCol;
      mTitle = this.createTextField("title_text",100,60,3,350,40)  ;
      sTitle = this.createTextField("stitle_text",200,60,30,350,3  0);
      urlXML.ignoreWhite = true;
      urlXML.onLoad = function(success) {    
      if (success) {        
      var urlfile;
      function parseXML(url_XML) {    
      var urlNode:XMLNode = url_XML.firstChild.childNodes; 
      var urls:Array = new Array();
      var caps:Array = new Array();

      picnums = url_XML.firstChild.childNodes.length;
      for (var j = 1; j<url_XML.firstChild.childNodes.length+1; j++) {
      images[j]=this.createClassObject(mx.controls.Loader, "myLoader"+j, j);
      images[j].scaleContent = false;
      captions[j]=this.createTextField("headline_txt"+j,picnums+j,1  00,100,120,40);     
      var picEntry:Array = new Array();
      for (var i=0; i<url_XML.firstChild.childNodes.length; i++) {
      var itemStr:String = url_XML.firstChild.childNodes[i].childNodes.toString();
      picEntry = itemStr.split(",");
      urls[i] = picEntry[0];
      links[i] = picEntry[1];
      caps[i] = picEntry[2];

      for (var i=0; i<urls.length; i++) {
      images[i+1].contentPath = urls[i];
      images[i+1]._x = i*200+50;
      images[i+1]._y = 60;
      captions[i+1].text = caps[i];
      captions[i+1]._x = i*200+70;
      captions[i+1]._y = 210;
      captions[i+1].textColor = capCol;
      captions[i+1].multiline = true;
      captions[i+1].wordWrap = true;
      if (images[i+1]._x == 250) {
      images[i+1]._alpha = 100;}
      else {
      images[i+1]._alpha = 20;}

      images[i+1].iVar = i;
      if (images[i+1]._x == 250) {
      images[i+1].onRelease = function() {
      myFLVPlayback.contentPath = links[this.iVar];



      var bgcol;
      var my_colorr:Color = new Color(rbar);
      var my_colorl:Color = new Color(lbar);
      Button.prototype.swapDepths = MovieClip.prototype.swapDepths;

      Here is the code for one of the buttons (other button is same except in reverse)
      on (release) {

      this.onEnterFrame = function (){

      for (var i=1; i<picnums+1; i++) {
      images[i]._x -= 200;
      captions[i]._x -= 200;
      if (images[i]._x == 250) {
      images[i]._alpha = 100;}
      else {
      images[i]._alpha = 20;}
      if (images[i]._x == 250) {
      images[i].onRelease = function() {
      myFLVPlayback.contentPath = links[this.iVar];
      else {
      delete images[i].onRelease; }
      delete this.onEnterFrame;

      Any idea why this is happening?  I'm sure it is not the most efficient  code, but it does work (well almost :-) ). Any help is much appreciated.   I've been going crazy with this for a week.  Thanks!


        • 1. Re: Problem with FLVPlayback
          kglad Adobe Community Professional & MVP

          use the trace() function to see if there are occassional failures to assign your component buttons.

          • 2. Re: Problem with FLVPlayback
            BobMelnyk Level 1

            Thanks for the suggestion.  But I'm not sure how trace() works.  I tried looking it up but did not find much help.  I tried putting the trace() statement after my component assignment statement like this:





            and like this:



            trace(myPlayPause );


            But nothing happened either time.  Where/how would I see output from the trace statement to tell me if the component assignment was failing, and what would be the correct syntax for the trace statement?





            • 3. Re: Problem with FLVPlayback
              kglad Adobe Community Professional & MVP

              both are those are fine.  you'll see output in the output panel.  even if your panel's not open, flash will open it for you when you test in the test environment.


              so, if you saw nothing that means the trace() code is not executing which means your button assignment code is not executing which is what i suspected.


              now, put a trace() statement above your if-statement to confirm that's causing the problem.  for example:


              trace(images[i]._x);  // and see if that's every 250

              • 4. Re: Problem with FLVPlayback
                BobMelnyk Level 1

                Ah, I think you are talking about Control->Debug Movie, right? I have used that before.  Problem is when I try to do that, it does not get very far and I get this error:

                Error opening URL "file:///C|/flash/undefined",

                I think because I am opening an external xml file which contains the links to the images and flv files I an using.  So, the debug can not even get to the point ot testing whether or not the playPauseButtonis getting assigned.  I know it is getting assigned, at least to begin with, becuase when I first bring the page up, it works fine.  It works fine usually a few times going back and forth between images, but at some point, the button always becomes unassigned.  It's driving me crazy.  It is so close to working really nicely.  Is there any way I could send you the fla file itself?  Would that help?  By the way, I don't expect you to keep spending time on this, but if you can help, I do really appreciate it.  Thanks again for all the help!



                • 5. Re: Problem with FLVPlayback
                  kglad Adobe Community Professional & MVP

                  no, i didn't mention debug mode.  click control/test movie/test.

                  • 6. Re: Problem with FLVPlayback
                    BobMelnyk Level 1

                    I get the same thing with that.  I hit control->test movie and it ends with an error: Error opening URL "file:///C|/flash/undefined" because it can not load the external xml file.

                    • 7. Re: Problem with FLVPlayback
                      kglad Adobe Community Professional & MVP

                      why do you now have an undefined file name problem?

                      • 8. Re: Problem with FLVPlayback
                        BobMelnyk Level 1

                        I don't have that problem when I publish and upload the swf and run from the server, because it can access the external file.  But if I try to test the program directly from the fla on my laptop, there is no way for it to access the external file that is on the server.

                        • 9. Re: Problem with FLVPlayback
                          kglad Adobe Community Professional & MVP

                          well, put the file on your local file system and use a relative path to the file so you can test your swf without making a lot of changes to your setup.

                          • 10. Re: Problem with FLVPlayback
                            BobMelnyk Level 1

                            ok, I was able to use the xml file from my own system and got the test to run.  It runs fine and NEVER fails.  I can see the playpause button getting assigned from the trace() statement, and no matter how often I go from image to image and click on it, the video always plays fine and the playpause button is always active.  However, when I publish and run on the server, it works just as well, except eventually (sometimes quickly, sometimes after a while), the playpause button becomes inactive.  Very frustrating :-).

                            • 11. Re: Problem with FLVPlayback
                              kglad Adobe Community Professional & MVP

                              then you'll need to either change your setup so you can see trace() statements online or add a textfield to your swf so you can display debugging messages in your textfield.

                              • 12. Re: Problem with FLVPlayback
                                BobMelnyk Level 1

                                ok, I set up a text field.  After the statement myFLVPlayback.playPauseButton=myPlayPause;    I set the text field to "Button on".  When I hit the button to go either left or right in the image stream, I set the test field to "Button off".  So, I can see the text field changing from "Button off" to "Button on".  Every time I click an image to play its video, the text field changes to "Button on", so I know I am executing the code to assign the playPause button.  However, even though Iknow I have gotten to that statement, at some point the playPause button becomes inactive.  As I mentioned before, if I just let the video continue t play, when it gets close to the end of the video, the button becomes active (without me doing anything).

                                • 13. Re: Problem with FLVPlayback
                                  kglad Adobe Community Professional & MVP

                                  then, for example, myPlayPause changes at some point during your swf's play.  to remedy,


                                  1.  create a new layer and cut myPlayPause from the stage where you currently have it and, with frame 1 of your new layer selected, paste it onto the stage.  don't worry about that button being visible when you don't want it to be visible.  fixing that will come later.


                                  2.  remove all instances of myPlayPause from every keyframe except the frame 1 in that new layer.  this step is critical.  if you miss any instances, your code will fail.  use movie explorer to search for movieclips using myPlayPause.  you're only finished when myPlayPause is listed only in frame 1 of your new layer.


                                  3.  now test.  (again, don't worry about the fact that myPlayPause is visible when you're viewing other frames.)


                                  4.  did this solve your problem?  if yes, you're ready to fix your app so myPlayPause doesn't ruin the appearance of your other frames.

                                  • 14. Re: Problem with FLVPlayback
                                    BobMelnyk Level 1

                                    Thanks...interesting, because that is basically the way I already have it set up.  There is only 1 frame in the movie to begin with.  I created a layer called playpause and dragged an instance of the playPauseButton onto the stage in that layer.  I made it a movieclip and gave it an instance name of "myPlayPause."  The FLVPlayback compontent is in its own layer with an instance name of myFLVPlayback.  Then I use the statement:




                                    to make the assignment.


                                    So, that statement is in the actionscript on the frame when the movie loads and also on the actionscript assigned to the buttons that move the images left and right.


                                    But there is only 1 instance of the component playPauseButton, and it is in its own layer in frame 1.

                                    • 15. Re: Problem with FLVPlayback
                                      kglad Adobe Community Professional & MVP

                                      if playPauseButton is a component it shouldn't be changed to a movieclip.  it already is a movieclip.  delete that component from the library and drag one from the component panel to the stage.  assign its instance name and change nothing else in the properties panel.

                                      • 16. Re: Problem with FLVPlayback
                                        BobMelnyk Level 1

                                        OK, did that.  No effect.  Problem still exists.

                                        • 17. Re: Problem with FLVPlayback
                                          kglad Adobe Community Professional & MVP

                                          why are you assigning a button in an enterframe loop?

                                          • 18. Re: Problem with FLVPlayback
                                            BobMelnyk Level 1

                                            I'm not sure if I understand your question, but when the movie first loads, there are 3 images showing.  The middle one needs to be clickable and when the user clicks on it, the video plays.  So, when it is clicked, I have code that assigns the playpausebutton the FLVPlayback component, and also assigns the video content path to the FLVPlayback component, so the video plays and the user has the playpausebutton to pause and start the video if he wants.  But the user could decide to scroll left or right before clicking on an image.  Let's say he scrolls to the right and decides to click on the 4th picture.  When he clicks I also need the video content path and the playpausebutton to be assigned at that point as well.


                                            I'm sure there is probably lots of changes I could make to the code to make it much more efficient, but I did the best I could, tying to figure out how to make all this work.  Thanks again for all your help!



                                            • 19. Re: Problem with FLVPlayback
                                              kglad Adobe Community Professional & MVP

                                              how many different flvplayback components are in your project and how many playpausebutton's are in your project?

                                              • 20. Re: Problem with FLVPlayback
                                                BobMelnyk Level 1

                                                1 of each.  When the user moves to a new image and clicks on it, I assign the contentpath of the proper flv file to the FLVPlayback component and it plays the appropriate video.

                                                • 21. Re: Problem with FLVPlayback
                                                  kglad Adobe Community Professional & MVP

                                                  assign the contentPath whenever you like.  that's a non-issue (at this point).


                                                  remove your code to assign a playPauseButton in the enterframe loop and assign it once at the start of your app.

                                                  • 22. Re: Problem with FLVPlayback
                                                    BobMelnyk Level 1

                                                    OK, the very first 3 lines of my app are now:


                                                    import mx.video.FLVPlayback;


                                                    I do the swapDepths because without it, the playPauseButton is hidden behind the images that get loaded dynamically at run time, and the video when it plays.

                                                    I do not reference myPlayPause anywhere else at all.


                                                    But, the problem still occurs.

                                                    • 23. Re: Problem with FLVPlayback
                                                      kglad Adobe Community Professional & MVP

                                                      that's about as much help as i can offer without downloading and correcting your fla (and i don't do that unless i'm hired).


                                                      someone else may be able to help from here.

                                                      • 24. Re: Problem with FLVPlayback
                                                        BobMelnyk Level 1

                                                        lol - I understand.  You've already been a lot of help.  I seems to work much better (takes much longer to fail) in IE than in FF - not sure why that is.  Anyway, if I were to send you the fla file, based on what we've discussed so far, do you feel confident that you could get it to work?  If so, how much would you charge to do it?  Thanks!

                                                        • 25. Re: Problem with FLVPlayback
                                                          kglad Adobe Community Professional & MVP

                                                          i would think this would be less than $20.    possibly way less.


                                                          go ahead and send an email via the contact page at  http://www.kglad.com

                                                          • 26. Re: Problem with FLVPlayback
                                                            BobMelnyk Level 1

                                                            If you can get this working for $20 it would be great.  I went to your site, but I do not see how to actually attach the fla file to send it to you using the contact form.  How do I get you the fla file?  Thanks!



                                                            • 27. Re: Problem with FLVPlayback
                                                              kglad Adobe Community Professional & MVP

                                                              just send an email.  i'll reply and then you'll have my email address and can send the fla.