3 Replies Latest reply on Mar 14, 2013 5:03 PM by Ned Murphy

    Can external calls be send from movieclips?

    ggaarde Level 1

      I am able to have buttons in a flash file trigger a Javascript function that in turn sends a event tracking message to Google Analytics.

       

      My button sends the main playhead to a particular frame where it stops.

       

      The AS is placed on that frame (not the button) and looks like this:

       

      stop();

      import flash.external.ExternalInterface;

      vid_rec.onRelease=function(){

      ExternalInterface.call("fv4");

       

       

      }

       

      (vid_rec is the instance name of the button.)

       

      The Javascript:

       

      function fp4(){

       

      The JS function looks like this:

      _gaq.push(['_trackEvent','Category','Action','Label',]); 

        }

       

      This works nicely and Google Analytics is readily showing my category, the Action and the Label.

       

      I am using this to track how many people listen to a sound recording.

      Another one is tracking a different button that leads to a Captivate file.

       

       

      Here is my problem:

       

      I need to monitor Video visits as well.

       

      My video is placed in a movie clip that is dropped on the main scene in a particular frame.

       

      I have a short shape animation right before the movie starts. Let us say the animation starts in frame 10 and goes to frame 16 where there is a stop action. On that frame the movie clip with the video is placed.

       

      I have tried to have the External interface code in both the frame where the movie clip lives and the first frame of the animation, but it does not work either way. Seems to me that I have tried to have the code inside the movieclip on the frame where the movie runs as well. And that it also did not produce a hit.

       

       

      Since it works well to have the code in the main time line in the other cases, I do not understand what is different about the video, other than that it lives in a movie clip.

       

      Do you have any other suggestions where to place the code?

       

      Thanks on beforehand.

       

      ggaarde

        • 1. Re: Can external calls be send from movieclips?
          Ned Murphy Adobe Community Professional & MVP

          I don't see why it wouldn't work the same either since it does not appear to be timeline related as far as the code goes.  Have you mixed a trace in with the code to confirm that the code is executing?

           

          What you might try just to see is to place the function in the main timeline and try calling it from within the movieclip using a _root reference to target it.

          1 person found this helpful
          • 2. Re: Can external calls be send from movieclips?
            ggaarde Level 1

            Hi Ned.

             

            Good idea with the trace code. It executes on the ones that are going to GA but not on the videos.

             

            I tried to move the video to the main time line, but that did not make a difference.

             

            Also tried to just take the playhead to an empty frame and move the code there, and that did not trigger the trace either.

             

            Now I am even more mystified...

             

            If i was going to try your approach of placing the function on the main time line where should it go? and what would the actual syntax be for both the function and ther movie clip calling it?

             

            Thank you on beforehand.

             

            ggaarde

            • 3. Re: Can external calls be send from movieclips?
              Ned Murphy Adobe Community Professional & MVP

              If the code is not executing, that's a better mystery to try to solve.

               

              For putting the function in the main timeline just place the function in a layer that extends as far as it needs to be accessible.  If you name the function aFunction, then the code to call it from within the movieclip could be _root.aFunction();

               

              But if you don't solve why the code is not executing, chances are you will find yourself in the same situation where the function call never gets made.

              1 person found this helpful