• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

TypeError: Error #1009: Help me?

New Here ,
Apr 12, 2011 Apr 12, 2011

Copy link to clipboard

Copied

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);
...............

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

.........

TOPICS
ActionScript

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

Thank

but now I don't know how to do...

Now ,I modified code

would you tell me detailed

//new instance of class

var myCourse:course = new course();
myCourse.newcourse("Chapter01-1/Session01/config/Config.xml");/* post a value"Chapter01-1/Session01/config/Config.xml"  to  parameter xmlPath through function newcourse*/

//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
{
  public var xmlPath;
  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 newcourse(val:String):void

  {

   xmlPath=val;
   loader.addEventListener (Event.COMPLETE, onDataHandler);
   loader.load (new URLRequest(xmlPath));

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

  }

...........

...........

...........
 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

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);

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

Yes,thanks

I try to do with your way,also error

1046: can not find the type, or it is not a compile-time constant: string

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;

  private var loader:URLLoader;
  private var loadppt:Loader;
  private var urlppt:URLRequest;
  private var xmlData:XML;
  private var tween:Tween;
  private var display:MovieClip;
  private var playpausebtn:MovieClip;
  private var mutebtn:MovieClip;
  private var volbar:MovieClip;
  private var seekbar:MovieClip;
  private var ttime:TextField;
  private var _newCourse:String;
  public function course():void

{
   display.playPauseButton = playpausebtn;
   display.muteButton = mutebtn;
   display.volumeBar = volbar;
   display.seekBar = seekbar;
   display.autoPlay = false;
   loader.addEventListener (Event.COMPLETE, onDataHandler);
   display.addEventListener (VideoEvent.READY, videoReadyHandler);
   display.addEventListener (VideoEvent.SCRUB_FINISH,videoUpdate);
   display.addEventListener (VideoEvent.PLAYHEAD_UPDATE ,videotime);
   display.addEventListener (MetadataEvent.CUE_POINT, cuePointHandler);

}

 
public function set  newCourse(value:string):void     //here error:1046: can not find the type, or it is not a compile-time constant: string

  {

   _newCourse = value;
   xmlPath = _newCourse;
   loader.load (new URLRequest(xmlPath));

  }
  private function onDataHandler ( evt:Event ):void
  {
   xmlData = new XML(loader.data);
   display.source = String(xmlData.video);
   trace (display.source);
   var i:uint = 0;
   for each (var cuepoint in xmlData.cuepoints.cuepoint)
   {
    display.addASCuePoint (Number(cuepoint.time), String(i));

    if( btn ){
     btn.index = i;
........................

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

........

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 13, 2011 Apr 13, 2011

Copy link to clipboard

Copied

sorry

string-String

also error

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

LATEST

OK

I had soluted this question

thank everyone

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines