Skip navigation
cablish
Currently Being Moderated

swfloader load avm1 swf is not work!

Jul 24, 2012 11:52 PM

my project is flex 4.5,

swfloader load a SWF file written in ActionScript 1.0 or 2.0,

it contains ''caurina.transitions.Tweener.addTween".

But to have a correct work!

1. run function test1 swf1 is  correct work!

2. run function test2 swf2 is  correct work!

code:

<fx:Script> 
            [Bindable]
            private var _byteData:ByteArray;
 
            public function init() {
                fileRef = new FileReference();
                fileRef.addEventListener(Event.SELECT, fileSelected, false, 0, true);
            }
 
            private function fileSelected(event:Event):void {
                fileRef.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
                fileRef.addEventListener(Event.COMPLETE, fileLoadCompleteHandler);
                fileRef.load();
            }
 
            private function selectHandler(event:Event):void {
                var filter:FileFilter = new FileFilter("*.swf", "*.swf");
                fileRef.browse([filter]);
                fileRef.addEventListener(Event.CANCEL, cancelHandler);
            }
 
            private function fileLoadCompleteHandler(event:Event):void {          
                var loader:Loader = new Loader();
                loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderCompleteFunction);
                loader.loadBytes( event.target.data);
            }
 
            private function loaderCompleteFunction(event:Event):void {
                var loader:Loader = event.target.loader;
                _byteData = loader.contentLoaderInfo.bytes;
            }
 
            // swf1 correct work
           private function test1():void {
                swf1.load();
                swf2.load();
            }
 
            // swf2 correct work
            private function test2():void {
                swf2.load();
                swf1.load();
            }
</fx:Script>
<mx:Panel title="SWFLoader Control Example"
              height="90%"
              width="90%"
              paddingTop="10"
              paddingBottom="10"
              paddingLeft="10"
              paddingRight="10">
          <mx:SWFLoader id="swf1" source="{_byteData}"
                      height="100%"
                      width="100%"/>
 
          <mx:SWFLoader id="swf2" source="{_byteData}"
                      height="100%"
                      width="100%"/>
 
         <mx:Button label="test1" click="test1()"/>
        <mx:Button label="test2" click="test2()"/>
    </mx:Panel>
</s:Application>
 
 
Replies
  • Currently Being Moderated
    Jul 25, 2012 12:12 PM   in reply to cablish

    What error did you get?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 10:04 PM   in reply to cablish

    You have two SWFLoaders sharing a single _byteData variable.  That looks suspicious to me.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 25, 2012 11:46 PM   in reply to cablish

    Maybe I don’t understand the issue.  Each SWF loads correctly by itself?  But when you try to load both only the first one works?

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points