Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




How To Correct This; TypeError: Error #1009: Cannot Access A Property Or Method Of..



hi again everybody.


after I saw the idea of class'es, I've been very exited about the idea.
but as this area is very new to me, I have big trouble completing my classes.

here's an example.
I'm working on a IndexPreloader - a preloader, that loads the .swf itself.
and so far I've managed to make the graphics to be used as a bar.
but when I try adding a TextField, I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.


here's what I've written in my .fla so far:

Code:
stop();

//set up the IndexPreloader class
import IndexPreloader;
var indexPreloader:IndexPreloader = new IndexPreloader();
addChild(indexPreloader);
// now the stage property of makeStars is no longer null

loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressEvent);
loaderInfo.addEventListener(Event.COMPLETE, doneLoading);

//functions
function progressEvent(e:ProgressEvent):void {
//bytesTotal, bytesLoaded, farve
indexPreloader.init(e.bytesTotal, e.bytesLoaded, 0x000000);
indexPreloader.doTheGraphics();
}

function doneLoading(e:Event):void {
trace("done loading");
gotoAndStop(2);
}

and here's the code in my .as-file:

Code:
package {

import flash.display.Sprite;
import flash.text.TextField;

public class IndexPreloader extends Sprite {
private var bytestotal:Number;
private var bytesloaded:Number;
private var color:uint;
private var backgroundGraphic:Sprite = new Sprite();
private var preloadGraphic:Sprite = new Sprite();
private var sclbar:Number;
private var isInitiated:Boolean = false;
private var textfield:TextField;

public function IndexPreloader() {

}
public function init(bytesTotally:Number, bytesToLoad:Number, colorToUse:uint):void {
bytestotal = bytesTotally;
bytesloaded = bytesToLoad;
color = colorToUse;
trace("completion = "+bytesloaded+" / "+bytestotal);
sclbar = Math.round(bytesloaded/bytestotal * 100) * 2; //goes from 0 to 200, which equals the preloaders width
if (bytesloaded >= bytestotal) {
trace("bytesloaded >= bytestotal");
}
}
public function doTheGraphics():void {
if (isInitiated == false) {
isInitiated = true;
backgroundGraphic.graphics.lineStyle(0, 0, 0);
backgroundGraphic.graphics.beginFill(color);
backgroundGraphic.graphics.lineTo(200, 0);
backgroundGraphic.graphics.lineTo(200, 20);
backgroundGraphic.graphics.lineTo(0, 20);
backgroundGraphic.graphics.lineTo(0, 0);
backgroundGraphic.graphics.endFill();
backgroundGraphic.alpha = 0.1;
backgroundGraphic.x = ((this.stage.stageWidth/2) - (backgroundGraphic.width/2));
backgroundGraphic.y = ((this.stage.stageHeight/2) - (backgroundGraphic.height/2));
addChild(backgroundGraphic);
//
preloadGraphic.graphics.lineStyle(0, 0, 0);
preloadGraphic.graphics.beginFill(color);
preloadGraphic.graphics.lineTo(200, 0);
preloadGraphic.graphics.lineTo(200, 20);
preloadGraphic.graphics.lineTo(0, 20);
preloadGraphic.graphics.lineTo(0, 0);
preloadGraphic.graphics.endFill();
preloadGraphic.alpha = 1;
preloadGraphic.x = backgroundGraphic.x;
preloadGraphic.y = backgroundGraphic.y;
addChild(preloadGraphic);
//
/*textfield.text = sclbar+" % loaded";
textfield.border = true;
textfield.width = 400;
textfield.height = 200;
textfield.selectable = false;
addChild(textfield);
trace(textfield.x);*/
}
preloadGraphic.width = sclbar; //here we increment width with sclbar number form init function
}
}
}

as long as the part about the textfield in the end of the doTheGraphics-function is not compiled, nothing seems to be a problem.
but if I complie it, I get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.


but to me it makes no sense (obviously )
because the textfield is defined at the same time of the 2 graphics, and the textfield is added to the stage in the same way the 2 graphics are...
so in my head, it ought to work perfectly!


can anyone tell me, what I'm doing wrong?

thanks
felisan



Ultrashock Forums > Flash > ActionScript
Posted on: 2008-01-17


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

[CS3] TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Ref
I'm getting the error
TypeError: Error #1009: Cannot access a property or method of a null object reference

Everything still works ok until I add the stop Flv code then somethings work some don't.

Example of code for one button:


Code:
mc_altogether.mc_animation.addEventListener(MouseEvent.CLICK,animationin);

function animationin(e:Event):void {

mc_altogether.gotoAndStop("animation1");

}
mc_altogether.mc_animation.buttonMode = true;

Adding this: in the function messes it all up:
video1.stop();


This is the website:
http://nintendo.byethost7.com/portfolio/deskv3.html

It's the animation, interative and Illustration buttons that mess up.

[CS3] TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Ref
Yes, I realize this probably a common error, I am a student and have no clue on how to solve this. i am doing (what I think to be) simple navigation buttons and this error keeps popping up everytime I try to ctrl+enter the movie...

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at applepic2_fla::MainTimeline/frame1()

Here is my actionscript 3.0

stop();
applebtn.addEventListener(MouseEvent.CLICK, onAppleClick, false, 0, true);
mcbtn.addEventListener(MouseEvent.CLICK, onMCClick, false, 0, true);
rugbybtn.addEventListener(MouseEvent.CLICK, onRugbyClick, false, 0, true);
aopibtn.addEventListener(MouseEvent.CLICK, onAopiClick, false, 0, true);
psebtn.addEventListener(MouseEvent.CLICK, onPSEClick, false, 0, true);
rugbymain.addEventListener(MouseEvent.CLICK, onRugbymainClick, false, 0, true);
applemain.addEventListener(MouseEvent.CLICK, onApplemainClick, false, 0, true);
aopimain.addEventListener(MouseEvent.CLICK, onAopimainClick, false, 0, true);
psemain.addEventListener(MouseEvent.CLICK, onPSEmainClick, false, 0, true);
mcbtn.addEventListener(MouseEvent.CLICK, onMCmainClick, false, 0, true);

function onAppleClick(evt:MouseEvent):void {
gotoAndPlay(2);
}
function onRugbyClick(evt:MouseEvent):void {
gotoAndPlay(51);
}
function onAopiClick(evt:MouseEvent):void {
gotoAndPlay(98);
}
function onPSEClick(evt:MouseEvent):void {
gotoAndPlay(143);
}
function onMCClick(evt:MouseEvent):void {
gotoAndPlay(190);
}
function onRugbymainClick(evt:MouseEvent):void {
gotoAndPlay(73);
}
function onApplemainClick(evt:MouseEvent):void {
gotoAndPlay(26);
}
function onAopimainClick(evt:MouseEvent):void {
gotoAndPlay(198);
}
function onPSEmainClick(evt:MouseEvent):void {
gotoAndPlay(173);
}
function onMCmainClick(evt:MouseEvent):void {
gotoAndPlay(213);
}


Any help you could give me would be very much appreciated (oh an put it in as simpliest form you can, I'm a newbie at this actionscript)

Curious: TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Objec
Curious: TypeError: Error #1009: Cannot access a property or method of a null object
Hey guys

i get the following error in AS3::

----
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main/main::init3d()
at PaperBase/init()
at main$iinit()

-----
I assume that the object which is null is related to all 3 but am unsure if this is a common error or just something stupid i am missing! If its any worth the script does use eventlisteners and i am suspicious this may be involved.

Can anyone point me in the right direction?
Cheers
Ash

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
i created a preloader following the gotoandlearn.com tutorial, exactly as it is:


Code:
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("particles.swf"));

function loop(e:ProgressEvent):void {
var perc:Number = e.bytesLoaded / e.bytesTotal;
percent.text = Math.ceil(perc*100).toString();
}

function done(e:Event):void {
removeChildAt(0);
percent = null;
addChild(l);
}
and then i tried compiling it, and i get this error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at particles_fla::MainTimeline/particles_fla::frame1()

particles file runs fine as a standalone, but not with the preloader
anyone knows what could it be?

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
Hey,
Can anyone help me with this problem? I'm trying to make a little project for my studies, and i'm trying to create a little flash movie but I keep encountering a "TypeError: Error #1009".

So far i've come across with no problems until the point I added a new Listner onto the actions, which is for a button. Once I run the movie I came across with this problem:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at gallery_fla::MainTimeline/gallery_fla::frame1()


Code:
var currentColor:Number;

goCP.addEventListener(MouseEvent.CLICK,goCpanel);
btNext.addEventListener(MouseEvent.CLICK,goNextFrame);
btPrev.addEventListener(MouseEvent.CLICK, goBack);
changeColor.addEventListener(MouseEvent.CLICK, colorChange);
go.addEventListener(MouseEvent.CLICK,go1);

function go1(event:MouseEvent):void {
gotoAndStop(1);
}


function goCpanel(event:MouseEvent):void {
gotoAndStop('cpanel');
}

function goNextFrame(event:MouseEvent):void {
nextFrame();
}

function goBack(event:MouseEvent):void {
prevFrame();
}

function colorChange(event:MouseEvent):void {
var colorTransform:ColorTransform = gal.transform.colorTransform;
currentColor = cpColor.selectedColor
colorTransform.color = currentColor;
gal.transform.colorTransform = colorTransform;
gotoAndStop(1);
}

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
I'm building an AS3 media player and I am having trouble loading an external movie. I keep getting the error:

TypeError: Error #1009: Cannot access a property or method of a null object reference at CookBookPlayer$iinit()

Here is my script for the main Loader class:


Code:
package {


import flash.display.*;
import flash.net.URLRequest;
import flash.events.Event;
import com.monkeyclaus.mediaplayer.PanControl;
import com.monkeyclaus.mediaplayer.PlayButton;
import com.monkeyclaus.mediaplayer.SpectrumGraph;
import com.monkeyclaus.mediaplayer.VolumeControl;
import flash.text.TextField;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.text.TextFormat;
import flash.utils.Timer;



public class LoadPlayer extends Sprite{



private var _loader:Loader;

public function LoadPlayer(){

//Create the loader and add it to the display list
_loader = new Loader();
addChild( _loader );

//add the event handler to interact with the movie
_loader.contentLoaderInfo.addEventListener( Event.INIT, handleInit );

//Load an external movie
_loader.load (new URLRequest( "MediaPlayer.swf" ));
}

// Event Handler called when the external loaded movie is ready

private function handleInit (event:Event):void{

var movie:* = _loader.content;

trace("loaded");
}

}


}

and here is the code for the media player application I am trying to load:




Code:
package {

import com.monkeyclaus.mediaplayer.PanControl;
import com.monkeyclaus.mediaplayer.PlayButton;
import com.monkeyclaus.mediaplayer.SpectrumGraph;
import com.monkeyclaus.mediaplayer.VolumeControl;
import flash.display.Sprite;
import flash.display.Stage;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.text.TextField;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundTransform;
import flash.net.URLRequest;
import flash.text.TextFormat;
import flash.utils.Timer;

public class CookBookPlayer extends Sprite{

private var _channel:SoundChannel;
private var _displayText:TextField;
private var _sound:Sound;
private var _panControl:PanControl;
private var _playing:Boolean = false;
private var _playPauseButton:Sprite;
private var _position:int = 0;
private var _spectrumGraph:SpectrumGraph;
private var _volumeControl:VolumeControl;

public function CookBookPlayer() {
trace("player started");
//Stage alignment
stage.scaleMode = flash.display.StageScaleMode.NO_SCALE;
stage.align = flash.display.StageAlign.TOP_LEFT;

//Enter a frame listener
var timer:Timer = new Timer(20);
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
_playing = true;

//Display a text field
_displayText = new TextField();
addChild(_displayText);
_displayText.x = 10;
_displayText.y = 17;
_displayText.width = 256;
_displayText.height = 14;

//Create a sound object
_sound = new Sound(new URLRequest("ruxpin_turtles_sea_forward.mp3"));
_sound.addEventListener(Event.ID3, onID3);
_channel = _sound.play();

//Create a bitmap for spectrum display
_spectrumGraph = new SpectrumGraph();
_spectrumGraph.x = 10;
_spectrumGraph.y = 33;
addChild(_spectrumGraph);

//Create the play and pause buttons
_playPauseButton = new PlayButton();
_playPauseButton.x = 10;
_playPauseButton.y = 68;
addChild(_playPauseButton);
_playPauseButton.addEventListener(MouseEvent.MOUSE_UP, onPlayPause);


//Create volume and pan controls

_volumeControl = new VolumeControl();
_volumeControl.x = 45;
_volumeControl.y = 68;
addChild(_volumeControl);
_volumeControl.addEventListener(Event.CHANGE, onTransform);

_panControl = new PanControl();
_panControl.x = 164;
_panControl.y = 68;
addChild(_panControl);
_panControl.addEventListener(Event.CHANGE, onTransform);

}

public function onTransform(event:Event):void{
//Get volume and pan data from controls
// and apply to a new SoundTransform Object
_channel.soundTransform = new SoundTransform(_volumeControl.volume, _panControl.pan);
}

public function onPlayPause(event:MouseEvent):void{
//If playing, stop and record that position
if(_playing) {
_position = _channel.position;
_channel.stop();
}
else{
//Else, restart at the saved position
_channel = _sound.play(_position);
}
_playing = !_playing;
}

public function onID3(event:Event):void{
//Display selected id3 tags in the text field
_displayText.text = _sound.id3.artist + " : " + _sound.id3.songName;
_displayText.setTextFormat(new TextFormat("Verdana", 8, 0xffffff));
}

public function onTimer(event:TimerEvent):void {
var barWidth:int = 256;
var barHeight:int = 5;

var loaded:int = _sound.bytesLoaded;
var total:int = _sound.bytesTotal;

var length:int = _sound.length;
var position:int = _channel.position;


//Draw a background bar
graphics.clear();
graphics.beginFill(0xffffff);
graphics.drawRect(10, 10, barWidth, barHeight);
graphics.endFill();

if(total > 0) {

//The percent of the sound that has loaded
var percentBuffered:Number = loaded / total;

//Draw a bar that represents the percent of
// the sound that has loaded
graphics.beginFill(0xcccccc);
graphics.drawRect(10, 10, barWidth * percentBuffered, barHeight);
graphics.endFill();

//Correct the sound length calculation
length /= percentBuffered;

//The percent of the sound that has played
var percentPlayed:Number = position / length;

//Draw a bar that represents the percent of
// the sound that has played

graphics.beginFill(0xffffff);
graphics.drawRect(10, 10, barWidth * percentPlayed, barHeight);
graphics.endFill();

_spectrumGraph.update();
}


}
}
}

Any ideas? I would greatly appreciate it.

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
First let me introduce myself. I'm Niassa and I'm pretty new to all of this. I did some basic Flash development way back in Flash 4, but didn't get into AS much at all. I have some basic OOP knowledge (C++, VB and a smidge of Java) so I'm not completely lost. This error I keep getting, however, is frustrating me like crazy, especially since I'm nearly copying it from a tutorial on this very thing (works great in the tut, not-so-much in my actual programming).

All I'm trying to do is basically get this movie clip to act as a button. When it is clicked I want it to go to the first frame of a different scene (in this instance it's the next scene, but I don't know that it will always be the next scene). I'm using the gotoAndStop function for this. The name of that frame is "Two" and the name of the scene is "Mid1." When I click on the movie clip, I get this error:

Quote:




TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Template01t_fla::MainTimeline/Template01t_fla::frame2()




Here is my code:


ActionScript Code:
menuBtn_mc.buttonMode = true;
resourceBtn_mc.buttonMode = true;
nextBtn_mc.buttonMode = true;
exitBtn_mc.buttonMode = true;

menuBtn_mc.addEventListener(MouseEvent.MOUSE_OVER, menuRShow1);
menuBtn_mc.addEventListener(MouseEvent.MOUSE_OUT, menuRNoShow1);
resourceBtn_mc.addEventListener(MouseEvent.MOUSE_OVER, resourceRShow1);
resourceBtn_mc.addEventListener(MouseEvent.MOUSE_OUT, resourceRNoShow1);
nextBtn_mc.addEventListener(MouseEvent.MOUSE_OVER, nextRShow1);
nextBtn_mc.addEventListener(MouseEvent.MOUSE_OUT, nextRNoShow1);
nextBtn_mc.addEventListener(MouseEvent.CLICK, seeNext);
exitBtn_mc.addEventListener(MouseEvent.MOUSE_OVER, exitRShow1);
exitBtn_mc.addEventListener(MouseEvent.MOUSE_OUT, exitRNoShow1);

function seeNext(event:MouseEvent):void
{
    gotoAndStop("Two","Mid1");
}


function menuRShow1(event:MouseEvent):void
{
    menuRlvr_mc.alpha = 1;
}

function menuRNoShow1(event:MouseEvent):void
{
    menuRlvr_mc.alpha = 0;
}

function resourceRShow1(event:MouseEvent):void
{
    resourcesRlvr_mc.alpha = 1;
}

function resourceRNoShow1(event:MouseEvent):void
{
    resourcesRlvr_mc.alpha = 0;
}

function nextRShow1(event:MouseEvent):void
{
    nextRlvr_mc.alpha = 1;
}

function nextRNoShow1(event:MouseEvent):void
{
    nextRlvr_mc.alpha = 0;
}

function exitRShow1(event:MouseEvent):void
{
    exitRlvr_mc.alpha = 1;
}

function exitRNoShow1(event:MouseEvent):void
{
    exitRlvr_mc.alpha = 0;
}

nextBtn_mc.gotoAndPlay("Two")

stop();

Everything else in the code works beautifully. Any help you all can provide would be so wonderfully appreciated.

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
Compiler Error says:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at beachHome3_fla::MainTimeline/beachHome3_fla::frame1()



Code is:

ActionScript Code:
var homeImage_mc:MovieClip;
var imageRequest:URLRequest;
var imageLoader:Loader;


addImage("beach.jpg", 0);

declare_mc._onClickURL = "http://www.gbyguess.com/pulse.aspx?PulsePI=2";
fashion_mc._onClickURL = "http://www.gbyguess.com/Videos.aspx";
girls_mc._onClickURL = "http://www.gbyguess.com/pulse.aspx?PulsePI=1";
green_mc._onClickURL = "http://www.gbyguess.com/pulse.aspx?PulsePI=3";
music_mc._onClickURL = "http://www.gbyguess.com/pulse.aspx?PulsePI=4";


declare_mc.addEventListener(MouseEvent.CLICK, onClickURL);
fashion_mc.addEventListener(MouseEvent.CLICK, onClickURL);
girls_mc.addEventListener(MouseEvent.CLICK, onClickURL);
green_mc.addEventListener(MouseEvent.CLICK, onClickURL);
music_mc.addEventListener(MouseEvent.CLICK, onClickURL);

function addImage(imageURL:String, imagePosition:Number)
{
    homeImage_mc = new MovieClip;
    imageRequest = new URLRequest(imageURL);
    imageLoader = new Loader();
    imageLoader.load(imageRequest);
    homeImage_mc.addChild(imageLoader);
    homeImage_mc.x = imagePosition;
    addChildAt(homeImage_mc, 0);
}



function onClickURL(event:MouseEvent):void
{
    var link:URLRequest = new URLRequest(event.currentTarget._onClickURL);
    navigateToURL(link,"_parent");
}

declare_mc, fashion_mc, girls_mc, green_mc, & music_mc all exist on the stage. Where am I going wrong? Thanks!


EDIT
Please put code in [ as ] [ /as ] tags (without spaces)

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
I have kind of a problem with my loading external swf into my main swf... It works absolutely fine with any first movie I load to view its content and then unload... However when I try to load another movie I get the error message below. But my swf still loads and everything!
Since I'm learning AS3 I wanna understand the reason for that message and keep my code super tidy.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at ExternalMovie1_fla::MainTimeline/stopScroll()

ExternalMovie1_fla being the swf I just loaded to view the content and then unloaded...

