Skip navigation
qdjch
Currently Being Moderated

TypeError: Error #1009:     Help me?

Apr 12, 2011 10:23 PM

When I new instance of classm, error under

TypeError: Error #1009: TypeError: Error # 1009: can not access a null object reference property or method.
at course/course1()

 

//instance class

var myCourse:course = new course();
myCourse.course1("Chapter01-1/Session01/config/Config.xml");

 

//class

package
{
import fl.transitions.*;
import fl.transitions.easing.*;
import fl.video.*;
import flash.events.*;
import flash.display.*;
import flash.net.*;
import flash.text.*;
public class course extends MovieClip
{
  private var xmlPath:String ;
  public var loader:URLLoader;
  public var loadppt:Loader;
  public var urlppt:URLRequest;
  public var xmlData:XML;
  public var tween:Tween;
  public var display:MovieClip;
  public var playpausebtn:MovieClip;
  public var mutebtn:MovieClip;
  public var volbar:MovieClip;
  public var seekbar:MovieClip;
  public var ttime:TextField;
public function course1(val:String):void
  {
   xmlPath=val ;
   loader.addEventListener (Event.COMPLETE, onDataHandler);
   loader.load (new URLRequest(xmlPath));

   display.playPauseButton = playpausebtn;
   display.muteButton = mutebtn;
   display.volumeBar = volbar;
   display.seekBar = seekbar;
   display.skin = "MinimaUnderPlayBackSeekCounterVolMuteFull.swf";
   display.autoPlay = false;

   display.addEventListener (VideoEvent.READY, videoReadyHandler);
   display.addEventListener (VideoEvent.SCRUB_FINISH,videoUpdate);
   display.addEventListener (VideoEvent.PLAYHEAD_UPDATE ,videotime);
   display.addEventListener (MetadataEvent.CUE_POINT, cuePointHandler);

  }
  private function onDataHandler ( evt:Event ):void
  {
   xmlData = new XML(loader.data);
   display.source = String(xmlData.video);
...............

..............

.........

 
Replies
  • Currently Being Moderated
    Apr 13, 2011 2:01 AM   in reply to qdjch

    Hi

     

    This can be a nightmare -  Error #1009 basically means your trying to use something before it exists.

     

     

    Your constructor - public function course1(val:String):void expects a value sent to it.

     

    Your instantiation doesn't send one - myCourse:course = new course();

     

    Secondly - I don't see a public method to set myCourse.course1("Chapter01-1/Session01/config/Config.xml");

     

    Either send - myCourse:course = new course("Chapter01-1/Session01/config/Config.xml")

     

    or

     

    Remove the value from the call - public function course1():void

     

    and make a public setter method

     

    public function set course(value:String):void

    {

      _course = value;

    }

     

    Hope it helps

     
    |
    Mark as:
  • Currently Being Moderated
    Apr 13, 2011 4:40 AM   in reply to qdjch

    Hi

     

    OK - now your getting confused between a Class Constructor and a Class Public Method.

     

    A Class MUST be defined with the same name in the Public Class definition and the Constructor: for instance

     

     

    package

    {

    imports.............

     

    public class course extends MovieClip

    {

    private var _newCourse:String;

    .................

    {

    public function course():void

    {

    // initiate vars and listeners for example here

    }

     

    // This allows you to externally set the course path.

    public function set newCourse(value:string):void

    {

    _newCourse = value;

    _xmlPath = _newCourse;

    ...........

    }

     

    In your document class or on a Frame enter -

     

    var myCourse = new course()

    myCourse.newCourse(pathtoxml);

    addChild(myCourse);

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points