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>
Influence of the rest of you. I'm sorry!
issue:
swf file(sound_position_as2_flash8.zip) loaded is only one can run! i want both correctly work!
I searched and found this:
SWF files written in ActionScript 1.0 or 2.0 cannot load SWF files written in ActionScript 3.0.
modify 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 {
_byteData = event.target.data; }
</fx:Script>
<mx:Panel title="SWFLoader Control Example"
height="90%"
width="90%"
paddingTop="10"
paddingBottom="10"
paddingLeft="10"
paddingRight="10">
<mx:Button click="selectHandler(event)" label="select swf file"/>
<mx:SWFLoader id="swf1" source="{_byteData}"
height="100%"
width="100%"/>
<mx:SWFLoader id="swf2" source="{_byteData}"
height="100%"
width="100%"/>
</mx:Panel>
North America
Europe, Middle East and Africa
Asia Pacific