7 Replies Latest reply on Dec 19, 2008 4:10 PM by Newsgroup_User

    problem in tilelist with dataprovider.

    mezrac
      I have a problem in tilelist. with the dataprovider a get the message error
      ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
      at flash.display::DisplayObjectContainer/removeChild()

      if i delete the images from the last added to the first one i have no prob but if i want to delete from the middle i get the message error th sode that i use is

      <mx:TileList id="tileList"
      dataProvider="{imgData}"

      columnCount="4"
      columnWidth="222"
      rowCount="2"
      rowHeight="194"
      themeColor="haloSilver"
      verticalScrollPolicy="on"
      x="0" y="415" width="100%">
      <mx:itemRenderer>
      <mx:Component>
      <mx:VBox horizontalAlign="center"
      verticalAlign="middle" width="222" height="194" verticalScrollPolicy="off" horizontalScrollPolicy="off" >
      <mx:Image id="img" width="165" height="126" maintainAspectRatio="true" source="{data.asset}" />
      <mx:Label id="txt" text="{data.title}"/>
      <mx:Button id="del" label="Delete" click="outerDocument.deleteSnapShot(event)"/>
      </mx:VBox>
      </mx:Component>
      </mx:itemRenderer>
      </mx:TileList>


      the function to add the image is :

      public function addImgToTile(bm:Bitmap):void{
      var bm1:BitmapData = Bitmap(bm1_source.content).bitmapData;
      var bitmap:Bitmap = new Bitmap(bm1);

      var vo:MyVOBm = new MyVOBm(bitmap,formatTime(inStream.time));
      imgData.addItem(vo);
      }

      And the function to delete the image is:

      public function deleteSnapShot(ev:Event):void{
      imgData.removeItemAt(tileList.selectedIndex);
      }

      tx for your help
        • 1. Re: problem in tilelist with dataprovider.
          Level 7

          "mezrac" <webforumsuser@macromedia.com> wrote in message
          news:gibhlk$afp$1@forums.macromedia.com...
          >I have a problem in tilelist. with the dataprovider a get the message error
          > ArgumentError: Error #2025: The supplied DisplayObject must be a child of
          > the
          > caller.
          > at flash.display::DisplayObjectContainer/removeChild()
          >
          > if i delete the images from the last added to the first one i have no prob
          > but
          > if i want to delete from the middle i get the message error th sode that i
          > use
          > is

          The code provided shows your manipulating the ArrayCollection dataprovider,
          as you should, but the error message makes it seem like you're trying to
          directly manipulate something. Can you post more complete code?

          Thanks;

          Amy


          • 2. Re: problem in tilelist with dataprovider.
            mezrac Level 1
            tx Amy for your help here i give you the code that generate the image from streaming video

            <mx:Canvas id="videoHBox" horizontalScrollPolicy="off" verticalScrollPolicy="off" backgroundColor="#000000" width="456" height="284" y="37">

            </mx:Canvas>

            <mx:Button x="464" y="188" label="In" width="48" id="btnIn" click="addStart(inStream.time);" enabled="true" visible="true" useHandCursor="true" buttonMode="true" toolTip="Add Start Image (shotcut Home)"/>

            <mx:Button id="Btn_add_action" x="464" y="221" label="Add Screenshot" click="addImgToTile(bm1)" useHandCursor="true" buttonMode="true" toolTip="Add Clip (shotcut insert)"/>

            <mx:TileList id="tileList"
            dataProvider="{imgData}"

            columnCount="4"
            columnWidth="222"
            rowCount="2"
            rowHeight="194"
            themeColor="haloSilver"
            verticalScrollPolicy="on"
            x="0" y="415" width="100%">
            <mx:itemRenderer>
            <mx:Component>
            <mx:VBox horizontalAlign="center"
            verticalAlign="middle" width="222" height="194" verticalScrollPolicy="off" horizontalScrollPolicy="off" >
            <mx:Image id="img" width="165" height="126" maintainAspectRatio="true" source="{data.asset}" />
            <mx:Label id="txt" text="{data.title}"/>
            <mx:Button id="del" label="Delete" click="outerDocument.deleteSnapShot(event)"/>
            </mx:VBox>
            </mx:Component>
            </mx:itemRenderer>
            </mx:TileList>


            variable:

            private var videoHolder:UIComponent = new UIComponent();
            [Bindable] public var imgData:ArrayCollection = new ArrayCollection();

            init :

            nc = new NetConnection();
            nc.addEventListener(NetStatusEvent.NET_STATUS, netStatus);
            nc.addEventListener(SecurityErrorEvent.SECURITY_ERROR, netSecurityError);
            nc.connect(Srv_Name);


            videoHolder.setActualSize(Playing_Video_width, Playing_Video_height);
            Playing_Video = new Video(Playing_Video_width, Playing_Video_height);
            videoHolder.addChild(Playing_Video);
            Playing_Video.x = 0;
            Playing_Video.y = 0;
            videoHBox.width = Playing_Video.width;
            videoHBox.height = Playing_Video.height;
            videoHBox.addChild(videoHolder);

            functions:

            public function addStart(timecode:Number):void{
            var bm:Bitmap = copyBitmap(videoHBox as UIComponent,timecode,"start");
            bm1 = bm;
            img_start_time.text = formatTime(timecode);
            start_time = timecode;
            }

            public function addImgToTile(bm:Bitmap):void{
            var bm1:BitmapData = Bitmap(bm1_source.content).bitmapData;
            var bitmap:Bitmap = new Bitmap(bm1);

            var vo:MyVOBm = new MyVOBm(bitmap,formatTime(inStream.time));
            imgData.addItem(vo);
            }


            private function copyBitmap(source:UIComponent,timecode:Number,origin:String=''):Bitmap {
            try{
            var bmd:BitmapData = new BitmapData( source.width, source.height );
            bmd.draw(source);
            corectImg = false;
            }
            catch (err:Error){
            this.setFocus();
            inStream.seek(timecode);
            if (origin == "start") setTimeout(addStart,750,timecode);
            }
            return new Bitmap(bmd);
            }

            public function deleteSnapShot(ev:Event):void{

            imgData.list.removeItemAt(tileList.selectedIndex);

            }

            and the MyVOBm class is :


            package components
            {
            import flash.display.Bitmap;

            [Bindable]
            public class MyVOBm
            {

            private var _asset:Bitmap;
            private var _title:String;

            public function MyVOBm(asset:Bitmap, title:String)
            {
            this.title=title;
            this.asset=asset;
            }

            public function set title(title:String):void{
            _title=title;
            }

            public function get title():String{
            return _title;
            }

            public function set asset(asset:Bitmap):void{
            _asset=asset;
            }

            public function get asset():Bitmap{
            return _asset;
            }

            }
            }

            • 3. Re: problem in tilelist with dataprovider.
              Level 7

              "mezrac" <webforumsuser@macromedia.com> wrote in message
              news:gidttm$dta$1@forums.macromedia.com...
              > tx Amy for your help here i give you the code that generate the image from
              > streaming video

              Again, I'm not seeing anything where it looks like you're trying to directly
              manipulate the TileList rather than working through the dataprovider. In
              cases like this, I usually just set lots of break points to step through and
              try to narrow down where the error is happening.

              HTH;

              Amy


              • 4. Re: problem in tilelist with dataprovider.
                mezrac Level 1
                hi amy
                the error is occurred when i call the function
                public function deleteSnapShot(ev:Event):void{

                imgData.list.removeItemAt(tileList.selectedIndex);

                }

                when i want to delete a record from the dataprovider to make the update for the tilelist i get the error message
                ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
                at flash.display::DisplayObjectContainer/removeChild()

                if i work with physical image i have no prob but when i manipulate the video to get the screenShot i got this error

                • 5. Re: problem in tilelist with dataprovider.
                  Level 7

                  "mezrac" <webforumsuser@macromedia.com> wrote in message
                  news:giecgn$2am$1@forums.macromedia.com...
                  > hi amy
                  > the error is occurred when i call the function
                  > public function deleteSnapShot(ev:Event):void{
                  >
                  > imgData.list.removeItemAt(tileList.selectedIndex);
                  >
                  > }

                  I see the problem. imgData is already an ArrayCollection, isn't it? So
                  don't try getting fancy and reaching inside it. I'm really amazed that with
                  all the great documentation out there that shows how to do this right you
                  managed to find this syntax :-)


                  • 6. Re: problem in tilelist with dataprovider.
                    mezrac Level 1
                    hi amy
                    in the code that i attach to the message it shows that the imgData is an ArrayCollection

                    [Bindable] public var imgData:ArrayCollection = new ArrayCollection();

                    and to update the content of the tilelist i have to manage change the content of the imgData:ArrayCollection
                    or if you have other solution it will be helpfull
                    i try bith of them and they give the some Error #2025
                    imgData.list.removeItemAt(tileList.selectedIndex);
                    imgData.removeItemAt(tileList.selectedIndex);
                    • 7. Re: problem in tilelist with dataprovider.
                      Level 7

                      "mezrac" <webforumsuser@macromedia.com> wrote in message
                      news:gigin0$rqr$1@forums.macromedia.com...
                      > hi amy
                      > in the code that i attach to the message it shows that the imgData is an
                      > ArrayCollection
                      >
                      > [Bindable] public var imgData:ArrayCollection = new ArrayCollection();
                      >
                      > and to update the content of the tilelist i have to manage change the
                      > content
                      > of the imgData:ArrayCollection
                      > or if you have other solution it will be helpfull
                      > i try bith of them and they give the some Error #2025
                      > imgData.list.removeItemAt(tileList.selectedIndex);
                      > imgData.removeItemAt(tileList.selectedIndex);
                      >

                      Can you upload the project somewhere so that I can just import it and play
                      with it?