#1009: Cannot access... Sprite/Child... ???




I have button is scroolbar. I can link it with:

scrooll_mc.content_mc.five.addEventListener(MouseE vent.CLICK, clickFive);


function clickFive(evtObj:MouseEvent){
trace("uz triju bt")
gotoAndStop("antras");
}

But the problem comes when I go to link of that button and come back it doesnt work.

Flash gives an error:

#1009: Cannot access a property or method of a null object reference.
at bandymai_fla::MainTimeline/frame1()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at flash.display::Sprite/constructChildren()
at flash.display::Sprite()
at flash.display::MovieClip()
at bandymai_fla::scrollMkkkC_1()
at flash.display::MovieClip/gotoAndStop()
at bandymai_fla::MainTimeline/clickSection()

Im a little lost now, maybe anybody can help with that\t
Posted On: Thursday 25th of October 2012 09:51:10 PM Total Views:  432
View Complete with Replies

RELATED TOPICS OF Flash / ActionScript PROGRAMMING LANGUAGE




Error 1009 help

I need help with an 1009 that i can't solve by myself. If you could help i would be very happy. I have a main Game.as class, where i define the array enemies and a y.as class, where the problem is. The probelm when debugging is in the pointed line: ActionScript Code: public function targetNearby(e:Event) { >>for (var v:int = MovieClip(parent).enemies.length - 1; v >= 0 ; v--) { if (this.x + 250 > MovieClip(parent).enemies[v].x) { targetnearby = true; } else { targetnearby = false; } } } This makes me think it is because of enemies.length being null, but that is impossible in that situation... Any ideas
VIEWS ON THIS POST

132

Posted on:

Tuesday 16th October 2012
View Replies!

TypeError: Error #1009?

Alright so I'm working on making a skill calculator for this a game. This one I am working on right now has multiple skill calculators in a single flash file, but for some reason that I can't figure out, the skill calculator won't actually calculate. Here is a pastebin length to the AS code http://pastebin.com/xB6xzJFd Alright, I apoligize for its length, but I really have no idea what I'm doing wrong with this one. Here is the output: Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at allInOneCalc_fla::MainTimeline/changeCalc() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at fl.controls::ComboBox/onListChange() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at fl.controls::SelectableList/handleCellRendererClick() I get that error the second I select a calc and it goes to that frame, and when I input all the information it gives me a "0 and whatever text I had it add" for the answer. Please help, I've been stuck on this for a while. EDIT: I Believe I did the wrong type of event for lines 22, 25 but I'm still not sure with what type of event I should use. Any advice is greatly appreciated
VIEWS ON THIS POST

143

Posted on:

Tuesday 16th October 2012
View Replies!

error 1009 problem

i am new to flash and have no idea how to get around this problem. (i am using as3) I have added a gotoAndStop function on a symbol to take me back to frame 1 When i run the movie and click on this button i get this error TypeError: Error #1009: Cannot access a property or method of a null object reference. at housedesign1_fla::MainTimeline/frame1() at flash.display::MovieClip/gotoAndStop() at housedesign1_fla::MainTimeline/gohome() I have tried looking through forums to see if anything can help but i still don't have an idea about why this error is occuring. I have a few frames in between frame with function and the destination frame which have a symbol with a similar function. I copied the symbol and changed the instance name in each frame. This is the code for the function home_btn.addEventListener(MouseEvent.CLICK,gohome) ; function gohome(evt:MouseEvent): void { gotoAndStop(1); } I also get the error from the code i used to make text appear and disappear. The error occurs when i click on box1. Here is the code for this. txt1.visible=false box1.addEventListener(MouseEvent.MOUSE_OVER, showtxt); box1.addEventListener(MouseEvent.MOUSE_OUT, hidetxt); function showtxt(evt:MouseEvent): void { txt1.visible=true; } function hidetxt(evt:MouseEvent): void { txt1.visible=false; } box1.addEventListener(MouseEvent.CLICK, solarpage); function solarpage(evt:MouseEvent): void { gotoAndStop(16); } I get the same type of error for this too TypeError: Error #1009: Cannot access a property or method of a null object reference. at housedesign1_fla::MainTimeline/hidetxt() This is my guess as to where the error may be but im not sure. These two errors are not related to each other. If this code is of no use then i will put other parts up. I tried to attach the file but the file size was too big.
VIEWS ON THIS POST