Also, here below is the code I use, see if I can add/correct anything. Or would it come from the way I load up my external movies?


ActionScript Code:
/** Load Function **/
swf1BTN.addEventListener(MouseEvent.CLICK, clickButton);
function clickButton(myevent:MouseEvent):void {
    var myrequest:URLRequest=new URLRequest("ExternalMovie1.swf");
    var myloader:Loader=new Loader();
    myloader.addEventListener("UnloadMe", unloadFunction);
    myloader.load(myrequest);
    stage.addChild(myloader);
    myloader.x=62;
    myloader.y=340;
}

/** Unload Function **/
function unloadFunction(event:Event):void {
    // event.target is the loader reference.. so cast it as Loader
    Loader(event.currentTarget).unload();
}

Then I have this code in my external swf, linked to a "close" button:

ActionScript Code:
CloseBTN.addEventListener(MouseEvent.CLICK, unloadFunction);
function unloadFunction(event:MouseEvent) {
    dispatchEvent(new Event("UnloadMe", true));
}

THANK YOU!!!

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
am new to AS3, here the code:

package projectClasses.wormGrid {
//
//
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.EventDispatcher
//
import flash.display.StageScaleMode;
import flash.display.StageAlign;
//
import flash.display.Sprite;
import flash.display.MovieClip;
//
import GridWorm;
//
public class DocumentClass extends MovieClip {
//
//
private var clip:MovieClip;
//
private var gridDimensions:Array;
private var speed:Number;
private var wormNum:Number;
private var wormLength:Number;
//
public function DocumentClass() {
//
trace("got the class");
// -----------------------------------------------------
// BUILD GRID
createGrid();
}
// GRID
// redo grid elements
public function createGrid():void {
...
}
}
}

now i left out a bit of code in between the function to be called as its just math, but can someone explain, why it thorws the error at all?

whats this null object reference it wants to access?

thanks in advance for replies

Marcus

Curious: TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object
Hey guys

i get the following error in AS3::

----
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main/main::init3d()
at PaperBase/init()
at main$iinit()

-----
I assume that the object which is null is related to all 3 but am unsure if this is a common error or just something stupid i am missing! If its any worth the script does use eventlisteners and i am suspicious this may be involved.

Can anyone point me in the right direction?
Cheers
Ash

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Referenc
Hi,
I'm relativley new to ActionScript 3.0 and have to build a 3d-Carousel which loads external Pictures and places them as Carousel-"Objects" on the stage. I tried to accomplish this through combining tutorials: an external LoaderClass which loads the Pictures and a MainClass which places Pictures on the Stage and rotates them through a 3d-Engine. In addition the Carousel rotates in relation to mousemoving and places the clicked Container to the front.
Finally the Pictures are placed correctly but the Carousel is rotating very slowly and every Frame i get this Errormessage:

TypeError: Error #1009: Cannot access a property or method of a null object reference:
at CarouselMenu/::sortZ()
at CarouselMenu/::enterFrameListener()

I'm lost and would appreciate your help.


Here is the Code:

The Loader-Class:


Code:
package{

import flash.display.Sprite;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.*;
import flash.display.Bitmap;

public class CarouselLoader extends Sprite{
public var posZ:Number;
public var posX:Number;
public var posY:Number;
public function CarouselLoader(url:String):void
{
var urlRequest:URLRequest = new URLRequest(url);
var loader:Loader = new Loader();
loader.load(urlRequest);
loader.contentLoaderInfo.addEventListener(Event.INIT, initListener);
}
private function initListener(event:Event):void
{
var bmp:Bitmap = event.target.content;
bmp.x = -bmp.width/2;
bmp.y = -bmp.height/2;
addChild(bmp);
}
}
}
The Main Class:

Code:
package{
import flash.display.*;
import flash.events.*;
public class CarouselMenu extends MovieClip
{
private var focalLength:int = 250;
private var viewPointX:int = stage.stageWidth/2;
private var viewPointY:int = stage.stageHeight/3;
private var radius:uint = 400;
private var offsetZ:uint = 400;
private var numItems:uint = 5;
private var currentItem:CarouselLoader;
private var pictures:Array;
private var urls:Array;
public function CarouselMenu():void
{
var url:String = "http://www.thb-foto.de/3dgalerietest/";
var urls:Array = new Array(url+"img1.jpg",url+"img2.jpg",url+"img3.jpg",url+"img4.jpg",url+"img5.jpg");
pictures = new Array();
for(var i:uint = 0; i< urls.length; i++)
{
var picture:CarouselLoader = new CarouselLoader(urls[i]);
var angle : Number = (Math.PI * 2) / numItems * i;
picture.posZ = Math.sin (angle) * radius;
picture.posX = Math.cos (angle) * radius;
picture.posY = 100;
pictures.push(picture);
addChild(picture);

picture.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);


}
this.addEventListener(Event.ENTER_FRAME,enterFrameListener); // not working correctly
}

private function enterFrameListener(event:Event):void
{
var angleY : Number;
if(currentItem != null)
angleY = int(currentItem.posX - (currentItem.posX >= 0 ? (-radius-currentItem.posZ) : -(-radius-currentItem.posZ))) *.0002;
else
angleY = (mouseX - viewPointX) *.0002;
var cosY : Number = Math.cos ( - angleY);
var sinY : Number = Math.sin ( - angleY);
for(var i:uint = 0; i< pictures.length; i++){
var picture:CarouselLoader = CarouselLoader(pictures[i]);
var x1 : Number = picture.posX * cosY - picture.posZ * sinY;
var z1 : Number = picture.posZ * cosY + picture.posX * sinY;
picture.posX = x1;
picture.posZ = z1;
//3DEngine
var scale:Number = focalLength/(focalLength + picture.posZ + offsetZ);
picture.scaleX = picture.scaleY = scale;
picture.x = viewPointX + picture.posX * scale;
picture.y = viewPointY + picture.posY * scale;
}
sortZ(); // not working
}
private function sortZ():void
{
pictures.sortOn("posZ", Array.DESCENDING | Array.NUMERIC);
for(var i:uint = 0; i < urls.length; i++){
var picture:CarouselLoader = pictures[i];
setChildIndex(picture,i);
}
}
private function mouseDownListener(event:MouseEvent):void
{
currentItem = currentItem == CarouselLoader(event.target) ? null : CarouselLoader(event.target) ;
}
}
}

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
Hi all

I'm trying to develop a KeyController class that's going to track which keyboard keys are being pressed.

My document class looks something like this:


ActionScript Code:
package {
   
    import flash.display.*;
    import flash.events.*;
   
    import KeyController;
   
    public class MyGame extends MovieClip{
       
        public var controller:KeyController;
       
        public function MyGame(){
            initKeyController();
        }
       
       
        public function initKeyController():void{
            controller = new KeyController();
        }
       
    }
   
}

And this KeyController class looks like:


ActionScript Code:
package{
   
    import flash.display.*;
    import flash.events.*;
   
    public class KeyController extends Sprite{
       
        public function KeyController(){
            stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownListener);
            stage.addEventListener(KeyboardEvent.KEY_UP, keyUpListener);
        }
       
        public function keyDownListener(e:Event):void{
            trace("Key Down");
        }
       
        public function keyUpListener(e:Event):void{
            trace("Key Up");
        }
       
    }
   
}

My problem is I keep getting this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at KeyController()
at MyGame/initKeyController()
at MyGame()

Which I think means I'm trying to access something in KeyController that isn't ready to be accessed. But I can't figure out what that is.

Any help is always appreciated.

Thanks
Chris

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
After creating a botton to enter the page.
Nothing no longer works.

I get these messages:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at GrupoSite2_fla::MainTimeline/GrupoSite2_fla::frame1()
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
ArgumentError: Error #2109: Frame label null not found in scene Scene 1.
at flash.display::MovieClip/gotoAndPlay()
at GrupoSite2_fla::MainTimeline/GrupoSite2_fla::frame10()

Thanks.

I am just starting to use AS3. A beginner in Fash....

http://www.actionscript.org/forums/i...s/confused.gif

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
This is my as3 code which is used to upload images to the stage
and all the function that it uses is defined in my main timeline.So,please help me because it is urgent

