5 Replies Latest reply on Mar 24, 2010 9:06 PM by bringrags

    Brian Riggs FM-333

    jerryhamby

      Brian,

       

      I noticed that you marked FM-333 fixed.

      I opened SerialElement.as in the truck for a look see.

      Is this the latest version?

       

      I'm hoping that somewhere in there, I can also get access to the

      current child number (0, 1, 2, etc...), not just the currentChild.

       

      Can I find the number in the event that is dispatched?

        • 1. Re: Brian Riggs FM-333
          bringrags Level 4

          Hmm, I suppose currentChildIndex would be a bit more useful than currentChild, in that you could get the next or previous child just by adjusting the index instead of having to first calculate the index by iterating over the list until you find the item that matches currentChild.  Would you prefer to see currentChildIndex rather than currentChild?

          • 2. Re: Brian Riggs FM-333
            jerryhamby Level 1

            curentChildIndex pleaseeeeeeeee.

            The current child number is much more useful

            for a lot of reasons.

             

            Playlists come to mind.

            • 3. Re: Brian Riggs FM-333
              bringrags Level 4

              It was pointed out to me that you can easily get from child to child index, just call CompositeElement.getChildIndex.  And our API review board felt that currentChild would be clearer than currentChildIndex.  So I just wanted to let you know that we're planning to keep it as currentChild.

              • 4. Re: Brian Riggs FM-333
                jerryhamby Level 1

                Assuming I understand the gist of your statement, would this code work

                in Sprint 11 with the current FM-333 fix?  Returning a different number

                as the player works is way through the SerialElement.

                 

                I can't test because I'm on Sprint 10 and I'm not working with the trunk.

                 

                var pSerialElement:SerialElement = new SerialElement;

                pSerialElement.addChild(new DurationElement(3, new ImageElement(new URLResource(THE_IMAGE), new ImageLoader() )));

                pSerialElement.addChild(new DurationElement(3, new ImageElement(new URLResource(THE_IMAGE2), new ImageLoader() )));

                pSerialElement.addChild(new DurationElement(3, new ImageElement(new URLResource(THE_IMAGE3), new ImageLoader() )));

                 

                var pFactory:MediaFactory = new DefaultMediaFactory();

                var pMediaElement:MediaElement = pFactory.createMediaElement(new URLResource(pSerialElement));

                 

                var pContainer:MediaContainer = new MediaContainer();

                pContainer.addMediaElement(pMediaElement);

                 

                var pMediaPlayer:MediaPlayer = new MediaPlayer(pMediaElement);

                 

                var pCompositeElement:CompositeElement = new CompositeElement();

                pCompositeElement.addChild(pMediaElement);

                 

                pMediaPlayer.addEventListener(DisplayObjectEvent.MEDIA_SIZE_CHANGE, mMediaSizeChange);

                 

                public function mMediaSizeChange(evt:DisplayObjectEvent):void{

                   trace( pCompositeElement.getChildIndex(pMediaElement.currentChild() ));

                }

                 

                I'm not sure about the pMediaElement.currentChild()  part.

                 

                Desired trace results:

                0

                1

                2

                 

                If I'm missing anything, let me know.

                • 5. Re: Brian Riggs FM-333
                  bringrags Level 4

                  The gist of what you're doing seems valid, although pCompositeElement would need to be an instance of a subclass of SerialElement, and you'd have to expose the currentChild publicly on that subclass.