3 Replies Latest reply: Jul 23, 2010 2:11 PM by Ned Murphy RSS

    AS2/AS3 HELP

    PrintingByDBE Community Member

      Im trying to place a widget on my site using a loader class...

       

      but it seems the widget is AS1/AS2 based...

       

       

      is there a simple code or something i can do to make it work in as3

       

       

      here is the error i am getting...

       

       

      The shows button was clicked!


      ArgumentError: Error #2180:  It is illegal to move AVM1 content (AS1 or AS2) to a different part of  the displayList when it has been loaded into AVM2 (AS3) content.
          at flash.display::DisplayObjectContainer/addChild()
          at index_fla::Shows_23/onCompleteHandler()

        • 1. Re: AS2/AS3 HELP
          Ned Murphy CommunityMVP

          I am offering this based solely on trying to interpret the error message... if you use addChild for the Loader after the loading is complete, try doing it before loading starts instead.

          • 2. Re: AS2/AS3 HELP
            PrintingByDBE Community Member

            Hey ned!

             

            thanks for the fast reply!

             

            here is the code im using

             

            maybe you can clear that up for me alittle more!

             

            import flash.net.URLRequest; import flash.display.Loader; import flash.events.Event; import flash.events.ProgressEvent; function startLoad() { var mLoader:Loader = new Loader(); var mRequest:URLRequest = new URLRequest('http://cache.reverbnation.com/widgets/swf/42/pro_widget.swf'); mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler); mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler); mLoader.load(mRequest); } function onCompleteHandler(loadEvent:Event) {         addChild(loadEvent.currentTarget.content); } function onProgressHandler(mProgress:ProgressEvent) { var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal; trace(percent); } startLoad();

            • 3. Re: AS2/AS3 HELP
              Ned Murphy CommunityMVP

              I am shooting in the dark, but it can't hurt for you to try...  I believe it is objecting to you trying to move the AS1/AS2 file to some other realm of the display list in the following function...

               

              function onCompleteHandler(loadEvent:Event) {

                       addChild(loadEvent.currentTarget.content);

              }

               

              So change that function to...

               

              function onCompleteHandler(loadEvent:Event) {       

                  addChild(loadEvent.currentTarget);

              }

               

              and see if it helps.

               

              If that fails, then try commenting out that line of code in that function and just add the mLoader to the display list right after yoiu declare it...

               

              var mLoader:Loader = new Loader();

              addChild(mLoader);