1 Reply Latest reply on Apr 8, 2010 10:55 AM by leaflashdev

    parallelElement clean all - Osmf

    leaflashdev Level 1

      Hello ,

       

      I am using the parallelElement to load several mediaElement in the same time

       

      First I do

       

      mediaPlayer = new MediaPlayer();
      mediaContainer = new MediaContainer();
      parallElement = new ParallelElement();
      mediaContainer.addMediaElement(parallElement);
      _mainMc.addChild(mediaContainer);

       

       

      When I clik on a button I load some images I run this function 3 times with 3 different images

       

      public function loadImage(id, mediaToPlay){

       

                  MediaElement1 =new ImageElement(new URLResource(mediaToPlay))
                  var layout2:LayoutMetadata = new LayoutMetadata();
                  layout2.x = (id-1)*1024;
                
                  MediaElement1.addMetadata(LayoutMetadata.LAYOUT_NAMESPACE, layout2);
               
                  parallElement.addChild(MediaElement1)
                 
                  mediaPlayer.media = MediaElement1;
                 
              }

       

       

      When I click in another button I would like to clean everything

      THE MEDIACONTAINER

      THE PARALLELELEMENT

       

      cannot find the right way to do that

       

      Any ideas ?

      Thank you

        • 1. Re: parallelElement clean all - Osmf
          leaflashdev Level 1

          I found a way to erase everything, If it can helps

           

          Here is my function

           


                      _mainMc.removeChild(mediaContainer);
                      _mainMc.addChild(mediaContainer);
                      mediaContainer.removeMediaElement(parallElement);
                      mediaContainer.addMediaElement(parallElement);
                      mediaPlayer.media=undefined;
                     
                      if(parallElement.numChildren){
                          var count:uint = parallElement.numChildren;
                          for(var i:uint=0;i<count;i++){
                          parallElement.removeChildAt(0);
                          }
                      }