141

Posted on:

Tuesday 16th October 2012
View Replies!

TypeError: #1009 Issues

Okay. I'm trying to make a popup alert modal window thing with an external class. I have a simple swf set up with just some random sample text, a rectangle, and a button (just so I can tell if it's working or not). What I want to happen is for the "alert" class to initialize upon startup of the swf and then when I click the button (instance: btn), the alert will show up. If I get rid of all AS in the swf and set alert as the document class, it shows up just fine, so I think it should be working, but for some reason I get this instead when I try the button function: TypeError: Error #1009: Cannot access a property or method of a null object reference. at alert$cinit() at global$init() at alertTester_fla::MainTimeline/frame1() Here's the code in my alertTester swf: Code: import alert; alert.msgAlert = "This is me testing stuff out."; btn.addEventListener(MouseEvent.CLICK, displayAlert); function displayAlert(e:MouseEvent):void { alert.showAlert(); } And here's the code in alert.as: Code: package { import flash.display.MovieClip; import flash.display.*; import flash.events.*; import flashx.textLayout.formats.Float; import flash.text.TextField; import flash.geom.Matrix; import flash.text.*; public class alert extends MovieClip { private static var stage:Stage = null; private static var bkgd:Sprite; private static var msgBox:Sprite; private static var msg:TextField; public static var msgAlert:String = "Test."; //for alert box itself public static var rectW:int = 200; public static var rectH:int = 150; private static var rectX:Number = (stage.stageWidth/2) - (rectW/2); private static var rectY:Number = (stage.stageHeight/2) - (rectH/2); public function alert() { addEventListener(Event.ADDED_TO_STAGE, added); } private function added(event:Event):void { init(stage); } private function init(stageRef:Stage):void { stage = stageRef; trace("Initialized!"); } public static function showAlert():void { if (stage == null) { trace("Alert class has not been initialized!"); return; } //initialize bkgd = new Sprite(); msgBox = new MovieClip(); msg = new TextField(); //assign content bkgd = createBkgd(); msgBox = createBox(); msgText(msgAlert); //add children msgBox.addChild(msg); bkgd.addChild(msgBox); stage.addChild(bkgd); } private static function createBkgd() : Sprite { //setup/initialize var overlay:Sprite = new Sprite(); //make rectangle/cover stage overlay.graphics.beginFill(0x929292); overlay.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight); overlay.graphics.endFill(); overlay.alpha = .85; //return return overlay; } private static function createBox() : Sprite { //setup/initialize necessary variables var box:Sprite = new Sprite(); var colors:Array = new Array(0xFFFFFF, 0xE1E1E1); var alphas:Array = new Array(1, 1); var ratios:Array = new Array(0,125); var mat:Matrix = new Matrix(); //make rectangle/alert box mat.createGradientBox(rectW,rectH,(Math.PI/2),rectX,rectY); box.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, mat); box.graphics.drawRoundRect(rectX,rectY,rectW,rectH,25,25); box.graphics.endFill(); //return return box; } private static function msgText(alertMsg:String):void { //create formatter and font var myFormat:TextFormat = new TextFormat(); var myFont = new Font(); //format formatter myFormat.size = 14; myFormat.align = TextFormatAlign.CENTER; myFormat.font = "Arial"; //declare and assign message variable var msgWords:String = alertMsg; //set text field properties msg.autoSize = TextFieldAutoSize.CENTER; msg.defaultTextFormat = myFormat; msg.background = false; msg.border = false; msg.selectable = false; msg.type = TextFieldType.DYNAMIC; msg.textColor = 0x000000; msg.antiAliasType = AntiAliasType.ADVANCED; msg.embedFonts = true; msg.text = msgWords; //set position msg.x = rectX + rectW/2 - msg.width/2; msg.y = rectY + rectH/5; } } } I originally had the "init" function as a public static function so I could do "alert.init(stage);" from the swf, but it gave me this same error.
VIEWS ON THIS POST

158

Posted on:

Tuesday 16th October 2012
View Replies!

Flashgame TypeError: Error #1009 AND howto stoptimer

