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\] at Levels()[C:\Users\Owner\Desktop\Flash AS3\Platform Game\Classes\] at DocumentClass()[C:\Users\Owner\Desktop\Flash AS3\Platform Game\Classes\] DocumentClass:
Code: package { import flash.display.MovieClip; import flash.ui.Keyboard; import; import; import flash.utils.Timer; import; 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

Posted On: Thursday 25th of October 2012 09:37:42 PM Total Views:  287
View Complete with Replies

Related Messages:

Web page within flash   (110 Views)
I've been looking around like a forensic scientist piecing together information for my latest project. Basically I need to display a particular webpage within my flash file... Now I know flash can display simple HTML, but nothing complex and nothing from an external source... BUT I know flash can also handle PHP - obviously. The page I need to load is a wordpress website, a combination of PHP codes and simple HTML snippets... but what I couldn't find was a way of inserting the snippets into a control box or movieclip on my page (actually run the PHP code to fetch HTML snippets) I hope it's possible!! (although it's seeming less and less likely the more I read up)
Shared object using a flash server   (113 Views)
At the moment I'm developing something in which I need to have a server of some sort store and send Shared Objects. When I was looking into it the API said that you would use something like a flash media server. Well the student price for that is about 1300$ so I can't do that. Is there a way for me to create a server in actionscript using socket connections (or something). To send and receive shared objects I haven't started on this yet I'm just looking ahead into what I'm going to need.
Editing flash application text content. Best way?   (175 Views)
, I'm creating a Flash presentation, and the user wants to be able to change the text on any screen from Flash itself. This was my original my idea (I don't have much experience in AS): 1 - Put all the text in a text file (XML or plain). 2 - Make AS read the text and fill in the text fields in the Flash presentation. 3 - When it's needed to change the text content, execute the Flash presentation with a parameter that will tell AS to show all the fields as INPUT. 4 - Save the new text in the text file via PHP. But I have been asked if it would be possible to avoid the use of a text file (and the server connection with PHP) and change the swf text content directly with AS. Is this possible I have been googling it but with no success. I have the idea that this wouldn't be possible but i don't know all the possibilites in the Flash environment.
build a scroll bar by action script in flash   (132 Views)
I would like to produce a fitting room system, and the users can adjust doll's size. In terms of shoulder, hip, and the length of both legs and arms by a horizontal scroll bar in this system. How could I control Action Script by Flash Please kindly share your experiences and opinions with us,
Linking external SWFs to the main flash file, Error 1120   (122 Views)
Please can someone help me with fixing this problem: I have made a menu bar and linked each separate swf file to the corresponding button. Upon testing my main movie, all the text on the main page is disappearing, the new swf file is not loading and the message 1120 error appears for all my buttons. I have checked the instance names and they match along with publish settings and folder settings. I cant understand why its not working Hope someone can help. Error: Scene 1, Layer 'Actions', Frame 1, Line 25 1120: Access of undefined property portfolio_btn. Code: var Xpos:Number = 180; var Ypos:Number = 200; var swf:MovieClip; var loader:Loader = new Loader(); var defaultSWF:URLRequest = new URLRequest("swfs/biography.swf"); loader.load(defaultSWF); loader.x = Xpos; loader.y = Ypos; addChild(loader); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Btns Universal function function btnClick(event:MouseEvent):void { removeChild(loader); var newSWFRequest:URLRequest = new URLRequest("swfs/" + + ".swf"); loader.load(newSWFRequest); loader.x = Xpos; loader.y = Ypos; addChild(loader); } // Btn listeners Biography_btn.addEventListener(MouseEvent.CLICK,bt nClick); portfolio_btn.addEventListener(MouseEvent.CLICK, btnClick); news_btn.addEventListener(MouseEvent.CLICK,btnClic k); gallery_btn.addEventListener(MouseEvent.CLICK,btnC lick); merchandise_btn.addEventListener(MouseEvent.CLICK, btnClick);
can I use mx.core.UIcomponent in flash   (127 Views)
I know it is intended for flex ... but what does that mean ... can I use it in flash ... if not, why not ... but more importantly: all of the mx classes, spark classes, flashx classes ... why are they NOT for flash pixels are pixels, matrices are matrices, 0's are 0's, 1's are 1's.
Limit flash loop to 30s   (128 Views)
actionscript users, I have a flash banner exactly like this one on a continuous loop. Does anyone know how can I stop the loop at the 30s mark That's one of the adwords requirements for flash banners. Thank you.
redirect browser from flash amfphp   (137 Views)
, I am currently developing an application in flash. In this application user will be able to buy in-game currency using real life money. For this purpose we have some external actors. In our case, it is hipay. Now, once a user clicks on a particular button, as3 will use amfphp to call a php file that eventually will do this: header("Location: ".$url) ; Once this happens I get an error in my flash: Error: Request for resource at by requestor from denied due to lack of policy file permissions Connection to halted not permitted from *** Security Sandbo Violation *** Warning: failed to load policyfile from Now, is this a problem on my side or hipay's side. If it is the latter I'm screwed I guess and have to find another solution. Can anyone help me with this
Help creating a flash slideshow galary to show videos   (157 Views)
I am relatively new at using flash but need to create a flash slideshow galary to show videos. I found the link below and it is exactly how I want it to be shown and created. If anyone has any ideas of where I need to start to get this implemented I will be extremely grateful. Many
I need flash canvas menu ...   (181 Views)
.. I need an flash canvas menu, written in AS3... In any shape, any type, it doesn't matter... Please help...
flash chart   (148 Views)
hi , can any one tell, how to develop flash charts (eg. pie charts) only with as3 and without using any components
mouse cursor changes in flash apps   (137 Views)
i have a flash loader thats loads many flash swf games, the problem is that the mouse corsair turns to the game's corsair and we trying to keep our original corsair. help will be appreciated.
flash projector files and multiple swfs?   (118 Views)
I have a project with many swf files loading dynamically. When I export my .app projector file only the main swf appears. Can you project multiple swf files into a .app or .exe file do the swf files have to be within same directory of the projector files any help would be appreciated.
Flash how to ipad flash app save data   (99 Views)
I'm planning to build an ipad flash game and would like to save some information, like user info like name and unlocked levels. How can i do that
How can I make my flash website to view it in FULL SCREEN MODE?   (182 Views)
How can I make my flash website to view it in FULL SCREEN MODE as in the following website Please do help.
passing keystrokes from air browser to flash game   (122 Views)
Here's my situation - I am accessing some games that my company built using a AIR browser (allowing us to sell an installable product on a CD, but keeping the content online for ease of maintenance). I can get the games to load, but i cant get them to accept keystrokes, ie: we have a tetris-like game that isnt getting any of the arrow key inputs. I'm fairly certain this has something to do with a focus issue, but I have no idea how to fix it. Any suggestions would be welcome.
Can flash load in SWCs at runtime?   (127 Views)
Beginners Intro to SWC files SWCs are ZIP archives with two files in them: catalog.xml - Lists all classes contained in the SWC along with their dependencies.library.swf - Contains all the actual classes So theoretically... It should be possible to load in SWC files at run time and use the classes from them, right You may have to unzip it first and extract out the SWF, but this arduous process could be made easier with a few helper classes. In fact, having the "catalog.xml" there may also make it easier to identify which classes are contained within (which means you don't need to guess or assume which classes are in it). Has anyone tried this yet or know of anyone else who has I searched Google for a bit, but most results actually were actually mislabeled, and loading the SWC in at compile time. I found nothing relevant, so asking here is much easier.
Help Me! - Imbedded a SWF file into flash but doesn't go away when you click out   (126 Views)
, I have inserted a scrolling gallery into my website but now whenever I click on the portfolio section that brings up the gallery I can't click out. The buttons are still there, but whenever you click another button it overlays the text and other images I put in them overtop the gallery scroll. How do I get this galleryscroll to stop being an attention-addict! Code for buttons - stop(); function goHome (e:MouseEvent):void{ gotoAndStop("Home"); } home_btn.addEventListener(MouseEvent.CLICK, goHome); function goAbout (e:MouseEvent):void{ gotoAndStop("About"); } about_btn.addEventListener(MouseEvent.CLICK, goAbout); function goLinks (e:MouseEvent):void{ gotoAndStop("Links"); } links_btn.addEventListener(MouseEvent.CLICK, goLinks); function goContact (e:MouseEvent):void{ gotoAndStop("Contact"); } contact_btn.addEventListener(MouseEvent.CLICK, goContact); code to bring scroll in - stop(); var myLoader:Loader = new Loader(); addChild(myLoader); var url:URLRequest = new URLRequest("galleryscroll.swf"); myLoader.load(url); code of the gallery scroll herself - import mx.transitions.Tween; import mx.transitions.easing.*; this.createEmptyMovieClip("container",1); var imagesNumber:Number = 6; var scrolling:Boolean = true; for (i=1; i0) { this._x = 0; } if (-this._x>(this._width-Stage.width)) { this._x = -(this._width-Stage.width); } }; for (i=1; i
Photo template in flash 3   (114 Views)
! this is the actionscript of a photo template that i found in Flash 3. The problem is that I've tried to copy the frames to another flash file and now it doesn;t work propeply. These are the errors: 1023: Incompatible override. 1021: Duplicate function definition. I'm a beginner and dont know how to fix shall i do it function updateFrame (inc) { // send slides to new frame newFrame = _root._currentFrame + inc; _root.gotoAndStop(newFrame); updateStatus(); if (_root._currentFrame == 1) { prevBtn.gotoAndStop(2); } else { prevBtn.gotoAndStop(1); } if (_root._currentFrame == _root._totalFrames) { nextBtn.gotoAndStop(2); } else { nextBtn.gotoAndStop(1); } } function updateStatus () { _root.statusField = _root._currentFrame + " of " + _root._totalFrames; } function autoplayInit () { startTime = getTimer(); hideControls(); updateStatus(); } function autoplay () { if (autoplayStatus != 0) { // get the current time and elapsed time curTime = getTimer(); elapsedTime = curTime-startTime; // update timer indicator indicatorFrame = int(4/(delay/(elapsedTime/1000))); indicator.gotoAndStop(indicatorFrame+1); // if delay time if met, goto next photo if (elapsedTime >= (delay*1000)) { if (_root._currentframe == _root._totalframes) { _root.gotoAndStop(1); } else { _root.nextFrame(); } autoplayInit(); } } } function hideControls () { nextBtn.gotoAndStop(2); prevBtn.gotoAndStop(2); } updateFrame(); autoplayStatus = 0;
Flash flash cs3 list box, look and feel urgently required   (135 Views)
Friends, I need a small help from you . I want to display a list box in a diferent way. I have uploaded the image as well ie what exactly am looking for and how the list box has to look. pls refer my attachment. i am parsing the xml data and it's coming fine in list box. but my reqmnt is the look n feel of list box, can u pls help me out. flash code : var xmlLoader:URLLoader = new URLLoader(); var xmlData:XML = new XML(); xmlLoader.addEventListener(Event.COMPLETE, LoadXML); xmlLoader.load(new URLRequest("news1.xml")); function LoadXML(e:Event):void { xmlData = new XML(; ParseNews(xmlData); } function ParseNews(xml:XML):void { var config:XMLList = xml.item.title; for each (var Title:XML in config) { my_lst.addItem({label:Title, data:Title}); } } xml data : Cameras PlP Add A Call Layout Participants waiting for your replies rajesh