Всем привет! Работаем над игрой и остался один баг который отделяет от релиза
TTT.swf основная, грузит в себя по очереди две swf: TSwf1 и TSwf2.
В TSwf1 и TSwf2 проигрываются по звук, звук подключен как swc, название звука совпадает в двух разных swc но звуки разные.
Ожидаемое поведение: поскольку мы грузим разные swf у которых разные swc, звуки должны быть разными не смотря на одинаковые названия. Реальное поведение: в TSwf2 играет звук с TSwf1.
Main.as
Код AS3:
package nord
{
import flash.utils.setTimeout;
import nord.connect.ITest;
import flash.display.DisplayObjectContainer;
import flash.display.Loader;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
/**
* ...
* @author DANIIL_NALETOV
*/
public class Main extends MovieClip
{
private var currentLdr:Loader;
private var currentSwf:DisplayObjectContainer;
public function Main()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void
{
loadSwf("TSwf1");
setTimeout(function()
{
stage.removeChild(currentSwf);
currentLdr.unloadAndStop();
currentLdr = null;
currentSwf = null;
setTimeout(function()
{
loadSwf("TSwf2");
}, 1000);
}, 5000);
}
public function loadSwf(name:String):void
{
trace("LoadRequest: " + name + ".swf");
currentLdr = new Loader();
var req:URLRequest = new URLRequest(name+".swf");
var ldrContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
currentLdr.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
currentLdr.load(req, ldrContext);
}
private function completeHandler(event:Event):void
{
currentLdr.contentLoaderInfo.removeEventListener(Event.COMPLETE, completeHandler);
currentSwf = currentLdr.content as DisplayObjectContainer;
stage.addChild(currentSwf);
}
}
}
ITest.as
Код AS3:
package nord.connect
{
/**
* ...
* @author DANIIL_NALETOV
*/
public interface ITest
{
function doIt(data:Object = null):void;
}
}
Исходник
https://shapikthequest.com/data/test.zip