, i'm making my first flash game but Ive run into some problems. Is there anyone here that can help Here is the game: http://www.2shared.com/file/gZfjkJFY/theGame.html Everytime I reach the next level I get this error: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Game_fla::MainTimeline/movecircle() I also want the timer to stop counting when I die or finnish. I've tried Code: if (platforms.currentFrame == platforms.totalFrames -1) { timer.stop(); } which didn't work.
VIEWS ON THIS POST

202

Posted on:

Tuesday 16th October 2012
View Replies!

CS4: Error #1009

I'm making an interactive video in Flash for a class. I'm having trouble when importing more than one video. Whenever I do, I get this error (Error #1099): Cannot access a property or method of a null object reference. This error occurs in Scene 3 specifically. I have tried re-importing the video, but that didn't fix it. Below is the ActionScript I'm attempting to use. ActionScript 3.0: Scene 1: stop(); /*tell both buttons to listen for a click and if there is a click, to perform a specific function*/ myPlayButton.addEventListener(MouseEvent.CLICK, StartMovie); myStopButton.addEventListener(MouseEvent.CLICK, StopMovie); mySkipButton.addEventListener(MouseEvent.CLICK, SkipMovie); //start the movie function StartMovie(evt:MouseEvent):void { forestIntro.play(); } //stop the movie function StopMovie(evt:MouseEvent):void { forestIntro.stop(); } //skip the movie function SkipMovie(evt:MouseEvent):void { gotoAndPlay(1,"Scene 2"); } Scene 2: stop(); myForestButton.addEventListener(MouseEvent.CLICK, SkipMovie2); function SkipMovie2(evt:MouseEvent):void { gotoAndPlay(1,"Scene 3"); } Scene 3: stop(); /*tell both buttons to listen for a click and if there is a click, to perform a specific function*/ myPlayButton2.addEventListener(MouseEvent.CLICK, StartMovie2); myStopButton2.addEventListener(MouseEvent.CLICK, StopMovie2); mySkipButton2.addEventListener(MouseEvent.CLICK, SkipMovie3); //start the movie function StartMovie2(evt:MouseEvent):void { forestIntro2.play(); } stop the movie function StopMovie2(evt:MouseEvent):void { forestIntro2.stop(); } //skip the movie function SkipMovie3(evt:MouseEvent):void { gotoAndPlay(1,"Scene 4"); }
VIEWS ON THIS POST

129

Posted on:

Thursday 18th October 2012
View Replies!

Error 1009 at MethodInfo-6

So I'm making a game and I keep getting this error; TypeError: Error #1009: Cannot access a property or method of a null object reference. at MethodInfo-6() And I'm really not sure why. Or what MethodInfo 6 is. If anyone would mind taking a look at what I have/have any ideas or advice I'd appreciate it forever! I uploaded the file here; this! Muchas Gracias!
VIEWS ON THIS POST

193

Posted on:

Thursday 18th October 2012
View Replies!

1009 Error, for no noticeable reason

I am a complete rookie when it comes to flash, but I have coded in many programming languages before this. The reason why I am so totally confused as to why this error is occurring, is simply because I didn't change any code to get this error. I was messing around with a glow filter, I test my game and BOOM. The infamous 1009 error apears when I test my little game. =[ I even pressed Ctrl + Z a million times to get back to a state where I knew my project worked, but I still get the same error. I get an output error of: "TypeError: Error #1009: Cannot access a property or method of a null object reference. at DocumentMain/enterFrameHandler()" Can anyone think of any quick fixes Thank you very much for any help. =] Here's my code - pastebin(D O T)com(S L A S H)DfN3h8ye
VIEWS ON THIS POST

184

Posted on:

Friday 19th October 2012
View Replies!

Between Errors 1009 and 1010

Obviously I have not assigned correct instances hence the errors though I spent hours reading the relevant posts. The problem seems to be that I don't know how to define the instance "shut" of close_btn inside the instance "popup1" of 01_mc_master. The line giving the error 1009 is: popup1.shut.close_btn.addEventListener(MouseEvent. CLICK, closebuttClick); and the 1010: popup1.close_btn.addEventListener(MouseEvent.CLICK , closebuttClick); Thank you for directing me here. Maciek
VIEWS ON THIS POST

183

Posted on:

Friday 19th October 2012
View Replies!

1009 error

I have just started action scripting......not doing very difficult stuff, just giving the navigation for an application.....got stuck and getting this error TypeError: Error #1009: Cannot access a property or method of a null object reference. at aug_19_2011_03_fla::MainTimeline/frame139() at flash.display::MovieClip/gotoAndPlay() at aug_19_2011_03_fla::MainTimeline/onloginclick() here is the entire code findmycar_btn.addEventListener(MouseEvent.CLICK,onf indmycarclick); locatedealer_btn.addEventListener(MouseEvent.CLICK ,onlocatedealerclick); mymazda_btn.addEventListener(MouseEvent.CLICK,onmy mazdaclick); maintenance_btn.addEventListener(MouseEvent.CLICK, onmaintenanceclick); service_btn.addEventListener(MouseEvent.CLICK,onse rviceclick); function onfindmycarclick(e:MouseEvent):void { gotoAndPlay("findmycar"); } function onlocatedealerclick(e:MouseEvent):void { gotoAndPlay("locatedealer"); } function onmymazdaclick(e:MouseEvent):void { gotoAndPlay("mymazda"); } function onmaintenanceclick(e:MouseEvent):void { gotoAndPlay("maintenance"); } function onserviceclick(e:MouseEvent):void { gotoAndPlay("service"); } offers_btn.addEventListener(MouseEvent.CLICK,onoff ersclick); function onoffersclick(e:MouseEvent):void { gotoAndPlay("offers") } recall_btn.addEventListener(MouseEvent.CLICK,onrec allclick); function onrecallclick(e:MouseEvent):void { gotoAndPlay("recall") } The moment i am adding recall button during the end i am getting this error..please help me to sort out this.
VIEWS ON THIS POST

196

Posted on:

Friday 19th October 2012
View Replies!

stage.stageWidth & Height not working: 1009

I've decided to start re-writing my project, but this time making the use of class files rather than nesting code inside my MovieClips. Now it's come to the "message box" that I previously wrote, and I'm having some troubles. (note: I don't really want to download a pre-built one as my message box class end up being the backbone for several custom interfaces). The problem is that I cannot, for the life of me, figure out why my message box class cannot access "stage.stageWidth", "stage.stageHeight", "MovieClip(root).currentWidth", etc. I'm rather hoping that someone will be able to shed some light on what I'm hoping is a novice error. (I'm very new to using class files.. as in.. this project new). This is the code for the working "messageBox.as": ActionScript Code: package com.components{ import flash.display.Shape; import flash.display.MovieClip; public class messageBox extends MovieClip { public function messageBox():void { drawBacking(); } public function drawBacking():void { var rectangle:Shape = new Shape ;// initializing the variable named rectangle rectangle.graphics.beginFill(0x000000); rectangle.graphics.drawRect(0, 0, 100, 100); rectangle.graphics.endFill(); rectangle.alpha=0.5; addChild(rectangle); } public function clear():void { var num:int = this.numChildren; for (var i:int=0; i
VIEWS ON THIS POST

210

Posted on:

Friday 19th October 2012
View Replies!

papervision3d typeerror error 1009

, I have following error when using papervision3d, setting "mouse3D.enabled = true;" in Lines3D typeerror error 1009 cannot access a property or method of a null object reference at org.papervision3d.core.utils::Mouse3D/updatePosition() at org.papervision3d.core.utils::InteractiveSceneMana ger/handleEnterFrame() Anyone know how to fix the problem.
VIEWS ON THIS POST

205

Posted on:

Friday 19th October 2012
View Replies!

CS3 TypeError #1009 when using a preloader

I keep getting the same error message ever since I tried adding a preloader. Everything seems to function properly, but obviously there's something wrong. Does anyone know how to fix this TypeError: Error #1009: Cannot access a property or method of a null object reference. at CaptainSUL_fla::MainTimeline/onProgress() heres my script: stop(); this.loaderInfo.addEventListener(ProgressEvent.PRO GRESS, 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; loaded_txt.text = "Loading..."+(Math.round(pct*100))+"%"; } function onComplete(e:Event):void { gotoAndStop("2"); }
VIEWS ON THIS POST

147

Posted on:

Wednesday 24th October 2012
View Replies!

Error 1009 Null object reference

Guys, So I embed a graphic, [Embed(source = "../../../_site/graphics/pinksquare.png", mimeType="application/octet-stream")] public var pub_graph1:Class; and then I reference it to render it as a bitmap. var var_bmpImage:BitmapData = (new pub_graph1() as Bitmap).bitmapData; this is where the problem lies. I can trace pub_graph1() right before this line of code and it comes back [class achieve_pub_graph1] I can't figure out what is causing this error. Any Ideas
VIEWS ON THIS POST

144

Posted on:

Thursday 25th October 2012
View Replies!

TypeError: Error #1009: Cannot access a property or method of a null object reference

Just starting to delve into as3. I have made a flash website with four navigation buttons (home, products, about, contact). When user clicks on "products", an external movie clip is loaded and everything works fine. User clicks any button after that, and myLoader.unloadAndStop, the swf is removed when you navigate away from "products". However, if the "home", "about", or "contact" buttons are clicked first (before the external swf has been loaded), it of course, throws the 1009 error. I need some sort of if/else statement to check whether or not the external swf is loaded, remove it if it is, and if not, just navigate to the "page" clicked. buttons code: home_mc.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler); home_mc.buttonMode = true; home_mc.useHandCursor = true; function fl_MouseClickHandler(event:MouseEvent):void { myLoader.unloadAndStop(); gotoAndStop("home"); } products_mc.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler2); products_mc.buttonMode = true; products_mc.useHandCursor = true; function fl_MouseClickHandler2(event:MouseEvent):void { gotoAndStop("products"); } about_mc.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler3); about_mc.buttonMode = true; about_mc.useHandCursor = true; function fl_MouseClickHandler3(event:MouseEvent):void { myLoader.unloadAndStop(); gotoAndStop("about"); } contact_mc.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler4); contact_mc.buttonMode = true; contact_mc.useHandCursor = true; function fl_MouseClickHandler4(event:MouseEvent):void { myLoader.unloadAndStop(); gotoAndStop("contact"); } "products" code: var myLoader:Loader = new Loader(); var url:URLRequest = new URLRequest("newTees/newTees.swf"); myLoader.load(url); addChild(myLoader); myLoader.x = 262; myLoader.y = 150;
VIEWS ON THIS POST

