2 Replies Latest reply: Apr 5, 2010 11:17 AM by The Jayster RSS

    Error #2025 with Fullscreen Mode Thumbnails

    The Jayster Community Member

      Hi Everyone!

       

      My first time on here, and I'm somewhat new to programming AS3, so please go easy. I have a portfolio page on my website (currently in-process) where I display flash samples. To avoid antiquated and uncontrollable pop-ups and js code etc that could be disabled, I went for a very clean/controlled approach by using flash's fullscreen capability. To achieve this, I am using indivdual swfs as thumbnails. Each thumbnail swf listens for a click. Once clicked it fires off its fullscreen mode, loads an external swf file, and positions my assets (the swf file and a custom exit button) perfectly on the screen according to your specific resolution settings. Everything unloads and goes back to normal via a fullscreen event listener, so it doesn't matter how you exit fullscreen mode (via button or escape or whatever). Everything works great in all browsers I've tested, except...

       

      Problem:

       

      In browsers other than Explorer I get the following error when returning to normal mode. Everything works fine, but the error window pops up. Not too impressive on your sample page obviously .

       

      ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
          at flash.display::DisplayObjectContainer/removeChild()
          at thumb_right_moves_fla::MainTimeline/fullScreenRedraw()
          at flash.display::Stage/set displayState()
          at thumb_right_moves_fla::MainTimeline/exitFullScreen()

       

       

      Setup:

       

      On the main stage I have a thumbnail movieclip that displays a graphic and provides the rollover effects etc. I also have an Exit movie clip that serves as a button during fullscreen mode. All code is in a single frame in the Actions layer of the main timeline. There is only 1 frame in the FLA.

       

       

      My Complete Code:

       

      import flash.display.Stage;
      import flash.display.StageAlign;
      import flash.display.StageScaleMode;
      import flash.events.Event;
      import flash.events.FullScreenEvent;

       


      var screenWidth:Number;
      var screenHeight:Number;
      var sampleWidth:Number = 800; // enter actual external content width
      var sampleHeight:Number = 500; // enter actual external content height
      var stageWidthAdjustment = stage.stageWidth/2;
      var stageHeightAdjustment = stage.stageHeight/2;
      var contentURL:String = "swf/sample_right_moves.swf"; // enter url to external content
      var screenMargin:Number = 10; // set the prefered distance of exit button from screen edge
      var contentRequest:URLRequest = new URLRequest(contentURL);
      var contentLoader:Loader = new Loader;

       

       

      // Initial stage setup

       

      exit_mc.visible = false;
      thumb_mc.buttonMode = true;
      thumb_mc.addEventListener(MouseEvent.CLICK, enterFullScreen);
      thumb_mc.addEventListener(MouseEvent.ROLL_OVER, over);
      thumb_mc.addEventListener(MouseEvent.ROLL_OUT, out);
      stage.addEventListener(FullScreenEvent.FULL_SCREEN, fullScreenRedraw);
      stage.addEventListener(Event.RESIZE, resizeDisplay);
      stage.scaleMode = StageScaleMode.NO_SCALE;

       


      // Event handlers

       

      function enterFullScreen(event:MouseEvent):void
      {
          stage.displayState = StageDisplayState.FULL_SCREEN;   
      }

       

      function exitFullScreen(event:MouseEvent):void
      {
          stage.displayState = StageDisplayState.NORMAL;
      }

       

      function resizeDisplay(event:Event):void
      {
          screenWidth = stage.stageWidth;
          screenHeight = stage.stageHeight;
      }

       

      function over(event:MouseEvent):void
      {
          event.target.gotoAndPlay("Over");
      }

       

      function out(event:MouseEvent):void
      {
          event.target.gotoAndPlay("Out");
      }


      // detect fullscreen mode status and perform operations/adjustments

      function fullScreenRedraw(event:FullScreenEvent):void
      {
          if (event.fullScreen) // full screen setup
          {
             // remove all the thumbnail listeners
              thumb_mc.visible = false;
              thumb_mc.removeEventListener(MouseEvent.CLICK, enterFullScreen);
              thumb_mc.removeEventListener(MouseEvent.ROLL_OVER, over);
              thumb_mc.removeEventListener(MouseEvent.ROLL_OUT, out);
             
              // add all the exit button listeners
              exit_mc.visible = true;
              exit_mc.buttonMode = true;
              exit_mc.addEventListener(MouseEvent.CLICK, exitFullScreen);
              exit_mc.addEventListener(MouseEvent.ROLL_OVER, over);
              exit_mc.addEventListener(MouseEvent.ROLL_OUT, out);   
              exit_mc.x = stageWidthAdjustment + (screenWidth/2) - exit_mc.width - screenMargin;
              exit_mc.y = stageHeightAdjustment - (screenHeight/2) + screenMargin;
             
              // load external sample content into container and position screen-centered
              contentLoader.load(contentRequest);
              addChild(contentLoader);
              contentLoader.x = stageWidthAdjustment - (sampleWidth/2);
              contentLoader.y = stageHeightAdjustment - (sampleHeight/2);
          }
          else // normal screen setup
          {
              SoundMixer.stopAll(); // stops the annoying audio that keeps running even after removing the child
              removeChild(contentLoader); // Problem area??      
              contentLoader.unload(); // not sure if even need this
             
              // add all the thumbnail listeners
              thumb_mc.visible = true;
              thumb_mc.gotoAndPlay("Out");
              thumb_mc.buttonMode = true;
              thumb_mc.addEventListener(MouseEvent.CLICK, enterFullScreen);
              thumb_mc.addEventListener(MouseEvent.ROLL_OVER, over);
              thumb_mc.addEventListener(MouseEvent.ROLL_OUT, out);       
             
              // remove all the exit button listeners
              exit_mc.visible = false;
              exit_mc.removeEventListener(MouseEvent.CLICK, exitFullScreen);
              exit_mc.removeEventListener(MouseEvent.ROLL_OVER, over);
              exit_mc.removeEventListener(MouseEvent.ROLL_OUT, out);       
          }
      }

        • 1. Re: Error #2025 with Fullscreen Mode Thumbnails
          kglad CommunityMVP

          if you're correct, use:

           

          contentLoader.parent.removeChild(contentLoader); //  Problem area?? 

          • 2. Re: Error #2025 with Fullscreen Mode Thumbnails
            The Jayster Community Member

            Thank for such a quick response! This indeed remedied the first of the four listed locations in the error message. The message now displays as follows:

             

            ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
               at flash.display::DisplayObjectContainer/removeChild() // YOU FIXED THIS ONE! Thank you!
                at thumb_right_moves_fla::MainTimeline/fullScreenRedraw()
                at flash.display::Stage/set displayState()
                at thumb_right_moves_fla::MainTimeline/exitFullScreen()

             

            Trust me when I say I am not being lazy. I spent several hours trying to fix these basic little things already, but I just don't have the coding knowledge when it comes to debugging odd little things like this. Ends up being trial and error hell for me, with no results. Do you (or anyone else) have any idea of the three problem locations remaining (my fullScreenRedraw handler, something about the displayState being set, and my exitFullScreen handler)? I must be calling stuff from the wrong timelines or something, though I don't know how. Must be the loader child mixing me up. Odd that it all works regardless.

             

            If the code will run flawlessly, it could be helpful to others who like the idea of flash thumbs that display constrained and centered portfolio content full screen. I havn't seen that being done yet (though I'm sure it out there). Everyone is using those complicated javascript box screen things, and not using all the screen real-estate. Seems odd when you can avoid browser and chrome constraints all together.

             

            Thanks again for you help kglad!