Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-17-2012, 04:22 AM   #1
thathany
Registered User
 
Join Date: May 2012
Posts: 2
Default i cant call other swf file

Hello guys, i'm a beginner
I've been away for a while and I just started to work on my new ordinary game (in flash). I want to import other swf file but it doesnt works and display an error :
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at stage1_fla::MainTimeline/mulai()[stage1_fla.MainTimeline::frame1:52]
	at stage1_fla::MainTimeline/writeText()[stage1_fla.MainTimeline::frame1:40]
And here is my code :

Code:
var myText:String; 
var counter:int = 0; 
var MC:Sprite;
var ldr:Loader;

MC:new Sprite;
ldr: new Loader;
fscommand("fullscreen", "true");

var format : TextFormat = new TextFormat();
format.size = 20;
format.font = "Lipsum";
//format.bold = true;
format.color = 0x000000; 

var textField : TextField = new TextField();
textField.width = 800;
textField.height = 550;
textField.selectable = false;
textField.wordWrap = true;
textField.defaultTextFormat = format;
textField.x = 300; textField.y = 160;
addChild(textField);
				


var textLoader:URLLoader = new URLLoader(new URLRequest("story1.txt"));
textLoader.addEventListener(Event.COMPLETE, function(e:Event){initText(e.target.data);});

function initText(string:String):void{
	myText = string; 
	addEventListener(Event.ENTER_FRAME, writeText); 
}

function writeText(e:Event):void{
	if (counter <= myText.length){
   	     textField.text = myText.substr(0,counter); 
   	     counter++; 
		 if(counter == myText.length){
			mulai();
		}
	}
	
	else{
		removeEventListener(Event.ENTER_FRAME,writeText); 
	}

}

function mulai():void{
	
   ldr.load(new URLRequest("Soal_1.swf"));
   ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
}
function loadComplete(e:Event):void 
{
	ldr.contentLoaderInfo.removeEventListener(Event.COMPLETE, loadComplete);//biasakan untuk event yang sudah tidak dipake lagi di remove
	MC.addChild(ldr.content);
	addChild(MC);
}
function destroy():void
{
	MC.removeChild(ldr.content);
	ldr.unloadAndStop();
}
I just used the debug mode in flash and it said that it contains error in ldr.load(new URLRequest("Soal_1.swf"));

Can somebody help me out ?
thathany is offline   Reply With Quote
Old 05-17-2012, 10:26 AM   #2
Poony
Flash Developer
 
Poony's Avatar
 
Join Date: Aug 2011
Location: Sweden
Posts: 366
Default

Here is your problem
ActionScript Code:
ldr: new Loader;
Should be
ActionScript Code:
ldr = new Loader();
Poony is offline   Reply With Quote
Old 05-17-2012, 03:05 PM   #3
thathany
Registered User
 
Join Date: May 2012
Posts: 2
Default

thanks for reply my thread Poony
and I've tried your suggestion .

And it works thanks a lot

Last edited by thathany; 05-17-2012 at 03:07 PM.
thathany is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:24 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.