2 Replies Latest reply on Sep 13, 2010 3:16 AM by DanielPopescu

    Video object & auto-resize

    Squall86

      Hi, I need to add at run-time a video object to a panel, making sure its size matches panel's.

      The spark videoDisplay object has some nice percentualHeight and percentualWidth attributes, but the problem is that I cannot attach webcam and netstream to it, which is what I really need, on the contrary the Video object allows me to attach webcam/netstream but has not percentualHeight and percentualWidth attributes.

      Is there a way to solve this problem?

        • 1. Re: Video object & auto-resize
          Squall86 Level 1

          No one?T_T

          • 2. Re: Video object & auto-resize
            DanielPopescu

            Use the resize event handler of your video object holder and set the new size.

             

            <?xml version="1.0" encoding="utf-8"?>
            <!-- Copyright (c)- 2010 Daniel Popescu -->
            <s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx"
                     width="100%" height="100%"
                     creationComplete="group_creationCompleteHandler(event)" >
                <fx:Script>
                    <![CDATA[
                        import mx.events.FlexEvent;
                        import mx.events.ResizeEvent;
                       
                        private var video:Video;

             

                        protected function group_creationCompleteHandler(event:FlexEvent):void
                        {
                            video = new Video(holder.width, holder.height);
                           
                            holder.addChild(video);
                        }

             

                        protected function holder_resizeHandler(event:ResizeEvent):void
                        {
                            if(video)
                            {
                                video.width = holder.width;
                                video.height = holder.height;
                            }
                        }

             

                    ]]>
                </fx:Script>
                <mx:UIComponent id="holder"
                                width="100%" height="100%"
                                resize="holder_resizeHandler(event)" />
            </s:Group>