33 Replies Latest reply on Sep 9, 2011 11:33 PM by ITango2

    Trying to get flvplybk to trigger on button.

    ITango2

      It would be embarrassing to say that I spent most of my holiday weekend trying to get an flv to play in a popup so I won't ;-)

       

      Existing Flash site with AC2

      Trying to add a button to popup and play an FLV file

      Code below works fine in main timeline without any attempt to wrap it in the onrelease, it opens and plays the file immediately (allbeit of course not what I want to happen)

      Button instance is of course play_vid

       

      I've looked at a hundred examples over 3 days and noda.  DOes something need to be added in to support onrelease?

       

      Thanks in advance

       

      play_vid.onRelease=function() {
      import mx.video.*;
      this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240, x:100, y:100});
      my_FLVPlybk.skin = "file:///d|/Adobe/Adobe Flash CS5/common/Configuration/FLVPlayback Skins/ActionScript 2.0/ClearOverPlaySeekMute.swf"
      my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv";   
      my_FLVPlybk.play();

       

      }

        • 1. Re: Trying to get flvplybk to trigger on button.
          kglad Adobe Community Professional & MVP

          use a local path to your skin:

           

          import mx.video.*;

           

          play_vid.onRelease=function() {

          this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:320, height:240, x:100, y:100});
          my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
          my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv";   
          my_FLVPlybk.play();

           

          }

          1 person found this helpful
          • 2. Re: Trying to get flvplybk to trigger on button.
            ITango2 Level 1

            It is currently local development.  That path is correct, and it will play if I load the code to the main timeline.  Trying to get it to play when the button is clicked is what I'm working on.

             

            Always greatful for your help Kglad

            • 3. Re: Trying to get flvplybk to trigger on button.
              ITango2 Level 1

              Correcting my typo above, that should read AS2.

              • 4. Re: Trying to get flvplybk to trigger on button.
                kglad Adobe Community Professional & MVP

                does your onRelease execute?  (use the trace() function to test.)

                • 5. Re: Trying to get flvplybk to trigger on button.
                  ITango2 Level 1

                  Well for heavens sake!  ;-)

                   

                  Further research indicated that best practice would be to use a movie clip button rather than a button button, so I changed it with its properties.

                   

                  I changed the code a bit, and added in trace() as shown here

                   

                  on (release) {
                  import mx.video.*;
                  this.attachMovie("FLVPlayback", "my_FLVPlybk", 10, {width:600, height:355, x:100, y:100});
                  trace("got here 1");
                  my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                  my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv";  
                  my_FLVPlybk.play();
                  trace("got here 2");
                  }

                   

                  And to my surprise, both traces reported to the output window as expected on a click.  But no flvplayback window.....Or so I thought.

                   

                  As luck would have it, I noticed some activity between existing oblects on the stage of the original movie.  The flvplayback window IS BEHIND the other objects.

                   

                  This is not what I would expect as a default.  I would ASSUME ;-)  a new window would default to on top.

                   

                  So the next task is to find out how to force the window to the front.

                   

                  Thanks for any assistance.

                  • 6. Re: Trying to get flvplybk to trigger on button.
                    kglad Adobe Community Professional & MVP

                    you're assigning your flvplayback component to a depth of 10 and you're attaching it to your movieclip button.

                     

                    we should correct all your problems now to prevent future problems.

                     

                    first, don't attach any code to objects.  assign your movieclip button an instance name (eg, mc_btn) and attached to the timeline frame that contains your button use:

                     


                    import mx.video.*;

                     

                    var tl:MovieClip=this;

                    mc_btn.onRelease=function() {

                     

                    // if you're publishing for fp 8 or greater use:
                    tl.attachMovie("FLVPlayback", "my_FLVPlybk", tl.getNextHighestDepth(), {width:600, height:355, x:100, y:100});

                    my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                    my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv";  
                    my_FLVPlybk.play();
                    trace(my_FLVPybk);  // is a more useful trace to use.
                    }

                     


                    1 person found this helpful
                    • 7. Re: Trying to get flvplybk to trigger on button.
                      ITango2 Level 1

                      Thanks, I had already taken to not attaching code to objects, and did some research on the "depth" part of the function.

                       

                      My vid is still comming out behind however.  A trace indicates that using your code I'm comming in at depth 1.  What is pasting over the top of it is a sort of slide show picture gallery with previous and next buttons.  Since I don't see it like all other stuff on the stage, I'm assuming it's being brought in programaticly, hence it's being able to superceed my video.

                       

                      I believe the symbol in question is a movie clip "pic_01".  I'm not sure how to determine its depth to overide though.

                       

                      So many functions, so little time.

                       

                      Thanks

                      • 8. Re: Trying to get flvplybk to trigger on button.
                        ITango2 Level 1

                        Further info:

                         

                        I can import a movie, place it, and test the scene and it is ok.  Runing the whole site renders it unseeable.  The pictures in this slide show window are definetly rolling over the top of any movie.

                         

                        later that day.... I believe what I have is a "shape" being partly to blame.  A rectangle to give a black background to the slide show area for a progress bar displayed until the pics are downloaded.  Would that take presedence?

                        • 9. Re: Trying to get flvplybk to trigger on button.
                          kglad Adobe Community Professional & MVP

                          what code is used to load your gallery?

                           

                          that will be a loadMove, loadMovieNum or loadClip statement.

                          • 10. Re: Trying to get flvplybk to trigger on button.
                            ITango2 Level 1

                            The only thing I can find other than a movie within pic_01 (to run the progress bar/percentage progression) is...

                             

                             

                            loadMovie(_root.current_pic, this.cont.cont1);

                             

                            As mentioned pic forward and back is handled by a couple of arrow buttons.

                             

                            an example of forward button AS (sadly residing ON the button)..

                             

                            on (rollOver) {this.gotoAndPlay("s1")}
                            on (rollOut) {this.gotoAndPlay("s2")}
                            on (release) {
                                if(_root.flag ==1){       
                                    _root.current_p +=1;
                                    if(_root.current_p >_root.pic_max){_root.current_p = 1;}   
                                    _root.current_pic = _root[("main" + _root.current_p)]
                                    _root.big1.gotoAndPlay("s2");
                                    _root.t1.v=_root[("gallery_txt" + _root.current_p)];
                                   
                                    }
                            }

                            Thanks

                            • 11. Re: Trying to get flvplybk to trigger on button.
                              kglad Adobe Community Professional & MVP

                              try:

                               


                               


                              import mx.video.*;


                              mc_btn.onRelease=function() {

                               

                              // if you're publishing for fp 8 or greater use:
                              _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:100, y:100});

                              my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                              my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv";  
                              my_FLVPlybk.play();
                              trace(my_FLVPybk);  // is a more useful trace to use.
                              }

                               


                              • 12. Re: Trying to get flvplybk to trigger on button.
                                ITango2 Level 1

                                Nuts:

                                 

                                Nothing at all now.  No movie displayed and an "undefined" on the trace.

                                • 13. Re: Trying to get flvplybk to trigger on button.
                                  kglad Adobe Community Professional & MVP

                                  what's the following show:

                                   

                                   


                                   


                                  import mx.video.*;


                                  mc_btn.onRelease=function() {

                                   

                                  // if you're publishing for fp 8 or greater use:
                                  _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:100, y:100});

                                  my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                                  my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv";  
                                  my_FLVPlybk.play();

                                  trace(_root.getNextHighestDepth());
                                  trace(my_FLVPybk);  // is a more useful trace to use.
                                  }

                                   


                                  • 14. Re: Trying to get flvplybk to trigger on button.
                                    ITango2 Level 1

                                    Odd.  First trace = 1, second trace = undefined

                                    • 15. Re: Trying to get flvplybk to trigger on button.
                                      kglad Adobe Community Professional & MVP

                                      do you have an flvplayback component in your library?

                                      • 16. Re: Trying to get flvplybk to trigger on button.
                                        ITango2 Level 1

                                        Yes, Its been there all along.

                                         

                                        The code works when using the...

                                         

                                        var tl:MovieClip=this;

                                         

                                        from your earlier code, just that it winds up behind the subsequently loaded clip.  using the above returns expected info on both traces.

                                         

                                        CODE:

                                         

                                        import mx.video.*;
                                        var tl:MovieClip=this;
                                        playvid_btn.onRelease=function() {

                                         

                                        tl.attachMovie("FLVPlayback", "my_FLVPlybk", tl.getNextHighestDepth(), {width:600, height:355, x:10, y:10});
                                        my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                                        my_FLVPlybk.contentPath = "casino1.flv"; 
                                        my_FLVPlybk.play();
                                        trace(tl.getNextHighestDepth());
                                        trace(my_FLVPlybk);

                                         

                                        }

                                         

                                         

                                        RETURNS:

                                         

                                        1
                                        _level0.instance756.my_FLVPlybk

                                         

                                        @@@@@@@@@

                                         

                                         

                                        CODE:

                                         

                                        import mx.video.*;
                                        // var tl:MovieClip=this;
                                        playvid_btn.onRelease=function() {

                                         

                                        _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:10, y:10});
                                        my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                                        my_FLVPlybk.contentPath = "casino1.flv"; 
                                        my_FLVPlybk.play();
                                        trace(_root.getNextHighestDepth());
                                        trace(my_FLVPlybk);

                                         

                                        }

                                         

                                        RETURNS:

                                         

                                        1
                                        undefined

                                         

                                        I've been reading on depth, but not entirely clear on who wins with multiple clips loading.  Also from what I've read, _root.attachMovie should work.

                                        • 17. Re: Trying to get flvplybk to trigger on button.
                                          kglad Adobe Community Professional & MVP

                                          what the trace output using:

                                           


                                          import mx.video.*;

                                          playvid_btn.onRelease=function() {

                                           

                                          trace(_root);

                                          var mc:MovieClip = _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:10, y:10});

                                          trace(mc);

                                           

                                          my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                                          my_FLVPlybk.contentPath = "casino1.flv"; 
                                          my_FLVPlybk.play();
                                          trace(_root.getNextHighestDepth());
                                          trace(my_FLVPlybk);

                                           

                                          }

                                           

                                          RETURNS:

                                           

                                          1
                                          undefined

                                           

                                          I've been reading on depth, but not entirely clear on who wins with multiple clips loading.  Also from what I've read, _root.attachMovie should work.

                                          • 18. Re: Trying to get flvplybk to trigger on button.
                                            ITango2 Level 1

                                            _level0
                                            _level0.my_FLVPlybk
                                            1
                                            undefined

                                             

                                            Not sure what that says of things.

                                             

                                            Thanks for hanging in there.

                                            • 19. Re: Trying to get flvplybk to trigger on button.
                                              kglad Adobe Community Professional & MVP

                                              that code must not be on your _root timeline.

                                               

                                              use:

                                               


                                               


                                              import mx.video.*;

                                              playvid_btn.onRelease=function() {

                                              var mc:MovieClip = _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:10, y:10});

                                              mc.skin = "ClearOverPlaySeekMute.swf"
                                              mc.contentPath = "casino1.flv"; 
                                              mc.play();

                                              // outside (and inside) this onRelease, you can use _root.my_FLVPlybk to reference your component.

                                              }


                                              • 20. Re: Trying to get flvplybk to trigger on button.
                                                ITango2 Level 1

                                                I'm a bit lost then.

                                                 

                                                Page4 (movieclip) has 2 layers, two text boxes, and the movieclip button playvid_btn overlayed on one of the static text boxes

                                                 

                                                In the 2 layer timeline, I put the code on layer1 frame 1.  Is this incorrect?  If I move the code out of this area, the button becomes inactive.

                                                 

                                                Thank you for being so educational. ;-)

                                                 

                                                Capture.JPG

                                                • 21. Re: Trying to get flvplybk to trigger on button.
                                                  kglad Adobe Community Professional & MVP

                                                  you confirmed what i just concluded:  your code is not on the _root timeline.  it's on the timeline of a movieclip (Page4).

                                                   

                                                  so, you're creating your flvplayback instance ok but you're not referencing it correctly when you try to assign its contentPath and its skin.  use the code i suggested in my last message and you should be done.

                                                  • 22. Re: Trying to get flvplybk to trigger on button.
                                                    ITango2 Level 1

                                                    Your latest code does indeed do exactly what the intent was.  Thank you!

                                                     

                                                    As mentione, I was aware of not to put code on an object and indeed had put it on the timeline of what was being worked with (page4).  Now, that said (and after a good deal of research) I'm curious just how/what the _root timeline is defined.

                                                     

                                                    If I open the swf, i've got about 30 layers in front of me.  If I use the top layer (named by the original author "script") and select frame1, open the action window, and use thhe previous code, the button is dissabled.  I don't even get the curser changing to a hand when over it (I had tried that very thing in an earlier post above).  So, I'm not sure WHERE that _root timeline is, and if I am in the correct place, do I reference in a drill down fassion?  I.E. _root.page4.playvid_btn?

                                                     

                                                    Thanks kglad for having the patience to teach a person to fish for themselves.  Much appreciated

                                                     

                                                    Best regards.

                                                     

                                                    Dirk

                                                    • 23. Re: Trying to get flvplybk to trigger on button.
                                                      kglad Adobe Community Professional & MVP

                                                      the _root timeline is your main timeline.  if you're only working with one swf (and not loading one swf into another), the main timeline is the one you see when you first open your fla in flash.  if you have an object on the timeline named page4 and on page4's timeline you have playvid_btn, then yes, you would could use _root.page4.playvid_btn to reference playvid_btn.

                                                       

                                                      problems start when you complete this project with everything working well and then you use another swf to load the completed swf.  the _root timeline is no longer the main timeline in your completed swf, it's the main timeline in the loading (main) swf.

                                                       

                                                      adobe/macromedia took pity on as2 developers and created the _lockroot property that allows you to add the following to your main timeline:

                                                       

                                                      this._lockroot = true;

                                                       

                                                      then, no matter what you do, _root in your swf will always reference the main timeline in that swf even if that swf is loaded into another.

                                                      • 24. Re: Trying to get flvplybk to trigger on button.
                                                        ITango2 Level 1

                                                        I'm curious as to how your last code above works.  It seems very similar.  Is it due to it becoming global being assigned to a var?

                                                         

                                                        in the code below, what part (if on the main timeline) references that button then?  playvid_btn movieclip is in page4 movieclip.

                                                         

                                                        Im not exectly sure how to ferret out stuff on the timeline to get a perspective on the hirearchy.

                                                         

                                                        import mx.video.*;

                                                         

                                                        playvid_btn.onRelease=function() {

                                                         

                                                        _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:100, y:100});

                                                         

                                                        my_FLVPlybk.skin = "ClearOverPlaySeekMute.swf"
                                                        my_FLVPlybk.contentPath = "http://www.satinnlatindance.com/images/casino1.flv"; 
                                                        my_FLVPlybk.play();
                                                        trace(my_FLVPybk);  // is a more useful trace to use.

                                                         

                                                        }

                                                         

                                                             I'll put this to rest now.'

                                                         

                                                        Thanks

                                                        • 25. Re: Trying to get flvplybk to trigger on button.
                                                          kglad Adobe Community Professional & MVP

                                                          no, nothing was made global.  in fact, i used a local (to the onRelease function) variable (mc).

                                                           

                                                          the essential change was i used the correct reference to the my_FLVPlybk.

                                                           



                                                           


                                                          import mx.video.*;

                                                          playvid_btn.onRelease=function() {

                                                          // mc is a correct reference inside this onRelease

                                                          var mc:MovieClip = _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:10, y:10});

                                                          mc.skin = "ClearOverPlaySeekMute.swf"
                                                          mc.contentPath = "casino1.flv"; 
                                                          mc.play();

                                                          // outside (and inside) this onRelease, you can use _root.my_FLVPlybk to reference your component.

                                                          }


                                                          this would also work:

                                                           


                                                           


                                                          import mx.video.*;

                                                          playvid_btn.onRelease=function() {

                                                          _root.attachMovie("FLVPlayback", "my_FLVPlybk", _root.getNextHighestDepth(), {width:600, height:355, x:10, y:10});

                                                          _root.myFLVPlybk.skin = "ClearOverPlaySeekMute.swf"

                                                          _root.my_FLVPlybk.contentPath = "casino1.flv"; 
                                                          _root.my_FLVPlybk.play();

                                                          }


                                                          and, in general, the correct reference for an attachMovie instance is whatever_mc.whateverinstancename when you use:

                                                           

                                                           

                                                          whatever_mc.attachMovie("whateverlinkageID","whateverinstancename",somedepth);

                                                           

                                                          p.s.  you can also determine the path to a timeline by using:

                                                           

                                                          trace(this);  // attached to the timeline.

                                                           

                                                          p.p.s.  if you have an object on a timeline with instance name my_mc, you can determine the path to it using:

                                                           

                                                          trace(my_mc);  // attached to the timeline containing my_mc.

                                                          • 26. Re: Trying to get flvplybk to trigger on button.
                                                            ITango2 Level 1

                                                            Try as I will, it just won't work from the _root.  Nether piece of code.

                                                             

                                                            If its on the root, the MC button (playvid_btn) is dissabled.  What I "believe" is the hierarchy is _root > page4 (movieclip) > playvid_btn (movieclip).

                                                             

                                                            With the code on page4 timeline (so I can click something) trace(this); returns _level0.instance747.playvid_btn

                                                             

                                                            Thanks

                                                             

                                                            Should a picture have any value.....

                                                             

                                                            Capture.JPG

                                                            • 27. Re: Trying to get flvplybk to trigger on button.
                                                              kglad Adobe Community Professional & MVP

                                                              page4 does not have an instance name.  flash is assigning it a default name (instance747).

                                                               

                                                              assign it an instance name by clicking it and, in the properties panel, typing page4.

                                                              • 28. Re: Trying to get flvplybk to trigger on button.
                                                                ITango2 Level 1

                                                                That was exactly what I thought was going on this morning when I looked at that trace, and have invested a few hours into researching how to set/change it.

                                                                 

                                                                Unfortunately, I'm unable to find it.  If I double click on page4 in the library the stage changes to that, which contains two text boxes and my playvid_btn movieclip.  I've been unable to determine just how to get the properties box to come up for page4 itself.

                                                                • 29. Re: Trying to get flvplybk to trigger on button.
                                                                  kglad Adobe Community Professional & MVP

                                                                  in movie explorer, toggle movieclips/buttons/graphics and search for instance747.  double click the found movieclip in the explorer panel.

                                                                  • 30. Re: Trying to get flvplybk to trigger on button.
                                                                    ITango2 Level 1

                                                                    I don't think movie explorer is working ;-)

                                                                     

                                                                    I followed your instructtions, and it finds noting with just the single filter you suggested, and tried playvid_btn, also nothing.  I also tried just actionscript and entered flv which we know is in there and it also found nothing.

                                                                     

                                                                    I ran the trace again to make sure of the name.

                                                                     

                                                                    I've also noticed that the instance number changes every time the program is run.  Since it seems to be generated dynamicly, that may be why it's not showing up.

                                                                     

                                                                    and later that night....

                                                                     

                                                                    IT seems I found a way to back door it.  After alot of forum reading I came accross a long thread that indicate people were having problems with CS5 not allowing edits to the instance box on clips.  One of the solutions was open the actions panel and select the "insert a target path" , then when I selected page4 it complained that it did not have an instance name and allowed me to provide one.  The trace now reads...

                                                                     

                                                                    _level0.page4.playvid_btn

                                                                     

                                                                    I would still like to know how to do this properly.  The movieclip (many others do not have a way to get to the instance) may need to have an instance assigned in the future

                                                                     

                                                                    Am I to assune that _level0 means _root?

                                                                     

                                                                     

                                                                    Thanks for working this out.

                                                                     

                                                                    Message was edited by: ITango2

                                                                    • 31. Re: Trying to get flvplybk to trigger on button.
                                                                      ITango2 Level 1

                                                                      Well, its been a fun week and incredible experience, but its working with the code in the root timeline.

                                                                       

                                                                      Fortunately in all this reading I remembered something saying the code also had to be in the root timeline at a point where the object came into use.  So, the code is on frame 360 of the root timeline first layer named script by the previous author.

                                                                       

                                                                      The only unanswered questions are...

                                                                       

                                                                      Why can't I find a place to set a reference on these movie clips?  (had to backdoor the page4)

                                                                       

                                                                      Is there quick reference to what all these icon/symbols/colors mean in the timeline?  (frames with actionscript are supppose to show a small a, they do, mine doesn't)  I'd like to find it in the future.

                                                                       

                                                                      X and Y parameters are working, but width and height are not on FVLPlayback.  I've use known numbers that would be larger and smaller than the video being loaded.

                                                                       

                                                                      Thanks greatly for all I've learned ;-)

                                                                      • 32. Re: Trying to get flvplybk to trigger on button.
                                                                        kglad Adobe Community Professional & MVP

                                                                         

                                                                        Why can't I find a place to set a reference on these movie clips?  (had to backdoor the page4)

                                                                        use the properties panel

                                                                         

                                                                        Is there quick reference to what all these icon/symbols/colors mean in the timeline?  (frames with actionscript are supppose to show a small a, they do, mine doesn't)  I'd like to find it in the future.

                                                                        check the flash help files.

                                                                         

                                                                        X and Y parameters are working, but width and height are not on FVLPlayback.  I've use known numbers that would be larger and smaller than the video being loaded.

                                                                         

                                                                        Thanks greatly for all I've learned ;-)

                                                                         

                                                                        you're welcome.

                                                                        • 33. Re: Trying to get flvplybk to trigger on button.
                                                                          ITango2 Level 1

                                                                          I wish I could use the properties page.

                                                                           

                                                                          Several days ago I was thinking that the page4 movie clip did not have an instance named.  You confirmed that with the suggested trace.  However I've found no way to FIND page4 other than the library.

                                                                           

                                                                          If I click on page4 in the library, it shows me my two text boxes, one of whichis overlayed with the playvid_btm movie clip.  I can click on any of the three and get an editable properties panel.  If I click on the background (assumed to be the page4 movieclip itself) I get nothing in the properties panel other than the standard properties panel of the document showing publish settings, profile, etc.

                                                                           

                                                                          Just can't seem to find it, and ther are MANY movie clips in the same state.