Skip to main content
Participant
April 27, 2020
Question

Separate AS3

  • April 27, 2020
  • 1 reply
  • 336 views

Hi ... i'm trying to move AS3 to separate file

but i always got error

Line 13 1120: Access of undefined property loader.

Line 13 1120: Access of undefined property handle_loadComplete.

Line 14 1120: Access of undefined property loader.

 

this is my code

 

package 
{
	import flash.events.Event;
	import flash.net.URLLoader;
	import flash.net.URLRequest;
	import flash.text.TextField;// ini untuk dynamic text
	import se.svt.caspar.template.CasparTemplate;

	public class ParsingXML extends CasparTemplate
	{
		private var loader:URLLoader = new URLLoader();

		loader.addEventListener(Event.COMPLETE, handle_loadComplete);
		loader.load(new URLRequest("pembuktian.txt"));

		private function handle_loadComplete(e:Event):void
		{

			myTextField.text = e.target.data;

		}
	}
}

 

 

before i move to separate file i had test it inside .fla file and it work

 

var loader:URLLoader = new URLLoader();

loader.addEventListener(Event.COMPLETE, handle_loadComplete);
loader.load(new URLRequest("pembuktian.txt"));

function handle_loadComplete(e:Event):void
{

	myTextField.text = e.target.data;

}

 

is there anyone can point me into right direction

 

comment and help would be appreciate

 

Best Regard

 

Gilar Kadarsah | Indonesia

 

 

Note: i also upload the AS3 File and FLA File incase need to open it

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    April 28, 2020

    Hi.

     

    Your initialization code must be inside of the constructor method of the ParsingXML class.

     

    ParsingXML.as

    package
    {
    	import flash.events.Event;
    	import flash.net.URLLoader;
    	import flash.net.URLRequest;
    	import flash.text.TextField;
    	import se.svt.caspar.template.CasparTemplate;
    
    	public class ParsingXML extends CasparTemplate
    	{
    		private var loader:URLLoader = new URLLoader();
    
    		public function ParsingXML()
    		{
    			loader.addEventListener(Event.COMPLETE, handle_loadComplete);
    			loader.load(new URLRequest("pembuktian.txt"));
    		}
    
    		private function handle_loadComplete(e:Event):void
    		{
    			myTextField.text = e.target.data;
    		}
    	}
    }

     

    CasparTemplate.as

    package se.svt.caspar.template
    {
    	import flash.display.MovieClip;
    
    	public class CasparTemplate extends MovieClip
    	{
    		public function CasparTemplate()
    		{
    			
    		}
    	}
    }

     

    I hope this helps.

     

    Regards,

    JC