3 Replies Latest reply on Jan 18, 2010 12:46 PM by kglad

    AS2 - Help with EventListener and multiple cuepoints

    hypnocookie123

      Hi, I'm really stuck on this and hope some one can help. I am quite familiar with Actionscript 2 but new to using cue points.

       

      I have followed a simple tutorial on using event listeners here and modified it slightly to my own needs but its not working. Here is what I have in the scene:

       

      - A video (an flv with the instance name compBack) with 3 event cuepoints in it - called Comp_1, Comp_2 & Comp_3,

      - 6 images - image_1L, image_1R, image_2L, image_2R, image_3L, image_3R (that is their instance names).

       

      When the playhead enters the first frame of the scene action script sets image_XX._visible = false and my video with the cue points in it also starts playing.

       

      What I want is for when cuepoint Comp_1 is reached the event listener sets image_1L._visible = true & image_1R._visible = true. then cue point Comp_2 should do image_2L & image_2R and so on.

       

      here is my script:

                     --------------------------------------------------

                     1.   stop();
                     2.   image_1L._visible = false;
                     3.   image_1R._visible = false;
                     4.   image_2L._visible = false;
                     5.   image_2R._visible = false;

       

                     6.   image_3L._visible = false;
                     7.   image_4R._visible = false;

                     8.

                     9.   var vidList:Object = new Object();

                     10. vidList.cuePoint = cuePointCatcher;

                     11.

                     12. function cuePointCatcher (Comp_1) {

                     13.     image_1L._visible = true;

                     14.     image_1R._visible = true;

                     15. }

                     16.

                     17. compBack.addEventListener("cuePoint", vidList);

                     -------------------------------------------------

       

      the script above as it is works fine, image 1L&1R become visible at the correct time during playback. However, when I add a function to line 16 to act when Comp_2 is hit it doest not work, and image 1L&1R no longer become visible either. The code is now:

       

                     -----------------------------------------------

                     9.   var vidList:Object = new Object();

                     10. vidList.cuePoint = cuePointCatcher;

                     11.

                     12. function cuePointCatcher (Comp_1) {

                     13.     image_1L._visible = true;

                     14.     image_1R._visible = true;

                     15. }

                     16. function cuePointCatcher (Comp_2){

                     17.   image_2L._visible = true;

                     18.   image_2R._visible = true;

                     19. }

                     20.

                     21. compBack.addEventListener("cuePoint", vidList);

                     -----------------------------------------------

       

      If any one can help I would greatly appreciate it.

       

      Thanks in advance

        • 1. Re: AS2 - Help with EventListener and multiple cuepoints
          kglad Adobe Community Professional & MVP

          you should be using one listener and using your eventobject to determine which cuepoint has been reached.

          • 2. Re: AS2 - Help with EventListener and multiple cuepoints
            hypnocookie123 Level 1

            Thanks for that Kglad. I have it working (sometimes all you need is sleep to see what is missing)

             

            To help any one else who may be suffering the same hedace here is my new code that now works perfectly.

             

            I have renamed a couple of bits and added a cuepoint caled 'Comp_end' and an image with the same instance name, my video instance name is CompBack.

             

            var MyCuePointListener:Object = new Object();
            MyCuePointListener.cuePoint = function(eventObject:Object):Void {
               if (eventObject.info.name == "Comp_1") {
                    image_1L._visible = true;
                    image_1R._visible = true;
                }

             

                if (eventObject.info.name == "Comp_2") {
                    image_2L._visible = true;
                    image_2R._visible = true;
                }

             

                if (eventObject.info.name == "Comp_3") {
                    image_3L._visible = true;
                    image_3R._visible = true;
                }
                    if (eventObject.info.name == "Comp_end") {
                    Comp_end._visible = true;
                }
            };

             

            compBack.addEventListener("cuePoint", MyCuePointListener);