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.
KirupaForum > Flash > ActionScript 3.0
Posted on: 12-19-2008, 08:39 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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
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 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++;
}
[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 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) ;
}
}
}
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,
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
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);
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
#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?
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?
Please PLease Help [TypeError: Error #1009: Null Object Reference]
Hello I am making an OOP scroll bar. I have three classes
1. ScrollBox
This class contains the scroll bar and a container that hold the images to be scrolled.
2. Scroll Bar
This class controls the scrolling of the bar and dispatches a scrollbar event containing the percentage to which the thumb bar is moved.
3. ScrollBarEvent class.
This class simply fires an event with the event object containing the percentage of the scroll bar scrolling.
Now Everything was running fine when it was on the stage but as I moved the code in classes it give a TYPE ERROR 1009 saying it cant access a property or method of null object reference.
The error comes when I create an object of scroll bar inside the scroll box class. I am pasting the code for the classes below.
SCROLL BAR Class
Code:
package
{
import flash.display.*;
import flash.events.*;
public class ScrollBar extends MovieClip
{
private var xOffset:Number;
private var xMin:Number;
private var xMax:Number;
public function ScrollBar():void
{
xMin = 0;
xMax = track.width - thumb.width;
thumb.addEventListener(MouseEvent.MOUSE_DOWN, thumbDown);
track.addEventListener(MouseEvent.MOUSE_DOWN, trackDown);
stage.addEventListener(MouseEvent.MOUSE_UP, thumbUp);
}
public function trackDown(e:MouseEvent):void
{
//stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
//yOffset = mouseY - thumb.y;
thumb.x = mouseX ;
if (thumb.x <= xMin)
{
thumb.x = xMin;
}
if (thumb.x >= xMax)
{
thumb.x = xMax;
}
dispatchEvent (new ScrollBarEvent(thumb.x / xMax));
}
private function thumbDown(e:MouseEvent):void
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
xOffset = mouseX - thumb.x;
}
private function thumbUp(e:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE, thumbMove);
}
private function thumbMove(e:MouseEvent):void
{
thumb.x = mouseX - xOffset;
if (thumb.x <= xMin)
{
thumb.x = xMin;
}
if (thumb.x >= xMax)
{
thumb.x = xMax;
}
dispatchEvent (new ScrollBarEvent(thumb.x / xMax));
e.updateAfterEvent();
}
}//end of class
}// End of package
ScrollBox Class
Code:
package
{
import flash.display.*;
import flash.events.*;
import caurina.transitions.*;
public class ScrollBox extends MovieClip
{
private var scrollBar:ScrollBar;
private var masker:Masker;
private var content:Content;
public function ScrollBox():void
{
scrollBar = new ScrollBar();
scrollBar.x = 100;
scrollBar.y = 50;
addChild(scrollBar);
scrollBar.addEventListener(ScrollBarEvent.VALUE_CHANGED, sbChange);
}
public function sbChange(e:ScrollBarEvent):void
{
Tweener.addTween(content, {x:(-e.scrollPercent*(content.width - masker.width)), time:1});
}
}//end of class
}// End of package
Scroll bar movie clip is in the library and contains two movieclips one with instance name thumb and another one with name track.
Can anyone please help I have really given up on this now Thanks in advance
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
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.
Cannot Access A Property Or Method Of A Null Object Reference.
The problem:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at badijalaShooter_fla::MainTimeline/badijalaShooter_fla::frame1()
here is the project
the code is in the first frame at as layer:
Code:
http://rapidshare.com/files/80311497/badijalaShooter.fla.html
Cannot Access A Property Or Method Of A Null Object Reference
I am getting this error:
Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Main$iinit()
I used the same code on another fla and it worked so it's the fla. I just don't know what it means.
The only difference I have on the non working fla is that the button is on frame 50 and the working fla is just 1 frame long.
Thanks a bunch!
Cannot Access A Property Or Method Of A Null Object Reference
Here's my problem.
I'm adding a movie clip via linkage to the stage through addchild.
the movieclip has a handful of labels along the time line all with different movieclips with which are to become clickable buttons and dynamic text fields which are to be filled.
HOWEVER!
When ever I tell the movie to gotoAndStop to the next required label, I then follow by telling it what all the buttons should do, and what should be in the text fields.
My problem is, the buttons and text fields are all :-
Quote:
TypeError: Error #1009: Cannot access a property or method of a null object reference
Basically - the code doesn't know they are there yet. A hack is to add an event listener that waits until the buttons are objects and then give them their functions. But this seems so uneccessary and cumbersome, if I have to do it for every label along the movie.
What am I missing? This is how the movieclip is being added:
public var highscores:MovieClip = new Highscores();
addChild(highscores);
highscores.x = 145;
highscores.y = -highscores.height;
Is their another way to target embedded movieclips along the timeline of an imported movieclip?
Is their a method I can pre-register the movieclips and text fields? without putting them all on the first frame of the imported movieclip?
Cannot Access A Property Or Method Of A Null Object Reference
Argh! I hate this Error! It doesn't tell me where it occurs, and it explains nothing!
I ran in debug through the entire code, the error happens only when after all of the code ran through. And then it tells me that it cannot display the source code at the locations which makes the Error!
Cannot access a property or method of a null object reference.
at main_fla::MainTimeline/main_fla::frame1()
What can cause the error? I don't remove any MC or anything like that..
Here's my code at frame1:
ActionScript Code:
import ns.Main;
var main:Main = new Main();
main.loadPage("main.swf");
addChild(main);
Cannot Access A Property Or Method Of A Null Object Reference
I keep getting this error "Cannot access a property or method of a null object reference." with the file I am working on. Trying to load images from an xml file onto the stage. Any help would be appreciated.
infoGraphicsLoader.addEventListener(Event.COMPLETE , processXMLInfoGraphics);
function processXMLInfoGraphics(e:Event):void {
infoGraphicsXML = new XML(e.target.data);
var imagesXML:XMLList = infoGraphicsXML.image;
trace(imagesXML[1]);
infoGraphic_btn.addEventListener(MouseEvent.MOUSE_ UP, testLoad);
function testLoad(e:MouseEvent):void {
var testLoader:Loader;
testLoader.load(new URLRequest(imagesXML[1].@src));
thumb1.addChild(testLoader);
}
}
Cannot Access A Property Or Method Of A Null Object Reference?
I'm confused at what is causing this error. My code seems to work for the first two links and then stops when it hits the third link.
I'm attempting to create a transition in effect for my links which can be easily achieved on the timeline but would like to understand how to do all of this through code.
The effect is just fade in each link one at a time while moving each link about 20 pixels higher while fading in.
ActionScript Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var home:Home_btn = new Home_btn();
addChild(home);
var about:About_btn = new About_btn();
addChild(about);
var register:Register_btn = new Register_btn();
addChild(register);
var schedule:Schedule_btn = new Schedule_btn();
addChild(schedule);
//setup link tween var
var homeAlpha:Tween;
var homeY:Tween;
var aboutAlpha:Tween;
var aboutY:Tween;
var registerAlpha:Tween;
var registerY:Tween;
var scheduleAlpha:Tween;
var scheduleY:Tween;
//set x values of links
home.x = 378;
about.x = 517;
register.x = 665;
schedule.x = 788.5;
//set link initial alpha to 0
home.alpha = 0;
about.alpha =0;
register.alpha =0;
schedule.alpha =0;
homeAlpha = new Tween(home, "alpha", Strong.easeOut, 0, 1, 1, true);
homeY = new Tween(home, "y", Strong.easeOut, 43, 37, 1, true);
homeY.addEventListener(TweenEvent.MOTION_FINISH, aboutStart);
function aboutStart(event:TweenEvent):void
{
aboutAlpha = new Tween(about, "alpha", Strong.easeOut, 0, 1, 1, true);
aboutY = new Tween(about, "y", Strong.easeOut, 43, 37, 1, true);
}
aboutY.addEventListener(TweenEvent.MOTION_FINISH, registerStart);
function registerStart(event:TweenEvent):void
{
registerAlpha = new Tween(register, "alpha", Strong.easeOut, 0, 1, 1, true);
registerY = new Tween(register, "y", Strong.easeOut, 43, 37, 1, true);
}
registerY.addEventListener(TweenEvent.MOTION_FINISH, scheduleStart);
function scheduleStart(event:TweenEvent):void
{
scheduleAlpha = new Tween(schedule, "alpha", Strong.easeOut, 0, 1, 1, true);
scheduleY = new Tween(schedule, "y", Strong.easeOut, 43, 37, 1, true);
}
Thanks!
Cannot Access A Property Or Method Of A Null Object Reference
Hi i have a game that stores information via the shared object type and i wish to check the user info at the very start of the game to see if the person has played before and if they have they will be shown there last scores. however i get the error "Cannot access a property or method of a null object reference." can any1 help me with this?
stop();
function stageOpen():void
{
if (localInfo.data.winScore == undefined || localInfo.data.lossScore == undefined || localInfo.data.user == undefined) {
gotoAndStop(2);
} else {
gotoAndStop(4);
}
}
stageOpen();
Cannot Access A Property Or Method Of A Null Object Reference
Hi All,
I´m stucked with "Cannot access a property or method of a null object reference"
I did a small test inside the IDE and it works fine
PHP Code:
var _container:Sprite;var holder:Sprite = new Sprite();addChild( holder ); PainelNumeros( holder );function PainelNumeros(mc:Sprite){ _container = new Sprite(); draw(); mc.addChild(_container);}function draw():void{ var origX = 23; var origY = 126.5; var deltaX = 24.5; var deltaY = 17.9; var larguraBox = 17.8; var alturaBox = 9.4; var posX = origX; var posY = origY; var elemento = 0; for (var i = 1; i <= 10; i++) { for (var j = 1; j <= 10; j++) { var nome = "numero" + elemento ; _container.addChild( new SpriteBox() ).name = nome; _container.getChildByName( nome ).x = posX; _container.getChildByName( nome ).y = posY; _container.getChildByName( nome ).width = larguraBox; _container.getChildByName( nome ).height = alturaBox; _container.getChildByName( nome ).alpha = 0.5; _container.getChildByName( nome ).addEventListener(MouseEvent.CLICK, mouseClickHandler); posX += deltaX; elemento++; } posX = origX; posY += deltaY; }}function mouseClickHandler(event:MouseEvent){ trace( event.target.parent.name );}................................................................package { import flash.display.*; import flash.events.*; public class SpriteBox extends Sprite { private var size:uint = 50 ; private var status:Boolean; private var bgColor:uint = 0xFFCC00; public function SpriteBox() { var child:Sprite = new Sprite(); status = false; draw(child); addChild(child); } private function draw(sprite:Sprite):void { sprite.graphics.beginFill(bgColor); sprite.graphics.drawRect(0, 0, size, size); sprite.graphics.endFill(); } }}
Then I tryed to translate what I got through the IDE to a new class
PHP Code:
package { import flash.display.*; import flash.events.*; public class PainelNumeros { private var _container:Sprite; public function PainelNumeros(mc:Sprite) { var _container:Sprite = new Sprite(); draw(); mc.addChild(_container); } private function draw():void { var origX = 23; var origY = 126.5; var deltaX = 24.5; var deltaY = 17.9; var larguraBox = 17.8; var alturaBox = 9.4; var posX = origX; var posY = origY; var elemento = 0; for (var i = 1; i <= 10; i++) { for (var j = 1; j <= 10; j++) { var marca:SpriteBox = new SpriteBox(); var nome = "numero" + elemento; _container.addChild( new SpriteBox() ).name = nome; _container.getChildByName( nome ).x = posX; _container.getChildByName( nome ).y = posY; _container.getChildByName( nome ).width = larguraBox; _container.getChildByName( nome ).height = alturaBox; _container.getChildByName( nome ).alpha = 0.5; _container.getChildByName(nome).addEventListener(MouseEvent.CLICK, mouseClickHandler); posX += deltaX; elemento++; } posX = origX; posY += deltaY; } } private function mouseClickHandler(event:MouseEvent) { trace( event.target.parent.name ); } }}
and tryed to instantiate it in the IDE
PHP Code:
var holder:Sprite = new Sprite();addChild( holder ) ; var painel1:PainelNumeros = new PainelNumeros ( holder ) ;
Where I get the error, what am I doing wrong ?
thanks in advance
jcarlos
Cannot Access A Property Or Method Of A Null Object Reference.
Why is it that ActionScript Code:
getChildByName("instance390").visible=false;
works and ActionScript Code:
getChildByName("Promotion1").visible=false;
give this error:
ActionScript Code:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at MethodInfo-98()
ActionScript Code:
getChildByName("Promotion1").visible=false;
works well in the FLA timeline. But not in the class. It's parent is the main timeline
Fla:
ActionScript Code:
import image.imageContainer;
var promoHolder:Array = new Array();
for (var i:int = 1; i < 5; i++) {
this['Promotion'+i] = new imageContainer("images/Promo"+i+".swf","loader.swf");
promoHolder[i] = this['Promotion'+i];
promoHolder.push(this['Promotion'+i]);
addChild(promoHolder[i]);
promoHolder[i].name = "Promotion" +i;
}
function test():void{
}
var Promotion1:MovieClip = MovieClip(getChildByName("Promotion1"));
var Promotion2:MovieClip = MovieClip(getChildByName("Promotion2"));
var Promotion3:MovieClip = MovieClip(getChildByName("Promotion3"));
var Promotion4:MovieClip = MovieClip(getChildByName("Promotion4"));
//Promotion1.visible=false;
Promotion2.visible=false;
Promotion3.visible=false;
Promotion4.visible=false;
Class:
ActionScript Code:
...
function handleClick(event:MouseEvent):void {
trace(event.currentTarget.name);
getChildByName("instance390").visible=false;
getChildByName("Promotion1").visible=false;
}
...
|