3 Replies Latest reply on Mar 7, 2010 4:16 AM by Ned Murphy

    Duplicate Function

    c-fqgy Level 1

      Hello,

      I have a flash movie that moves ahead in the animation based off the audio. I've broken the movie up into a few scenes so that I can keep things really easy for myself. However because I'm using the same function to read the audio in the different scenes I'm getting a duplicate function error. I've been looking around the web and have tried to play with my code but I'm pretty clueless when it comes to AS and would really appreciate a little help or a nug in the right direction.

       

      Original Function that works great in the individual scenes but fails when played together:

      Scene 1Scene 2

      import fl.video.MetadataEvent;


      audio.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Wealthy") gotoAndPlay(2);

      if (eventObject.info.name == "Happy") gotoAndPlay(3);

      if (eventObject.info.name == "Healthy") gotoAndPlay(4);

      if (eventObject.info.name == "Home") gotoAndPlay(5);

      if (eventObject.info.name == "Neighbourhood") gotoAndPlay(6);

      if (eventObject.info.name == "End") gotoAndPlay(7);

      }

      import fl.video.MetadataEvent;


      audio.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Components") gotoAndPlay(71);

      }

       

       

       

      Shots in the dark:

      Scene 1Scene 2

      import fl.video.MetadataEvent;


      audio_001.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Wealthy") gotoAndPlay(2);

      if (eventObject.info.name == "Happy") gotoAndPlay(3);

      if (eventObject.info.name == "Healthy") gotoAndPlay(4);

      if (eventObject.info.name == "Home") gotoAndPlay(5);

      if (eventObject.info.name == "Neighbourhood") gotoAndPlay(6);

      if (eventObject.info.name == "End") gotoAndPlay(7);

      }

      import fl.video.MetadataEvent;


      audio_002.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Components") gotoAndPlay(71);

      }

      import fl.video.MetadataEvent;


      audio.addEventListener(MetadataEvent.CUE_POINT, cp_listener001);

      function cp_listener001(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Wealthy") gotoAndPlay(2);

      if (eventObject.info.name == "Happy") gotoAndPlay(3);

      if (eventObject.info.name == "Healthy") gotoAndPlay(4);

      if (eventObject.info.name == "Home") gotoAndPlay(5);

      if (eventObject.info.name == "Neighbourhood") gotoAndPlay(6);

      if (eventObject.info.name == "End") gotoAndPlay(7);

      }

      import fl.video.MetadataEvent;


      audio.addEventListener(MetadataEvent.CUE_POINT, cp_listener002);

      function cp_listener002(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Components") gotoAndPlay(71);

      }

      import fl.video.MetadataEvent;


      audio.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Wealthy") gotoAndPlay(2);

      if (eventObject.info.name == "Happy") gotoAndPlay(3);

      if (eventObject.info.name == "Healthy") gotoAndPlay(4);

      if (eventObject.info.name == "Home") gotoAndPlay(5);

      if (eventObject.info.name == "Neighbourhood") gotoAndPlay(6);

      if (eventObject.info.name == "End") gotoAndPlay(7);

      if (eventObject.info.name == "Components") gotoAndPlay("Interactive Charts", 71);

      }

      import fl.video.MetadataEvent;


      audio001.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      audio002.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Wealthy") gotoAndPlay(2);

      if (eventObject.info.name == "Happy") gotoAndPlay(3);

      if (eventObject.info.name == "Healthy") gotoAndPlay(4);

      if (eventObject.info.name == "Home") gotoAndPlay(5);

      if (eventObject.info.name == "Neighbourhood") gotoAndPlay(6);

      if (eventObject.info.name == "End") gotoAndPlay(7);

      if (eventObject.info.name == "Components") gotoAndPlay("Interactive Charts", 71);

      }

      import fl.video.MetadataEvent;


      audio001.addEventListener, audio002.addEventListener(MetadataEvent.CUE_POINT, cp_listener);

      function cp_listener(eventObject:MetadataEvent):void

      {

      if (eventObject.info.name == "Wealthy") gotoAndPlay(2);

      if (eventObject.info.name == "Happy") gotoAndPlay(3);

      if (eventObject.info.name == "Healthy") gotoAndPlay(4);

      if (eventObject.info.name == "Home") gotoAndPlay(5);

      if (eventObject.info.name == "Neighbourhood") gotoAndPlay(6);

      if (eventObject.info.name == "End") gotoAndPlay(7);

      if (eventObject.info.name == "Components") gotoAndPlay("Interactive Charts", 71);

      }

       

      I don't really know which direction to head so I'm going to see if I can figure out how to end the listeners after they have finished. I have NO idea if that will work... I will really look forward to reading your suggestions!!!