131

Posted on:

Thursday 25th October 2012
View Replies!

TypeError: Error #1009

Hi - This error occurs whenever I return to a particular frame that contains the following AS... import fl.controls.UIScrollBar; my_text.addEventListener(Event.SCROLL,updateScroll Bar); function updateScrollBar(evt:Event):void{ my_scroll.update(); } var req:URLRequest = new URLRequest("external.txt"); var loader:URLLoader = new URLLoader(); function fileLoaded(event:Event):void { my_text.text = loader.data; } loader.addEventListener(Event.COMPLETE, fileLoaded); loader.load(req); This is the first frame of the movie that contains a dynamic text control that is loaded with the contents of an external text file. There is no problem when it first loads, the error occurs when I return to this frame from another one. I suspect the problem is with the addEventListener but I do not know how to handle this. Please help
VIEWS ON THIS POST

158

Posted on:

Thursday 25th October 2012
View Replies!

Preloader pops TypeError: Error #1009:

Hi to you all. I've made preloaders in the past, but now I'm getting this error, and I don't know what is exactly the problem. TypeError: Error #1009: Cannot access a property or method of a null object reference at com.mugui::Footer() If I erase all references of the footer from my Main Class the flash works normal. So the problem comes from my footer, but why. My main class: Code: public class MuguiMain extends MovieClip { private var contentHolder:Sprite = new Sprite; private var mainContent:MainContent = new MainContent(); private var footer:Footer = new Footer(); private var loader:Loader; private var swfContent:MovieClip; private var swfContentHolder:Sprite = new Sprite(); public function MuguiMain():void { this.addEventListener(Event.ENTER_FRAME, preload); } public function preload (e:Event):void { var total:Number = this.stage.loaderInfo.bytesTotal; var loaded:Number = this.stage.loaderInfo.bytesLoaded; loaderText.text = Math.floor((loaded/total)*100) + "%"; if(total == loaded) { gotoAndStop("ini"); this.removeEventListener(Event.ENTER_FRAME, preload); MuguiIni(); } } public function MuguiIni():void { addEventListener("clickCatalogo", clickCatalogo,false,0,true); addEventListener("clickClose", unLoadSwf,false,0,true); addEventListener("clickInicio", clickInicio,false,0,true); addEventListener("clickQuienes", clickQuienes,false,0,true); addChild(contentHolder); contentHolder.addChild(mainContent); contentHolder.addChild(footer); } My footer class: Code: public function Footer():void { this.x = 1000; this.y = 432; catalogoBtn.addEventListener(MouseEvent.CLICK, clickCatalogo,false,0,true); TweenMax.to(this,2,{x:523, ease:Expo.easeOut}); catalogoBtn.buttonMode = true; } public function clickCatalogo(e:MouseEvent):void { dispatchEvent(new Event("clickCatalogo",true)); } } } Hope anyone can spot the problem. Thank in advance for any hint on this issue. Greetings.
VIEWS ON THIS POST