function upldImg():void
{


m_isLocal = Boolean( this.loaderInfo.url.indexOf( 'http://' ) < 0 );


creating.visible = false;
creating.alpha = 0;

// add output container to stage at 0,0;
addChildAt( m_output, 0 );

// check to make sure stage is available ( which it wouldn't be if this class were instantiated from another class );
if ( stage != null )
{

stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;


with ( m_mask.graphics )
{
beginFill( 0x000000 );
drawRect( 0, 0, stage.stageWidth, stage.stageHeight );
}

var border : Sprite = new Sprite();

// draw border around stage;
with ( border.graphics )
{
lineStyle( 0, 0x000000 );
drawRect( 0, 0, stage.stageWidth - 1, stage.stageHeight - 1 );
}

addChildAt( border, numChildren - 1 );
}


// create progress indicator;
with ( m_progress.graphics )
{
beginFill( 0x000000 );
drawRect( 0, 0, upload.width, 1 );
}

addChild( m_progress );

m_progress.x = upload.x;
m_progress.y = upload.y + upload.height + 2;


captureContainer = m_output;


captureContainer.mask = m_mask;


m_effect = new Scribble();

captureContainer.addChild( m_effect );




this.addEventListener(Event.ADDED_TO_STAGE, init());
init();
var upload : UIButton;// upload button on .fla stage;
var create : UIButton;// create button on .fla stage;
//var scribble : UIButton;// scrubble button on .fla stage;
var clear : UIButton;// clear button on .fla stage;
var creating : Sprite;
var m_output : Sprite = new Sprite();// container for image;
var m_mask : Sprite = new Sprite();// mask for image container;
var m_progress : Sprite = new Sprite();// upload / download indicator;
var m_effect : Scribble;// covers image with random effect;

var m_isLocal : Boolean;// determines if swf is on web server or local drive;
var m_fileMgr : FileManager;// manages the opening & upload of local files;
var m_imagePHP : String = 'image.php';// file that will manage image upload on your server;
var m_finalImage : String;// final name of file on creation;
var m_imageQuality : Number = 90;// jpeg or png export quality;
var m_capture : Sprite;// set this equal to the sprite or movie clip that you wish to capture ( set to stage for entire movie );
var m_downloader : GraphicLoader;// handles image download ( after upload is complete );
var m_imageExtension : String = '.jpg';// jpeg image extension;








function onBrowse ( e : MouseEvent ) : void
{
trace ("hello");
m_fileMgr.browse();
}


function onCaptureImage ( e : MouseEvent ) : void
{
// make sure there is content to capture;
if ( captureContainer.width <= 1 && captureContainer.height <= 1 ) throw new Error( 'ERROR : no content to capture;' );

// show image creation message;
TweenFilterLite.to( creating, 1, { autoAlpha : 1 } );

// create image;
captureImage();
}

function onUploadProgress ( e : CustomEvent ) : void
{
trace( 'image uploading : ' + e.params.percent );

m_progress.scaleX = e.params.percent;
}


function onImageUploaded ( e : CustomEvent ) : void
{
var dPath : String = String( downloadPath + e.params.fileName );

trace( 'image ready for download at : ' + dPath );

m_downloader.loadURL( dPath );
}

function onDownloadProgress ( e : CustomEvent ) : void
{
trace( 'image downloading : ' + e.params.percent );

m_progress.scaleX = 1 - e.params.percent;
}

function onImageDownloaded ( e : CustomEvent ) : void
{
trace( 'image downloaded' );

// get image from loader;
var clip : DraggableImage = new DraggableImage( new Bitmap( e.params.loaded.bitmapData.clone() ) );

// add the image to the stage;
captureContainer.addChildAt( clip, captureContainer.getChildIndex( m_effect ) );

showOptions();
}


function onImageCreated ( e : Event ) : void
{
trace( 'image created : ' + e );

// hide image creation message;
TweenFilterLite.to( creating, 1, { autoAlpha : 0 } );

// download image;
downloadCreatedImage();
}

/**
*fires if there is an error creating the image;
**/
function onImageCreationError ( e : * ) : void
{
trace( 'error : ' + e );
}


function onUploadError ( e : CustomEvent ) : void
{
trace( 'upload error' );
}

/**
*fires if there is an error during download;
**/
function onDownloadError ( e : ErrorEvent ) : void
{
trace( 'download error' );
}


function onGetCapturedImage ( e : MouseEvent ) : void
{
m_fileMgr.download( finalImagePath, m_finalImage + m_imageExtension );
}


function onScribble ( e : MouseEvent ) : void
{
m_effect.createEffect();

showOptions();
}


function onClearAll ( e : MouseEvent ) : void
{
// remove all child object ( except effect clip ) from capture area;
while ( captureContainer.getChildAt( 0 ) is DraggableImage ) delete captureContainer.removeChildAt( 0 );

// reset the scribbles;
m_effect.reset();

hideOptions();
}

function init () : void
{
// set progress bar to zero scale;
m_progress.scaleX = 0;

// set up file manager;
m_fileMgr = new FileManager( uploadPath, m_uploadPath );
m_fileMgr.addEventListener( FileManager.ON_PROGRESS, onUploadProgress );
m_fileMgr.addEventListener( FileManager.ON_UPLOAD_ERROR, onUploadError );
m_fileMgr.addEventListener( FileManager.ON_IMAGE_UPLOADED, onImageUploaded );

// listen to buttons;
upload.addEventListener( MouseEvent.CLICK, onBrowse );
create.addEventListener( MouseEvent.CLICK, onCaptureImage );
//scribble.addEventListener( MouseEvent.CLICK, onScribble );
clear.addEventListener( MouseEvent.CLICK, onClearAll );

// ensure that the top left corner of the draw area is included in the draw calculations by drawing an invisible 1px box at 0,0;
var corner : Sprite = new Sprite();

// draw box;
with ( corner.graphics )
{
beginFill( 0xFFFFFF, 0 );
drawRect( 0, 0, 1, 1 );
}

// add corner piece to container;
captureContainer.addChild( corner );

// set up loader;
m_downloader = new GraphicLoader();
m_downloader.addEventListener( GraphicLoader.ON_LOAD_PROGRESS, onDownloadProgress );
m_downloader.addEventListener( GraphicLoader.ON_LOAD_COMPLETE, onImageDownloaded );
m_downloader.addEventListener( ErrorEvent.ERROR, onDownloadError );

hideOptions();
}

/**
*perform image capture and upload to server;
**/
function captureImage () : void
{
// set up a new bitmapdata object that matches the dimensions of the captureContainer;
var bmd : BitmapData = new BitmapData( m_mask.width, m_mask.height, true, 0xFFFFFFFF );

// draw the bitmapData from the captureContainer to the bitmapData object;
bmd.draw( captureContainer, new Matrix(), null, null, null, true );

// create a new JPEG byte array with the adobe JPEGEncoder Class;
var byteArray : ByteArray = new JPGEncoder( m_imageQuality ).encode( bmd );

// create and store the image name;
m_finalImage = getUniqueName();

// set up the request & headers for the image upload;
var urlRequest : URLRequest = new URLRequest();
urlRequest.url = createPath + '?path=' + m_outputPath;
urlRequest.contentType = 'multipart/form-data; boundary=' + UploadPostHelper.getBoundary();
urlRequest.method = URLRequestMethod.POST;
urlRequest.data = UploadPostHelper.getPostData( m_finalImage + m_imageExtension, byteArray );
urlRequest.requestHeaders.push( new URLRequestHeader( 'Cache-Control', 'no-cache' ) );

// create the image loader & send the image to the server;
var urlLoader : URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
urlLoader.addEventListener( Event.COMPLETE, onImageCreated );
urlLoader.addEventListener( IOErrorEvent.IO_ERROR, onImageCreationError );
urlLoader.addEventListener( SecurityErrorEvent.SECURITY_ERROR, onImageCreationError );
urlLoader.load( urlRequest );
}

/**
*downloads image to local computer;
**/
function downloadCreatedImage () : void
{
m_fileMgr.download( finalImagePath, m_finalImage + m_imageExtension );
}

/**
*returns new string representing the month, day, hour, minute and millisecond of creation for use as the image name;
*/
function getUniqueName () : String
{
var d : Date = new Date();

return d.getMonth() + 1 + '' + d.getDate() + '' + d.getHours() + '' + d.getMinutes() + '' + d.getMilliseconds();
}

/**
*show create / clear options;
**/
function showOptions () : void
{
create.show();
clear.show();
}

/**
*hide create / clear options;
**/
function hideOptions () : void
{
create.hide();
clear.hide();
}


}
upldImg();

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
I made a little particle engine for a project I'm working on, I have several particle sprites I wanna be able to use, and a single MovieClip that holds them all, each sprite in different frame, and I use this line to choose the sprite:


Code:
animRefMC.gotoAndStop(particleArray[j].sprite);
I get this error:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at particles::Particle_Manager/think()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
The weird thing is the code works perfectly, and this error only happens the first time I run the code after changing it.. lets say I changed the particleArray[j].sprite to something else, I run the code, I get the error, then I run it again without touching anything, and no error. Changed the frames position on the movieclip, running it, I get the error, running it again, no error.

What could be going on?

EDIT: Sometimes the error takes more times of re-running the code to disappear

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
Hello,

I have made a document class with a function in it to create buttons.
For these buttons I have also made a class.

This is the code from the button class:

// CameraButton klasse

package{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.*;

public class CameraButton extends Sprite{

private var topic:Topic;
private var huidig:Boolean;
private var ldrWFLoader;

public function CameraButton(topic:Topic, huidig:Boolean):void{
this.topic = topic;
this.huidig = huidig;
//om het handje weer te geven als je over het clickable item gaat
if(this.huidig==false){
this.buttonMode = true;
}

//eventlisteners toevoegen
this.addEventListener(MouseEvent.CLICK, clickHandler);
this.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);
this.addEventListener(MouseEvent.ROLL_OUT, rollOutHandler);

//loader van de images
if(this.huidig==false){
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest("images/"+this.topic.naam+".png"));
addChild(imageLoader);
}else{
var imageLoader1:Loader = new Loader();
imageLoader1.load(new URLRequest("images/"+this.topic.naam+"Actief.png"));
addChild(imageLoader1);
}

}

private function clickHandler(evt:MouseEvent):void{
var ldrWFLoader = new SWFLoader();
ldr.addEventListener(SWFLoader.LOAD_DONE, showMovie);
ldr.laad(this.topic.naam+".swf");
}

private function showMovie(evt:Event):void{
var MCToShow:MovieClip = ldr.MC;
trace(MCToShow);
addChild(MCToShow);
}

private function rollOverHandler(evt:MouseEvent):void{
if(this.huidig==false){
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest("images/"+this.topic.naam+"Actief.png"));
addChild(imageLoader);
}
}

private function rollOutHandler(evt:MouseEvent):void{
if(this.huidig==false){
var imageLoader:Loader = new Loader();
imageLoader.load(new URLRequest("images/"+this.topic.naam+".png"));
addChild(imageLoader);
}
}
}
}


The SWFLoader class is like this:

package{
import flash.events.*;
import flash.display.*
import flash.net.URLLoader
import flash.net.URLRequest
public class SWFLoader extends EventDispatcher{
public var MC:MovieClip;
public static const LOAD_DONEtring ="loaddone"
public function SWFLoader():void{
MC = new MovieClip();

}
public function laad(pathtring):void{
var req:URLRequest = new URLRequest(path)
var ldr:Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPL ETE,contentLoaded)
ldr.load(req);
}

private function contentLoaded(evt:Event):void{
trace(evt.target.content);
trace("test6");
MC = MovieClip(evt.target.content);
//
dispatchEvent(new Event(SWFLoader.LOAD_DONE));
}
}

}

Does anybody know why i get this error and how to solve it:
TypeError: Error #1009: Cannot access a property or method of a null object reference

Thanks in advance.

