サーバーインスタンスと複数のswfs間の変数。私はこれをどのように達成したかについての基本を分かち合うと思った。 ParentSWF
public var MyVar:String = "Hello";
public var sfs:SmartFox = new SmartFox(true);
private var ChildMC:MovieClip = new MovieClip();
private var myLoader:Loader;
private function LoadChildSWF(evt:Event):void //i used button click event to load swf
{
myLoader = new Loader(); // create a new instance of the Loader class
var url:URLRequest = new URLRequest("YOURSWF.swf"); // in this case both SWFs are in the same folder
try
{
myLoader.load(url);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,FFLoaded);
}
catch (error:Error)
{
trace("Unable to load requested document.");
}
}
function FFLoaded(e:Event):void
{
ChildMC= myLoader.content as MovieClip;
addChild(ChildMC);
ChildMC.init(this);
}
public function RemoveChildMC():void
{
removeChild(ChildMC);
ChildMC=null;
}
ChildSWF
package
{
import com.smartfoxserver.v2.SmartFox;
public class ChildDocumentClass extends MovieClip
{
private var refDocument:*;
private var ChildVar:String;
private var sfs:SmartFox;
public function ChildDocumentClass()
{
trace("Initilise ChildDocumentClass");
// Nothing to do
}
public function init(refDoc:*):void
{
// Get the references to the Document Class
refDocument = refDoc;
// Get the references to the Server Instance
sfs=refDocument.sfs;
//Pass Parent Variable to child variable
ChildVar=refDocument.MyVar;
}
//call to parent class function example to remove loaded swf
private function UnloadThisSWF():void
{
refDocument.RemoveChildMC();
}
}
}
あなたは通信のinit(refDoc:*)を介して、子クラスに親クラスを渡すことによって達成することができます見ることができるように機能。
SWFはどちらも単一のSWFですか? – Benny
いいえ、先生はどちらも違います – user990947