129

Posted on:

Thursday 25th October 2012
View Replies!

TypeError: #1009 Issues

Okay. I'm trying to make a popup alert modal window thing with an external class. I have a simple swf set up with just some random sample text, a rectangle, and a button (just so I can tell if it's working or not). What I want to happen is for the "alert" class to initialize upon startup of the swf and then when I click the button (instance: btn), the alert will show up. If I get rid of all AS in the swf and set alert as the document class, it shows up just fine, so I think it should be working, but for some reason I get this instead when I try the button function: TypeError: Error #1009: Cannot access a property or method of a null object reference. at alert$cinit() at global$init() at alertTester_fla::MainTimeline/frame1() Here's the cote in my alertTester swf: Code: import alert; alert.msgAlert = "This is me testing stuff out."; btn.addEventListener(MouseEvent.CLICK, displayAlert); function displayAlert(e:MouseEvent):void { alert.showAlert(); } And here's the code in alert.as: Code: package { import flash.display.MovieClip; import flash.display.*; import flash.events.*; import flashx.textLayout.formats.Float; import flash.text.TextField; import flash.geom.Matrix; import flash.text.*; public class alert extends MovieClip { private static var stage:Stage = null; private static var bkgd:Sprite; private static var msgBox:Sprite; private static var msg:TextField; public static var msgAlert:String = "Test."; //for alert box itself public static var rectW:int = 200; public static var rectH:int = 150; private static var rectX:Number = (stage.stageWidth/2) - (rectW/2); private static var rectY:Number = (stage.stageHeight/2) - (rectH/2); public function alert() { addEventListener(Event.ADDED_TO_STAGE, added); } private function added(event:Event):void { init(stage); } private function init(stageRef:Stage):void { stage = stageRef; trace("Initialized!"); } public static function showAlert():void { if (stage == null) { trace("Alert class has not been initialized!"); return; } //initialize bkgd = new Sprite(); msgBox = new MovieClip(); msg = new TextField(); //assign content bkgd = createBkgd(); msgBox = createBox(); msgText(msgAlert); //add children msgBox.addChild(msg); bkgd.addChild(msgBox); stage.addChild(bkgd); } private static function createBkgd() : Sprite { //setup/initialize var overlay:Sprite = new Sprite(); //make rectangle/cover stage overlay.graphics.beginFill(0x929292); overlay.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight); overlay.graphics.endFill(); overlay.alpha = .85; //return return overlay; } private static function createBox() : Sprite { //setup/initialize necessary variables var box:Sprite = new Sprite(); var colors:Array = new Array(0xFFFFFF, 0xE1E1E1); var alphas:Array = new Array(1, 1); var ratios:Array = new Array(0,125); var mat:Matrix = new Matrix(); //make rectangle/alert box mat.createGradientBox(rectW,rectH,(Math.PI/2),rectX,rectY); box.graphics.beginGradientFill(GradientType.LINEAR, colors, alphas, ratios, mat); box.graphics.drawRoundRect(rectX,rectY,rectW,rectH,25,25); box.graphics.endFill(); //return return box; } private static function msgText(alertMsg:String):void { //create formatter and font var myFormat:TextFormat = new TextFormat(); var myFont = new Font(); //format formatter myFormat.size = 14; myFormat.align = TextFormatAlign.CENTER; myFormat.font = "Arial"; //declare and assign message variable var msgWords:String = alertMsg; //set text field properties msg.autoSize = TextFieldAutoSize.CENTER; msg.defaultTextFormat = myFormat; msg.background = false; msg.border = false; msg.selectable = false; msg.type = TextFieldType.DYNAMIC; msg.textColor = 0x000000; msg.antiAliasType = AntiAliasType.ADVANCED; msg.embedFonts = true; msg.text = msgWords; //set position msg.x = rectX + rectW/2 - msg.width/2; msg.y = rectY + rectH/5; } } } I originally had the "init" function as a public static function so I could do "alert.init(stage);" from the swf, but it gave me this same error.
VIEWS ON THIS POST