Bram De Baets.

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
I searched through this forum and had 2 posts of same error however they didn't help me. I was making codes for buttons, all 5 buttons and instance named each and gave them which frame to go to.

First arrow button works but next second one doesn't work. Please let me know asap because i would like to keep working and finish this.







Attach Code

package Xmaspack{
import flash.display.*;
import flash.events.*;

public class XmasApp extends MovieClip
{
public function XmasApp()
{
trace("XmasApp created");

chimmey_btn.addEventListener(MouseEvent.MOUSE_UP, playSanta);

arrow1.addEventListener(MouseEvent.MOUSE_UP, goRoom1);
arrow2.addEventListener(MouseEvent.MOUSE_UP, goRoom2);
arrow3.addEventListener(MouseEvent.MOUSE_UP, goList);
arrow4.addEventListener(MouseEvent.MOUSE_UP, goTree);
arrow5.addEventListener(MouseEvent.MOUSE_UP, goCredit);

stop();

}

public function playSanta(onEvent:MouseEvent):void
{
trace("chimmey button");
this.downChimmey.play();
}

public function goRoom1(onEvent:MouseEvent):void
{
trace("room1");
this.gotoAndStop("room1");
}

public function goRoom2(onEvent:MouseEvent):void
{
trace("room2");
this.gotoAndStop("room2");
}

public function goList(onEvent:MouseEvent):void
{
trace("check list");
this.gotoAndStop("list");
}

public function goTree(onEvent:MouseEvent):void
{
trace("put present under the tree");
this.gotoAndStop("tree");
}

public function goCredit(onEvent:MouseEvent):void
{
trace("credits");
this.gotoAndStop("credits");
}

} // end class


} // end package

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
hello, i keep getting the "TypeError: Error #1009: Cannot access a property or method of a null object reference." error for the following function, and i know this error is usually about missing instances, but it doesn't make any sense.

the function runs properly as long as i'm in frame 40, but when the last bit executes, as soon it moves back to frame 30 i keep getting the error for the ucKontrol function, which doesn't make any sense because:

1) it shouldn't execute in frame 30, it should run only in frame 40
2) i removed the event listener at the last bit, so it shouldn't execute anywhere

could someone tell me what i'm doing wrong here, i feel really stupid because i'm probably missing something very basic. thank you










Attach Code

function ucKontrol(event:Event):void
{
if(currentFrame == 40)
{

if(agacAnim03.currentFrame == 10)
{
agacAnim03.urunler03.gotoAndPlay(2);
}

else if(agacAnim03.urunler03.currentFrame >= 135)
{
agacAnim03.gotoAndPlay(61);
agacAnim03.urunler03.gotoAndStop(1);
}

else if(agacAnim03.currentFrame >= 105)
{
agacAnim03.gotoAndStop(1);
this.removeEventListener(Event.ENTER_FRAME, ucKontrol);
gotoAndStop(30);
}

else
{

}
}
}

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
I am so new at Flash and I'm working on a Web site within Flash that may be over my head!

I have looked online for solutions to this problem and I have found some, but I don't understand how to apply them to my Flash movie because I'm just a beginner.

So, when I'm testing my movie, I'm getting an error that says:









Attach Code

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at The_Cogs_Page_V2_fla::MainTimeline/frame106()

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
I am attaching the file for anyone that is willing to offere some advice.

I’m having a problem loading the compiled SWF into another project. I keep getting the following error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spaceBoard/Initial3D()
at spaceBoard()


Does anyone think of a reason why this might be happening?
Any help will be sincerely apprciated.

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
Hello all I have a slight problem here which I guess it would be simple to solve but I need here your help because I am not able to figure it out for much that I try.

On my third line of code you can see a reference to a text field that gets loaded with some text retrieved from an XML file. There is a button "nextButton_mc", which will call a function that should retrieve the pertinent text from the next node in that XML. All code works fine except for the reference I make to that text field inside the nextSlides function. I do not know why it would not work with the same reference I made before: MovieClip(this.parent).myText.text

When I press the button that should retrieve the next piece of text I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

Obviously I am doing something wrong here.

I am very grateful for any help from you.

Andres.


PHP Code:



function linkEvent(evt:TextEvent):void {    linkText.removeEventListener(TextEvent.LINK, linkEvent);MovieClip(this.parent).myText.text=projectsXML.item[Number(evt.text)].desc;    nextButton_mc.addEventListener(MouseEvent.CLICK, nextSlides);    var index=[Number(evt.text)+1];    function nextSlides(e:MouseEvent) {        if (index<projectsXML.item.length()) {MovieClip(this.parent).myText.text=projectsXML.item[index].desc;                      }         index++;    } 

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
hello, I'm new to flash and AS3, so maybe this is a dumb question but, I have a preloader that I want to tween down the alpha and move to the next frame. I have a tween variable tweening the alpha channel down to 0 and adding an event listener that moves to the next frame. here's my code:


ActionScript Code:
stop();this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);function onProgress(e:ProgressEvent):void{    var loaded:Number=e.target.bytesLoaded;    var total:Number=e.target.bytesTotal;    var pct:Number=loaded/total;    loader_mc.scaleX=pct;}function onComplete(e:Event):void{    var loaderTween:Tween = new Tween(loaderOutline_mc,"alpha",Strong.easeOut,1,0,1,true)    var loaderTween2:Tween = new Tween(loader_mc,"alpha",Strong.easeOut,1,0,1,true)}//************NEEDS TO BE CORRECTED*************loader_mc.addEventListener (Event.ENTER_FRAME, menuLoad);function menuLoad (event:Event):void    {        //trace(loader_mc.alpha)        if (loader_mc.alpha==0)        {            nextFrame();            loader_mc.removeEventListener (Event.ENTER_FRAME, menuLoad);        }    }


when I run the application it moves to the next frame, however I get an error code that repeats consecutively reading:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Production_6_fla::MainTimeline/menuLoad()

and does not stop repeating. I can still run the program but this is really making everything run super slow... I commented out everything in the "if statement" seperately and evrything outside of the "if statement"to see where the problem lies. the problem is in the nextFrame(); code.

I tried to add "stage.nextFrame(); but that did not work, and Stage.nextFrame(); and gotoAndStop(2); and stage.gotoAndStop(2); and I really can't figure out what is going on... I'm banging my head against the wall on this one.

TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
Hello all I have a slight problem here which I guess it would be simple to solve but I need here your help because I am not able to figure it out for much that I try.

On my third line of code you can see a reference to a text field that gets loaded with some text retrieved from an XML file. There is a button "nextButton_mc", which will call a function that should retrieve the pertinent text from the next node in that XML. All code works fine except for the reference I make to that text field inside the nextSlides function. I do not know why it would not work with the same reference I made before: MovieClip(this.parent).myText.text

When I press the button that should retrieve the next piece of text I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

Obviously I am doing something wrong here.

I am very grateful for any help from you.

Andres.


PHP Code:

function linkEvent(evt:TextEvent):void {

    linkText.removeEventListener(TextEvent.LINK, linkEvent);

MovieClip(this.parent).myText.text=projectsXML.item[Number(evt.text)].desc;


    nextButton_mc.addEventListener(MouseEvent.CLICK, nextSlides);


    var index=[Number(evt.text)+1];

    function nextSlides(e:MouseEvent) {
        if (index<projectsXML.item.length()) {
MovieClip(this.parent).myText.text=projectsXML.item[index].desc;        
              }

        index++;
    }

TypeError #1009: Cannot Access A Property Or Method
Hi i am designing a site where i will be loading content into an empty movieclip, the content wil consist of a few movieclip that are moveable and they will each contain buttons within them. Now i want the buttons to control what is displayed within the main timelines empty movieclip, however i am having trouble in making the buttons effect the empty movieclip, i thought the code below should have worked but it doesnt:



ActionScript Code:
homeBttn.addEventListener(MouseEvent.CLICK, loadWeb);


function loadWeb(evt:Event):void {
    var pageLoader:Loader = new Loader();
    var pageURLReq:URLRequest = new URLRequest ( "pages/AS3 Portfolio Main.swf");
    var swf:MovieClip;
    pageLoader.load(pageURLReq);
    pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

    function imageLoaded(evt:Event):void {
        holder.addChildAt(pageLoader.content, 1 );
        holder.removeChildAt(2);
        swf = evt.target.content;
       
        var button:MovieClip = swf.paper2.websiteBttn;
        button.addEventListener(MouseEvent.CLICK, openWeb);
       
    }
    function openWeb(e:Event):void {
        var pageLoader:Loader = new Loader();
        var pageURLReq:URLRequest = new URLRequest ( "pages/AS3 Portfolio Web.swf");
        pageLoader.load(pageURLReq);
        pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);

        function imageLoaded(evt:Event):void {
            holder.addChildAt(pageLoader.content, 1 );
            holder.removeChildAt(2);
        }
    }
}


As you can see once the main button is clicked the main content is loaded in "AS3 Portfolio Main.swf", and then it checks for a completion of that load and adds it to the stage. Then i created a variable (swf) to look for the button within the loaded movieclip on completion of the load, once that was done i wanted the program to look for the click event of that button and then run the click function by changing the content in the empty movieclip to the appropraite content. But all that i get is the error below:


ActionScript Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at MethodInfo-8()


is there any1 who can help me with this please thanks??

TypeError #1009: Cannot Access A Property Or Method
Hi i am designing a site where i will be loading content into an empty movieclip, the content wil consist of a few movieclip that are moveable and they will each contain buttons within them. Now i want the buttons to control what is displayed within the main timelines empty movieclip, however i am having trouble in making the buttons effect the empty movieclip, i thought the code below should have worked but it doesnt:



ActionScript Code:
homeBttn.addEventListener(MouseEvent.CLICK, loadWeb);function loadWeb(evt:Event):void {    var pageLoader:Loader = new Loader();    var pageURLReq:URLRequest = new URLRequest ( "pages/AS3 Portfolio Main.swf");    var swf:MovieClip;    pageLoader.load(pageURLReq);    pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);    function imageLoaded(evt:Event):void {        holder.addChildAt(pageLoader.content, 1 );        holder.removeChildAt(2);        swf = evt.target.content;                var button:MovieClip = swf.paper2.websiteBttn;        button.addEventListener(MouseEvent.CLICK, openWeb);            }    function openWeb(e:Event):void {        var pageLoader:Loader = new Loader();        var pageURLReq:URLRequest = new URLRequest ( "pages/AS3 Portfolio Web.swf");        pageLoader.load(pageURLReq);        pageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);        function imageLoaded(evt:Event):void {            holder.addChildAt(pageLoader.content, 1 );            holder.removeChildAt(2);        }    }}



As you can see once the main button is clicked the main content is loaded in "AS3 Portfolio Main.swf", and then it checks for a completion of that load and adds it to the stage. Then i created a variable (swf) to look for the button within the loaded movieclip on completion of the load, once that was done i wanted the program to look for the click event of that button and then run the click function by changing the content in the empty movieclip to the appropraite content. But all that i get is the error below:


ActionScript Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.    at MethodInfo-8()



is there any1 who can help me with this please thanks??

Error #1009: Cannot Access A Property Or Method Of A Null...
Yep, I've found this is an infamous error msg and I've actually fixed it the first time it appeared. However, I'm not sure how to deal with it with the new field it's complaining about.

Forgive me, this is my first actionscript where I'm using a main file and its' companion package file. My very first actionscript, well I had all my code in one file and then noticed example code in tutorials were separated in packages. So, I have split off my one file into the convention where the class is in an external file but now, I am encountering the 1009 type error.

In short, I'm trying to add a sprite using an external jpg file and also added in a function so that I can move it. I put all loads and move function in the class package file. The error is that when I try to access the "addEventListener" statement, I encounter the error listed in the title. The error message (complete) is:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at asdata::Bumper()
at bumper_fla::MainTimeline/frame1()

The main file code is:

import asdata.Bumper;
var myBumper:Bumper = new Bumper();

The class package file is:


ActionScript Code:
package asdata{
import flash.display.*;
import flash.net.URLRequest;
import flash.events.*;
 
public class Bumper extends Sprite{
 
private var bumper:Sprite = new Sprite();
private var loader:Loader = new Loader();
private var rq:URLRequest = new URLRequest("bumper.png");
 
public function Bumper() {
trace("entered new bumper creation");
 
loader.load(rq);
this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadBumper);
//next statement is where the error occurs.
//I think it's having a problem accessing stage because
//it is null but I don't know what to do to fix this.
stage.addEventListener(MouseEvent.MOUSE_MOVE,moveBumper);
}
 
 
function loadBumper(event:Event):void {
var bumperImage:BitmapData = new BitmapData(loader.width,loader.height,false,0x000000);
bumperImage.draw(this.loader);
 
this.bumper.graphics.beginBitmapFill(bumperImage, null, true);
bumper.graphics.drawRect(0,0,100,10);
bumper.graphics.endFill();
bumper.x = 10;
bumper.y = 290;
addChild(bumper);
}
 
 
function moveBumper(e:MouseEvent):void {
bumper.x = e.stageX - bumper.width;
}
}
}

How do I substantiate stage before accessing it? Or am I analyzing this error incorrectly? Also, when I had the code all in one file, a picture actually appeared when it executed the 'addChild' statement. However, now that I've separted the code into 2 files (main with .as file), nothing appears after the addChild is executed. :x Am I wrong to assume that anything added to the display list in a class will not appear? What am I doing wrong here, too?

Any help is appreciated,
Marion the Mighty Confused

P.S. I'm sorry the program isn't indented correctly, the editor stripped out my tabs and extra spaces.

Rollover Makes Error#1009:Cannot Access A Property Or Method
Whenever I rollover a section, this pops up in the output panel:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.transitions::Tween/setPosition()
at fl.transitions::Tween/set position()
at fl.transitions::Tween()
at Buttons_fla::MainTimeline/AlphaUp()

Error#1009: Cannot Access A Property Or Method Of A Null Object Reference.
Hi Guys,

I am hoping that someone can help me, as I am at a loss....

I don't understand why this script does not work, it keeps coming up with the Error #1009

I appreciate any help




Code:
function gotoAuthorPage(event:MouseEvent) :void
{
var targetURL:URLRequest = new URLRequest ("http://www.digi-sign.com/");
navigateToURL(targetURL);
}
homeButton.addEventListener(MouseEvent.CLICK,gotoAuthorPage);

Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
hi all- i'm relatively new to flash, have been getting into for the past few weeks. anyhow, i've been encountering this error as I load new swf into my main file...

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-203()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.controls::ProgressBar/_setProgress()
at fl.controls::ProgressBar/handleProgress()
-------------------------------------------------------------------------
Here's the code I've got on frame one of my main file:

import flash.events.EventDispatcher;
import flash.display.MovieClip;
stop();

//Define SWFLoader -------------------------------------------

var loader:Loader = new Loader();
addChild(loader);
SWFLoader.addChild(loader);

loader.contentLoaderInfo.addEventListener(
Event.COMPLETE,
function(evt:Event):void {
SWFLoader.x = 0;
SWFLoader.y = 0;
}
);

------------------------------------------------------------------

and this is the code I'm using to call the loading of my external movie:

loader.load(new URLRequest("swf/gS_Architecture.swf"));

------------------------------------------------------------------

I don't know where I'm going wrong, looking for help. Much appreciated, Ken.

Error #1009 Cannot Access A Property Or Method Of A Null Object Reference.
Someone has probably already answered this question in another forum, but I couldn't find a solution. I have a .swf that is loading other .swfs. Everything works fine when I run it in Flash Player, but once I embed the swf into an html I get Error #1009...

Does anyone know why this would happen in an html an not in flash player?

If I press continue the code seems to run just fine, but I don't want this error to create panic in those who will view the page. Plus, the fact that I get this error makes me think something is not working right.

Error #1009: Cannot Access A Property Or Method Of A Null Object Reference
This is driving me insane! Hopefully someone here can help. I've been given what is a mess of timelined and AS files actionscript and have managed to solve my way through most of it after much hrs. This has me stumped though, i'm still new at AS3.

When clicking on a button that is to load an external swf i get the following errors:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at main_fla::MainTimeline/loadBigImg()
at main_fla::left_19/mapBtn()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AS::BigImage/setLG()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AS::BigImage/setLG()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at AS::BigImage/imgLoaded()



i've checked all of these and from what i can understand it's trying to make a reference before the object / reference is available ?

Here is the loadBigImg() function:


ActionScript Code:
function loadBigImg(bigSrc:String):void {
    content_mc.h.stopAnimation();
    home.mouseChildren = false;
    TweenFilterLite.to(home, .5, {type:"Blur", blurX:8, blurY:8, ease:Sine.easeOut, quality:2});
    TweenFilterLite.to(home, .5, {type:"color", colorize:0xFFFFFF, amount:1, brightness:2, overwrite:false});
    var bImg:BigImage = new BigImage(bigSrc);
    parent.parent["BigImageHolder"].addChildAt(bImg, 0);
    parent.parent["BigImageHolder"].alpha = 1;
    parent.parent["BigImageHolder"].addEventListener(MouseEvent.CLICK, bigImgOff);
    parent.parent["BigImageHolder"].buttonMode = true;
    parent.parent["BigImageHolder"].mouseChildren = false;
}

Here is the mapBtn() function:


ActionScript Code:
function mapBtn(evt:MouseEvent):void {
    if(evt.type == MouseEvent.CLICK) {
        MovieClip(parent).loadBigImg("map.swf");
    }
}

Here is the setLG() function:


ActionScript Code:
public function setLG(evt:ProgressEvent):void {
    lg.x = stage.stageWidth/2-lg.width/2;
    lg.y = stage.stageHeight/2-lg.height/2;
}

and finally ....


ActionScript Code:
public function imgLoaded(evt:Event):void {
    removeChild(lg);
    /*bmpData = new BitmapData(ld.width, ld.height, true, 0x00000000);
    bmpData.draw(ld);
    bmp = new Bitmap(bmpData, "auto", true);*/
    ld.alpha = 0;
    ld.x = stage.stageWidth/2-ld.width/2;
    ld.y = stage.stageHeight/2-ld.height/2;
    addChild(ld);
    TweenLite.to(ld, .15, {alpha:1});
}

Any help with this will be GREATLY appreciated. All it needs to be doing is loading in a damn swf when a button is clicked, and unloading it when something else is clicked.

Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
I have searched this error over and over and I can't seem to find a good response as to what this means. More specific to what I am working on now, is I am working on a site using PureMVC, and I am getting this very non-descriptive error "Error #1009: Cannot access a property or method of a null object reference." I am using very similar code to the one in this tutorial (http://hubflanger.com/building-a-fla...using-puremvc/) and I don't get an error with that code.

Here is my code:


ActionScript Code:
var siteHolder : SiteHolder = new SiteHolder();
           
try
{
     facade.registerMediator (new SpiralMediator( siteHolder ));   
}
     catch ( error: Error)
{
     trace(error.message); 
}

I traced the facade instance and it exists, I traced the siteHolder instance and it exists, and I tried instantiating the SpiralMediator separately and it worked, so I have come down to the solution that the registerMediator Method is not working. However, I traced it, and it seems to be working. Anyone have any suggestions?

Error #1009 Cannot Access A Property Or Method Of A Null Object Reference.
I am trying to do a simple gotoAndPlay but I keep getting this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.

This is my code. Very simple, I just can't figure out what is wrong. Any help would be greatly appreciated.



import flash.events.MouseEvent;

turnOn.addEventListener(MouseEvent.CLICK, videoBtnOn);
turnOff.addEventListener(MouseEvent.CLICK, videoBtnOff);

function videoBtnOn(event:MouseEvent):void
{
gotoAndPlay("showVideo");
}

function videoBtnOff(event:MouseEvent):void
{
gotoAndPlay("hideVideo");
}

Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
Hello everyone,

I'm trying to learn actionscript 3.0.
I have problem need helps everyone

Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
Hello,

Please help, this is a tricky one to explain, but hopefully someone out there will be able to understand the problem I am having and be able to shed some light on the matter.

