I can't solve this, i need help.
I am trying to load another b.swf into this a.swf
if i try to load a swf without class it works fine.
a.swf have no class, but b.swf have.
I encounter this error.
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MyGame()
What is the solution?
a.fla
Mygame.asCode:stop(); function startLoad() { var imageRequest:URLRequest = new URLRequest("b.swf"); var imageLoader:Loader = new Loader(); imageLoader.load(imageRequest); addChild(imageLoader); } function onCompleteHandler(loadEvent:Event) { addChild(loadEvent.currentTarget.content); } function onProgressHandler(mProgress:ProgressEvent) { var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal; trace(percent); } startLoad();
What is the solution?Code:package { import flash.display.MovieClip import flash.display.Sprite import flash.display.Bitmap import flash.display.BitmapData import flash.display.Graphics import flash.events.Event import flash.events.MouseEvent import flash.utils.ByteArray import flash.utils.setInterval import flash.utils.setTimeout import flash.geom.Point import flash.text.TextField import flash.display.BlendMode import flash.display.StageScaleMode import flash.display.StageAlign import flash.text.TextFormat import playerio.* import sample.ui.Prompt import sample.ui.Chat import sample.ui.Lobby public class MyGame extends MovieClip{ private var connection:Connection private var lobby:Lobby private var questions:Array=new Array(); private var answers:Array=new Array(); [Embed(source="c.xml", mimeType="application/octet-stream")] private static const MyData:Class; function MyGame(){ stop(); PlayerIO.connect( stage, //Referance to stage "quiz-sfhwfbj70ectvbcjazv2tw", //Game id (Get your own at playerio.com) "public", //Connection id, default is public "name", //Username "", //User auth. Can be left blank if authentication is disabled on connection handleConnect, //Function executed on successful connect handleError //Function executed if we recive an error ); stage.scaleMode = StageScaleMode.NO_SCALE stage.align = StageAlign.BOTTOM } private function handleConnect(client:Client):void{ trace("Sucessfully connected to player.io"); //Set developmentsever (Comment out to connect to your server online) client.multiplayer.developmentServer = "localhost:8184"; //Create pr join the room test client.multiplayer.createJoinRoom( "", //Room id. If set to null a random roomid is used "bounce", //The game type started on the server false, //Should the room be visible in the lobby? {}, //Room data. This data is returned to lobby list. Variabels can be modifed on the server {}, handleJoin, //Function executed on successful joining of the room handleError //Function executed if we got a join error ); //Create lobby lobby = new Lobby(client, "mygame", handleJoin, handleError) //Show lobby (parsing true hides the cancel button) lobby.show(true); } private function handleJoin(connection:Connection):void{ trace("Sucessfully connected to the multiplayer server"); var byteArray:ByteArray = new MyData() as ByteArray; var xml:XML = new XML(byteArray.readUTFBytes(byteArray.length)); var loop = 5; for (var i=0;i<loop;i++) { questions[i]=xml.ques[i].q1; //questions[i]=loop; answers[i]=[xml.ques[i].op1,xml.ques[i].op2,xml.ques[i].op3]; //answers[i]=loop; } gotoAndStop(2); stop(); /* trace(questions[1]); trace(answers[1]); trace(answers[1][0]); trace(answers[1][1]); trace(answers[1][2]); */ //Add chat to game var chat:Chat = new Chat(stage, connection); //Add listener for messages of the type "hello" connection.addMessageHandler("hello", function(m:Message){ trace("Recived a message with the type hello from the server"); }) //Add message listener for users joining the room connection.addMessageHandler("UserJoined", function(m:Message, userid:uint){ trace("Player with the userid", userid, "just joined the room"); }) //Add message listener for users leaving the room connection.addMessageHandler("UserLeft", function(m:Message, userid:uint){ trace("Player with the userid", userid, "just left the room"); }) //Listen to all messages using a private function connection.addMessageHandler("*", handleMessages) } private function handleMessages(m:Message){ trace("Recived the message", m) } private function handleDisconnect():void{ trace("Disconnected from server") } private function handleError(error:PlayerIOError):void{ trace("got",error) gotoAndStop(4); } } }