427

Posted on:

Thursday 25th October 2012
View Replies!

Flash Error #1009: Cannot access a property or method of a null object reference.

I dont understand these errors or how to fix them. Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Function/Levels/$construct/createLvl()[C:\Users\Owner\Desktop\Flash AS3\Platform Game\Classes\Levels.as:54] at Levels()[C:\Users\Owner\Desktop\Flash AS3\Platform Game\Classes\Levels.as:95] at DocumentClass()[C:\Users\Owner\Desktop\Flash AS3\Platform Game\Classes\DocumentClass.as:23] DocumentClass: Code: package { import flash.display.MovieClip; import flash.ui.Keyboard; import flash.events.KeyboardEvent; import flash.events.Event; import flash.utils.Timer; import flash.events.TimerEvent; import Classes.Levels public class DocumentClass extends MovieClip { public var gameTimer:Timer; private var LevelActionScript; public var character:Character; public function DocumentClass() { character = new Character(); addChild( character ); LevelActionScript = new Levels(); LevelActionScript.Levels(); /*gameTimer = new Timer(500); gameTimer.addEventListener( TimerEvent.TIMER, CharacterMovement ); gameTimer.start(); }*/ var leftKeyDown:Boolean = false; var upKeyDown:Boolean = false; var rightKeyDown:Boolean = false; var downKeyDown:Boolean = false; var mainSpeed:Number = 7; var mainJumping:Boolean = false; var jumpSpeedLimit:int = 15; var jumpSpeed:Number = jumpSpeedLimit; character .addEventListener(Event.ENTER_FRAME, moveChar); function moveChar(event:Event):void { if (leftKeyDown) { character.x -= mainSpeed; } if (rightKeyDown) { character.x += mainSpeed; } if (upKeyDown || mainJumping) { mainJump(); } } stage.addEventListener(KeyboardEvent.KEY_DOWN, checkKeysDown); function checkKeysDown(event:KeyboardEvent):void { if (event.keyCode == 37 || event.keyCode == 65) { leftKeyDown = true; } if (event.keyCode == 38 || event.keyCode == 87) { upKeyDown = true; } if (event.keyCode == 39 || event.keyCode == 68) { rightKeyDown = true; } if (event.keyCode == 40 || event.keyCode == 83) { downKeyDown = true; } } stage.addEventListener(KeyboardEvent.KEY_UP, checkKeysUp); function checkKeysUp(event:KeyboardEvent):void { if (event.keyCode == 37 || event.keyCode == 65) { leftKeyDown = false; } if (event.keyCode == 38 || event.keyCode == 87) { upKeyDown = false; } if (event.keyCode == 39 || event.keyCode == 68) { rightKeyDown = false; } if (event.keyCode == 40 || event.keyCode == 83) { downKeyDown = false; } } function mainJump():void { if (! mainJumping) { mainJumping = true; jumpSpeed = jumpSpeedLimit * -1; character.y += jumpSpeed; } else { if (jumpSpeed < 0) { jumpSpeed *= 1 - jumpSpeedLimit / 75; if (jumpSpeed > - jumpSpeedLimit / 5) { jumpSpeed *= -1; } } if (jumpSpeed > 0 && jumpSpeed = stage.stageHeight - character .height) { mainJumping = false; character.y = stage.stageHeight - character.height; } } } } } } Levels: Code: package { import flash.display.Sprite; import flash.display.MovieClip; public class Levels extends MovieClip { public var character:Character; //LEVEL VARIABLES //the current lvl var lvlCurrent:int = 1; /*The key for the level arrays: 1: Regular Block X: Main Character */ //this variable will hold the character var X:String = 'MAIN'; //the array for level 1 var lvlArray1:Array = new Array( 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,X,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ); public function Levels() { character = new Character(); //creating the level //this guy will hold all of the blocks var blockHolder:Sprite = new Sprite(); //then we add him to stage //current row that we are creating var row:int = 0; addChild(blockHolder); function createLvl():void { //getting the current level that we are on var lvlArray:Array = MovieClip(root)['lvlArray' + lvlCurrent]; //we have to find how far this level goes //this will be used so we know when to move to the next row //there will always be 16 rows, so this is how we find it out //of course, this will make the lvl formatting very strict var lvlColumns:int = Math.ceil(lvlArray.length / 16); //now we must create the level for (var i:int = 0; i
VIEWS ON THIS POST

384

Posted on:

Thursday 25th October 2012
View Replies!

Flash Error #1009: Get On the....Stage!

Greetings and Salutations Everyone! Can someone please help me resolve this issue I keep getting the same error("TypeError: Error #1009: Cannot access a property or method of a null object reference. at FullFla$iinit()") -I gather that I am attempting to call an object that is not presently on the stage, BUT I am unclear exactly what steps to take to correct it...Add a wrapper DisplayObject or do I change an the Event that I am listening for\t Please give me some guidance. I appreciate it immensely. package { import flash.display.StageAlign; import flash.display.StageScaleMode; import flash.display.Sprite; import flash.display.MovieClip; import flash.display.Loader; import flash.net.URLRequest; import flash.events.MouseEvent; import flash.events.Event; public class FullFla extends Sprite { private var _loading:Loading; private var _navi:Navi; private var menuList:Array = ["home", "about", "work"]; private var _menus:Array = new Array(); private var _pages:Array = new Array(); private var _urlNo:uint = 0; private var _currentMenu:MovieClip; private var _currentPage:Sprite; public function FullFla() { stage.align = StageAlign.TOP_LEFT; stage.scaleMode = StageScaleMode.NO_SCALE; _loading = new Loading(); _navi = new Navi(); for (var i:int=0; i < menuList.length; i++) { var mc:MovieClip = _navi[menuList[i]]; _menus.push(mc); mc.redpoint.visible = false; } resizeHandler(); stage.addEventListener(Event.RESIZE, resizeHandler); addChild(_loading); addChild(_navi); loadSwf(); } private function loadSwf():void { var url:String = menuList[_urlNo] + ".swf"; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, completeHandler); var req:URLRequest = new URLRequest(url); loader.load(req); } private function completeHandler(e:Event):void { _pages.push(e.target.content); if(_urlNo < menuList.length - 1 ) { _urlNo++; loadSwf(); } else { removeChild(_loading); _loading = null; startPage(); } } private function startPage():void { for (var i:int = 0; i < _menus.length; i++ ) { var mc:MovieClip = _menus[i]; mc.page = _pages[i]; mc.buttonMode = true; mc.addEventListener(MouseEvent.CLICK, clickHandler); } _currentMenu = _menus[0]; displayPage(); } private function displayPage():void { _currentMenu.redpoint.visible = true; _currentPage = _currentMenu.page; resizeHandler(); addChild(_currentPage); } private function clickHandler(e:MouseEvent): void { _currentMenu.redpoint.visible = false; removeChild(_currentPage); _currentMenu = e.target as MovieClip; displayPage(); } private function resizeHandler(e:Event = null):void { var w:Number = stage.stageWidth; var h:Number = stage.stageHeight; if (Boolean(_loading)) { _loading.x = w / 2; _loading.y = h / 2; } _navi.y = h; _navi.bar.width = w; _navi.logo.x = w - 10; if(Boolean(_currentPage)) { _currentPage.x = w / 2; _currentPage.y = h / 2; } } } } m
VIEWS ON THIS POST

354

Posted on:

Thursday 25th October 2012
View Replies!