Okay, so I have quite a large naviagtional flash .swf. It is created on the timeline, with some elements added dynamically and others are on the stage.

I have a menu naviagtion bar on each frame, these are buttons and if clicked send you to the corresponding frame by gotoAndStop commands. The only other code in these functions are the removeChild(); commands required for each frame. This works up to a point, however every now and then I keep getting the error message below:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at TestingVersion5_fla::MainTimeline/TestingVersion5_fla::frame3()

This is a pain because it does not tell me specifically where the error is so I dont know what to change, what is also annoying is that this error seems to appear randomly with no connection as to which button is being pressed at the time, I should also mention, when this error is displayed, one of the buttons on the stage becomes invisible.

Anyone any ideas how I can perhaps fix this one? Would adding these navigation buttons dynamically help in any way?

Many thanks

It is greatfully appreciated.

Thanks again Jude :D

TextArea And Error #1009: Cannot Access A Property Or Method Of A Null Object Referen
Hi. I get this error when I try to display a TextArea. All I see is the text, no border or scroll bar. The odd thing is, I have another TextArea in a different part of the code that works. The instance parameters in the .fla file are identical between the two and in the code, all I'm doing for each is assigning the text (textAreInstance.htmlText = "...").

Any ideas on why this is happening?

Error #1009:Cannot Access A Property Or Method Of A Null Object Reference. [renamed]
Hi, i made a class that creates some sprites and make all those spectrum analyzer effects
when i use this class as the document class of an swf file, it works fine, but if i try to create an instance of this class inside another one, o got this message


TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.chan.graphics::OvalSpectrumAnalyzer$iinit()
at com.chan.graphics::Teste/com.chan.graphics::frame1()

i don´t understand the explannation on the reference related to this error...

what am i doing wrong, and how can i create an instance of this class?

one thing that i didn't understand is what means the null object reference

can anyone tell me what´s wrong with my class?

thanks

Pong Game: GotoAndStop Causing Error #1009: Cannot Access A Property Or Method Of A Null Object Reference.
I'm building a pong game as a way of learning Flash and actionscript 3. Almost have it done.

The game consists of 4 frames: begin, play, win, and lose.

The code for begin works fine and the code for win and lose is the same so I will concentrate on the code for play and lose.

The actual game code in play works fine. Collision detection, score tracking, player paddle movement, AI paddle movment, etc. But there is one problem.

Problem: After the player or the computer gets to 5 points the game is supposed to go to the win or lose frame. I use gotoAndStop for this: gotoAndStop("lose"). This is where I get the "Error #1009: Cannot access a property or method of a null object reference."

From what I can tell it has to do with the gotoAndStop statements that take the player to the win or lose frame. I say this because if I add an End button with an event listener and function call in place of either gotoAndStop statement the End button works properly. It takes me to the win or lose frame (depending on which I target) without an error. But only putting gotoAndStop("frame") in the if statement gives me the error. I want the program to automatically go to the win or lose frame based on the score. I do not want the user to have to click anything.

The code I'm using for the play and lose frames is below.

Any thoughts?







Attach Code

//PLAY FRAME CODE

var playerScore:int = 0;
var computerScore:int = 0;
var relY:int;
var relPerc:Number;
var newDy:Number;

init();

function init(){
//turns off mouse pointer
Mouse.hide();

//gives ball initial direction
ball.dx = 15;
ball.dy = 6;

//Sets the speed of the computer's paddle. Higher speed equals a better
//opponent.
computerPaddle.speed = 8;
}

playerPaddle.addEventListener(Event.ENTER_FRAME, fnPlayerEnterFrame);
computerPaddle.addEventListener(Event.ENTER_FRAME, fnComputerEnterFrame);
ball.addEventListener(Event.ENTER_FRAME, fnBallEnterFrame);

function fnPlayerEnterFrame(event:Event):void{
//Player's paddle follows mouse
playerPaddle.y = stage.mouseY - (playerPaddle.height / 2);
}

function fnComputerEnterFrame(event:Event):void{
//Move the computer's paddle relative to the ball and difficulty
//setting (computerPaddle.speed)
if ((ball.y + (ball.height/2)) < (computerPaddle.y + (computerPaddle.height/2))){
computerPaddle.dy = -computerPaddle.speed;
} else {
computerPaddle.dy = computerPaddle.speed;
}
computerPaddle.y += computerPaddle.dy;
}

function fnBallEnterFrame(event:Event):void{
//move the ball
ball.move();

//check if it hit the top or bottom
ball.checkBoundaries();

//check if it hit a paddle
ball.checkPaddles();
}


ball.move = function(){
ball.x += ball.dx;
ball.y += ball.dy;
}

ball.checkBoundaries = function(){
if (ball.y < 0){
ball.dy = -ball.dy;
}
if (ball.y > stage.stageHeight){
ball.dy = -ball.dy;
}
if (ball.x < 0){
computerScore++;
computerScoreField.text = computerScore.toString();
if (computerScore >= 5){
gotoAndStop("lose");
}

ball.x = computerPaddle.x-50;
ball.y = computerPaddle.y + (computerPaddle.height / 2);

ball.dy = 0;
}

if (ball.x > stage.stageWidth){
playerScore++;
playerScoreField.text = playerScore.toString();

if (playerScore >= 5){
gotoAndStop("win");
}

ball.x = playerPaddle.x + 50;
ball.y = playerPaddle.y + (playerPaddle.height / 2);
ball.dy = 0;

}
}

ball.checkPaddles = function(){
if (ball.hitTestObject(playerPaddle)){
ball.dx = -ball.dx;
ball.dy = getDy(playerPaddle);
}
if (ball.hitTestObject(computerPaddle)){
ball.dx = -ball.dx;
ball.dy = getDy(computerPaddle);
}
}

function getDy(paddle){
relY = (ball.y + (ball.height/2)) - (paddle.y + (paddle.height/2));

relPerc = relY / paddle.height;

newDy = relPerc * 30;

return newDy;
}



//LOSE FRAME CODE

Mouse.show();

btnPlay.addEventListener(MouseEvent.CLICK, fnPlay);

TypeError: Error #1009: Cannot Access
For some GD reason I keep getting this error and I dont know why.


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at components.alpharaven::Frame/SetSize()
at framework/::StartAnimation()
I am attaching the files for reference. CAN SOMEONE PLEASE HELP!!!!. I cant seem to figure out the reason why its happening. Everything seems fine to me.

#1009: Cannot Access A Property Or Method Of A Null Object Reference.
I've googled this error a ton but haven't found anything relevant yet. I'm in an AS 3.0 class (as in a room with people and a teacher and text books and lectures .. not a class file) and we're all getting the same errors.

Basically we all have to create a file with 10 buttons. Each button needs to go to a new frame. On that frame we have a separate actionscript 3.0 code that does something (for this question, I do not think it matters... each script on each frame has to show off a different AS 3.0 code that proves we've learned something).

So let's say we have 11 frames. Frame 1 has the navigation and the intro. Frames 2-11 each have a stop(); and a new code.

So each frame has different content (except for the background and navigation buttons which are consistent on all frames).

The problem is that on one frame we have an ENTER_FRAME on a movie clip that points to a specific function. On that particular frame it works fine but once you navigate to a new frame on the timeline - the function continues to run in the background and we get the "#1009: Cannot access a property or method of a null object reference" error. (I assume it's because on the new frame the content from the previous frame no longer exists. By content I mean the movie_clips/buttons/etc..)

Once the functions start to run on top of each other in the background - the entire SWF just devolves and breaks down because it's trying to do too many things at once.

removeListener seems like the obvious answer but on each new frame it generates an error because it can't see the content from the previous frame on which the Listener was added. Putting it on the navigation button codes doesn't seem to work either.

Any theoretical suggestions?

Classes And Movieclips: "TypeError: Error #1009: Cannot Access"
Howdy folks.

On the stage i have a movieclip named menu.

When i want to grab the movieclip from the Index.as file (which is my document class)
I use this code:

ActionScript Code:
getChildByName("menu"); //Works fine

Then i create a class lets call it myClass and to that class i send the stage object

When im from there need to grab the menu movieclip i try to use this code

ActionScript Code:
myStage.getChildByName("menu");
trace("myStage: " + myStage); //output myStage: [object Stage]
and recive the following error:
TypeError: Error #1009: Cannot access a property or method of a null object reference.

What am i doing wrong?
Do i need to send the menu movieclip aswell to myClass?

Thanks /Nobster

Error 1009Cannot Access A Property Or Method Of A Null Object
How do I prevent this error? is is fine until I shift all my content on one frame to create a preloader for the main swf.

I'm using this class called proximitymenu, written by Lee at the Flash Blog.


Code:
package
{
// Import Flash classes
import flash.display.*;
import flash.events.*;

public class ProximityMenu extends MovieClip
{
private var ia:Array;

public function ProximityMenu():void
{
ia = [eg1Mc, eg2Mc, eg3Mc, eg4Mc, eg5Mc, eg6Mc, eg7Mc, eg8Mc, eg9Mc, eg10Mc];
for(var i:uint=0; i<10; i++)
{
ia[i].buttonMode = true;
ia[i].ox = ia[i].x;
ia[i].oy = ia[i].y;
ia[i].tx = ia[i].ox;
ia[i].ty = ia[i].oy;
ia[i].addEventListener(MouseEvent.ROLL_OVER, onOver);
}
stage.addEventListener(Event.ENTER_FRAME, onMove);
}

private function onOver(e:MouseEvent):void
{
e.target.gotoAndPlay("over");
addChild(MovieClip(e.target));
}

private function onMove(e:Event):void
{
for(var i:uint=0; i<10; i++)
{
var dist:Number = getDist(mouseX, mouseY, ia[i].ox, ia[i].oy);
if(dist < 70)
{
ia[i].tx = mouseX;
ia[i].ty = mouseY;
}
else
{
ia[i].tx = ia[i].ox;
ia[i].ty = ia[i].oy;
}
ia[i].x += Math.round((ia[i].tx - ia[i].x) * 0.3);
ia[i].y += Math.round((ia[i].ty - ia[i].y) * 0.3);
}
}

private function getDist(x1:Number, y1:Number, x2:Number, y2:Number):Number
{
var dx:Number = x2 - x1;
var dy:Number = y2 - y1;
return Math.sqrt(dx*dx + dy*dy);
}
}
}

TypeError: Error #1009:
HI All,

I'm trying to follow a lesson in the ActionScript 3.0 Cookbook and hitting a wall. This book is written for Flex Developers so the conversion to Flash is giving me some trouble (that's my story and I'm sticking to it).

So I've created a class:


Code:
package testing{
import flash.display.Sprite;
import flash.text.TextField;
import flash.events.MouseEvent;
public class RemoveChildExample extends Sprite{
private var _lable:TextField;
public function RemoveChildExample(){
_lable = new TextField();
_lable.text = "Some Text";
addChild(_lable);
stage.addEventListener(MouseEvent.CLICK, removeLable);
}
public function removeLable(event:MouseEvent):void{
removeChild(_lable);
}
}
}
And a FLA File


Code:
import testing.RemoveChildExample;
var myText:RemoveChildExample = new RemoveChildExample();
this.addChild(myText);
And I get this error:


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at testing::RemoveChildExample()
at CircleText_fla::MainTimeline/frame1()
Any thoughts?

Thanks.

_t

TypeError: Error #1009
I'm new to Flash, and ActionScript3.

I'm trying to create a very basic "slideshow", when I compile, it runs, but I get the following error.


Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at lab7_fla::MainTimeline/lab7_fla::frame1451()
On that frame is the following ActionScript.


Code:
menu2.addEventListener(MouseEvent.CLICK,menu2Listener);
next2.addEventListener(MouseEvent.CLICK,next2Listener);
prev2.addEventListener(MouseEvent.CLICK,prev2Listener);

function menu2Listener(event:MouseEvent):void {
gotoAndPlay(2,"Menu");
}

function next2Listener(event:MouseEvent):void {
nextFrame();
}

function prev2Listener(event:MouseEvent):void {
prevFrame();
}
What's weird is, the nextFrame is working, but not the prevFrame button.
I am using scenes, and the scenes are being displayed properly.

My only problem is the error, and the prevFrame not working.

Please help out this AS3 n00b.

TypeError: Error #1009
Good day everybody.. so yes im a complete noob at this.. i can handle most coding languages.. but this i just cant

so this is the AS 3.0 i have for a preloader .. that i used from a tut, is a simple fill up pre-loader. so the tut was made for AS 2.0 and i tried to migrate some parts like the on enterframe thing.. and the getbytesloaded.. so yah but when i try it i all ways get an error..

TypeError: Error #1009

and heres is the code..


Code:
stop();
mask_mc.height = 1;
addEventListener(Event.ENTER_FRAME,shizzy);
function shizzy(event:Event) {
var bytesLoaded:uint = 0
var bytesTotal:uint = 0
var loadedData:Number = bytesLoaded
var allData:Number = bytesTotal
var percent:Number = Math.round(loadedData/allData*100);
mask_mc.scaleY = percent;
if (loadedData>=allData) {
gotoAndStop(10);
delete this.onEnterFrame;
}
}

TypeError: Error #1009: Help
Hey, i am relatively new to actionscript and xml and i just cant wrap my head around this problem!

This is the Error i am getting:

Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at dandeFly::Dandelion/doAddedToStage()
at flash.display::DisplayObjectContainer/addChildAt()
at dandeFly::DandelionManager/initLevel()
at dandeFly::Document/initLevel()
at dandeFly::Document/dandeFly::frame29()
Here is my xml code:

Code:
<?xml version="1.0"?>
<game freelifeat="5000" maxlives="3">
<butterfly initshieldcnt="90" levelshieldcnt="15" maxspeed="10"></butterfly>
<dandelion initastcount="4" levelastcount="2">
<large proto="2" scale="1.00" points="10" maxspeed=".5" maxspeedvar=".5" maxrot=".25" maxrotvar="1" />
<med proto="1" scale="0.75" points="20" maxspeed="1" maxspeedvar=".5" maxrot="1" maxrotvar="2" />
<small proto="0" scale="0.50" points="30" maxspeed="3" maxspeedvar="1" maxrot="3" maxrotvar="3" />
</dandelion>
<bullets gbulletspeed="12" gbullets="4" bbulletspeed="5" bbullets="1" />
</game>

Here is my XML actionscript loader file:

Code:
package dandeFly
{
import flash.display.*;
import flash.events.*;
import flash.net.*;

public class XMLLoader
{
private var pRequest:URLRequest;// Request from file or Internet
private var pLoader:URLLoader;// Content Loader
private var pFile:String;// Retains the file path
private var pDocClass:Document; // Reference back to the document class
private var pAM:DandelionManager;// Manager References
private var pGM:ButterflyManager;
private var pBM:BulletManager;

// Constructor - Executes content loading and retains information regarding
// all of the content managers passed in (as well as the document class)
public function XMLLoader(aFile:String, aDocClass:Document, aAM:DandelionManager, aGM:ButterflyManager, aBM:BulletManager)
{
// Keep around parameters
pFile = aFile;
pDocClass = aDocClass;
pAM = aAM;
pGM = aGM;
pBM = aBM;

// Set up the loader
pRequest = new URLRequest(pFile);
pLoader = new URLLoader();

// Set up the event listeners
pLoader.addEventListener(Event.COMPLETE, doComplete);
pLoader.addEventListener(IOErrorEvent.IO_ERROR, doError);
pLoader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, doError);

// Load the content
// Requires an event to continue
pLoader.load(pRequest);
}

// doComplete - Event handler that reads in the loader content and
// parses it as XML

public function doComplete(anEvent:Event):void
{
// Convert loader content to an XML Object
var xmlData:XML = new XML(pLoader.data);

// Read information pertaining to the document class
pDocClass.freelifeat = xmlData.@freelifeat;
pDocClass.maxlives = xmlData.@maxlives;

// Read information pertaining to the ButterflyManager
pGM.initShieldCount = xmlData.butterfly.@initshieldcnt;
pGM.levelShieldCount = xmlData.butterfly.@levelshieldcnt;
pGM.maxspeed = xmlData.butterfly.@maxspeed;

// Read information pertaining to the DandelionManager
pAM.initCount = xmlData.dandelion.@initastcount;
pAM.levelCount =xmlData.dandelion.@levelastcount;

// Read information pertaining to the BulletManager
pBM.gBullets = xmlData.bullets.@gbullets;
pBM.gBulletSpeed =xmlData.bullets.@gbulletspeed;
pBM.bBullets = xmlData.bullets.@bbullets;
pBM.bBulletSpeed = xmlData.bullets.@bbulletspeed;

// Now, for each Dandelion Prototype, read all pertenent information
for each (var element:XML in xmlData.Dandelions.*)
{
var tempProto:DandelionPrototype = new DandelionPrototype();
tempProto.pProto = element.@proto;
tempProto.pScale = element.@scale;
tempProto.pPoints = element.@points;
tempProto.pMaxSpeed = element.@maxspeed;
tempProto.pMaxSpeedVar = element.@maxspeedvar;
tempProto.pMaxRot = element.@maxrot;
tempProto.pMaxRotVar = element.@maxrotvar;
pAM.addProto(tempProto);
}

// When all is OK, tell the document class to change to the
// instructions state
pDocClass.doInstructions();
}

// doError - This event handler tells the document class to change
// to the error state

public function doError(anEvent:Event):void
{
pDocClass.doError();
}
}
}
Here is the part of code from the dandelion AS file:

Code:
public function doAddedToStage(anEvent:Event):void
{
stop();
rotation = GameMath.randRange(0,360);
distance = GameMath.randRange(pProto.pMaxSpeed+pProto.pMaxSpeedVar,pProto.pMaxSpeed+pProto.pMaxSpeedVar);
angvel = GameMath.randMotion(pProto.pMaxRot-pProto.pMaxRotVar, pProto.pMaxRot+pProto.pMaxRotVar);
scale = pProto.pScale;
isActive = true;
gotoAndStop("dandelion"+pType+"active");
update();
}
And here is the code from the Document constructor as file:

Code:
public function initLevel():void
{
// Tell all the managers to init level data
pDandelionManager.initLevel();
pButterflyManager.initLevel();
pBulletManager.initLevel();


// Start the timer to do game updates
pUpdateTimer.start();
}
and lastly the code from the dandelion manager AS file:

Code:
public function initLevel():void
{
for (var x:int = 0; x < pCount; x++)
{
var tempPoint:Point = new Point(GameMath.randRange(0, pDocClass.stage.stageWidth), GameMath.randRange(0,pDocClass.stage.stageHeight));
var tempDandelion:Dandelion = new Dandelion(getProto(pDandelionProto.length - 1),this, tempPoint);
pDandelions.push(tempDandelion);
pDocClass.addChildAt(tempDandelion, 1);
}
}

Could anyone give me an idea as to why these errors are appearing?

TypeError: Error #1009
Hello. I am getting a null object reference error on a button in Adobe Flash CS3 (ActionScript 3.0). The button is placed in frame 1 and has small roll over and roll out animations. When the button is clicked, flash resumes play at a point further down the timeline. I can avoid the error by removing the roll out animation or by having the gotoAndPlay command point to a frame earlier than the frame when the button was clicked. How can I change the command to keep the roll out animation and still have the button function as a skip button? Thank you.

AS 3.0 Command:
myBtn.buttonMode = true;
myBtn.addEventListener(MouseEvent.ROLL_OVER,animIn );
myBtn.addEventListener(MouseEvent.ROLL_OUT,animOut );
function animIn(event:MouseEvent):void {
myBtn.gotoAndPlay(5);
}
function animOut(event:MouseEvent):void{
myBtn.gotoAndPlay(11);
}
myBtn.addEventListener(MouseEvent.MOUSE_DOWN,skipi ntro);
function skipintro(event:MouseEvent):void{
gotoAndPlay(285);
}

Error Displayed:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index_fla::MainTimeline/animOut()

Copyright © 2005-08 www.BigResource.com, All rights reserved