SEARCH YOUR SOLUTION HERE  

Null object error when adding sounds?

right. So I'm creating a flash game with AS3 but I'm having some issues with sounds. Usually, when there is not much action around, sounds play just fine and all. But when it starts getting ugly with explosions everywhere and stuff, I start getting this every now and then:
Code: TypeError: Error #1009: Cannot access a property or method of a null object reference. at Main/sounds() at Mob/dmgHealth() at Mob/loop() This is the sound function on Main :
Code: public function sounds(soundType:String="default"){ var mySound:Sound; var rand:int; if(soundType=="armor"){ rand=Math.floor(Math.random()*3+1); if(rand==1){ mySound=new ArmorSound1(); }else if(rand==2){ mySound=new ArmorSound2(); }else if(rand==3){ mySound=new ArmorSound3(); } soundFXChannel=mySound.play(); soundFXTransform.volume=0.2; soundFXChannel.soundTransform=soundFXTransform; } if(soundType=="sword"){ rand=Math.floor(Math.random()*3+1); if(rand==1){ mySound=new SwordSound1(); }else if(rand==2){ mySound=new SwordSound2(); }else if(rand==3){ mySound=new SwordSound3(); } soundFXChannel=mySound.play(); soundFXTransform.volume=0.4; soundFXChannel.soundTransform=soundFXTransform; } if(soundType=="crush"){ rand=Math.floor(Math.random()*3+1); if(rand==1){ mySound=new CrushSound1(); }else if(rand==2){ mySound=new CrushSound2(); }else if(rand==3){ mySound=new CrushSound3(); } soundFXChannel=mySound.play(); soundFXTransform.volume=0.5; soundFXChannel.soundTransform=soundFXTransform; } if(soundType=="lightning"){ rand=Math.floor(Math.random()*1+1); if(rand==1){ mySound=new LightningSound1(); } soundFXChannel=mySound.play(); soundFXTransform.volume=0.6; soundFXChannel.soundTransform=soundFXTransform; } if(soundType=="explosion"){ rand=Math.floor(Math.random()*1+1); if(rand==1){ mySound=new ExplosionSound1(); } soundFXChannel=mySound.play(); soundFXTransform.volume=0.6; soundFXChannel.soundTransform=soundFXTransform; } if(soundType=="hurt"){ rand=Math.floor(Math.random()*1+1); if(rand==1){ mySound=new HurtSound1(); } soundFXChannel=mySound.play(); soundFXTransform.volume=0.4; soundFXChannel.soundTransform=soundFXTransform; } }
I did all my imports, all my vars are set at the beginning of the class, the sounds in the library got all their classes right (I checked a few times to see if the names were the same) and the bug don't always shows up, only when there is a lot of sounds at the same time.

I also noticed that when I comment the "Crush" part of the code, the error shows up less often. Also the other functions under the sounds one in the error are irrelevant, as they always change.

Is this just because I push flash way too far with sounds

Posted On: Friday 19th of October 2012 03:28:27 AM Total Views:  96
View Complete with Replies




Related Messages:

Cannot access a property or method of a null object reference.   (62 Views)
HI , my as3 code was working perfectly, however I restructured my folders and now my .fla is in the /src/ with my MainApp.as ( Document class ) then MainApp creates a new instance of a class that is in /src/blah/blah/deep/ When this new as class is created it has a few buttons on it that are declared in the .fla as instance variables. I have turned off automatically declare stage instances. and declare it in my class like so Code: public var mInstBtnPlay:SimpleButton; // my constructor public function MainMenuScreen_mc() { trace( "MainMenuScreen_mc::MainMenuScreen_mc()" ); // listen for button pressed mInstBtnPlay.addEventListener(MouseEvent.CLICK, OnPlay, false, 0, true ); } The .addEventListener gives the error as it obviously thinks my mInstBtnPlay is null, but it is not null it is created in the .fla Any ideas , or where have I gone wrong p.s. as I said this was working before I restructured the folders and imports to compensate
Class instance returns null value   (53 Views)
all, I'm currently stumped by this. I've created a class to load xml data from a txt file, then assign that xml to a variable named siteStructureXml. When I trace the value of siteStructureXml from within the class instance it shows the expected xml data. When I try to assign the value to a variable returnedXml defined on the timeline of my movie, it's value traces as null. I've a feeling it's something blindingly obvious... The class is written as follows: package uk.co.wearerevolting.initialisation { import flash.display.MovieClip import flash.events.Event import flash.net.URLLoader import flash.net.URLRequest public class XmlToVariableSetter extends flash.display.MovieClip { private var requestXmlUrl:URLRequest; private var xmlFileLoader:URLLoader; private var loadedXmlString:String; public var siteStructureXml:XML; public function XmlToVariableSetter() { } public function loadXml():XML { requestXmlUrl = new URLRequest("site_structure.xml"); xmlFileLoader = new URLLoader(requestXmlUrl); xmlFileLoader.addEventListener(Event.COMPLETE, assignXmlToVariable); trace("loadXml value" + siteStructureXml); return siteStructureXml; } public function assignXmlToVariable(event:Event):XML { loadedXmlString = xmlFileLoader.data; siteStructureXml = XML(loadedXmlString); trace("assign xml variable" + siteStructureXml); return siteStructureXml; } } } The code on the timeline is: import uk.co.wearerevolting.initialisation.* var xmlSetter:XmlToVariableSetter = new XmlToVariableSetter(); var returnedXml:XML; xmlSetter.loadXml(); returnedXml = xmlSetter.siteStructureXml; trace(returnedXml); Many
declaring un-instantiated class makes stage=null. MOST bizzare   (129 Views)
In my document class I have this PHP Code: var__w:Who; trace(stage);//null but if I comment out the var I get this PHP Code: //var__w:Who; trace(stage);//[objectStage] It does not matter where I declare the var __w:Who in the constructor, as a class var or in another function entirely. The whole thing still operates normally but it's irritating not being able to set my stage.align=StageAlign.TOP_LEFT; in the constructor.... I am guessing it is something in my Who class because it does not happen if I declare any other vars the constructor in Who pretty basic: PHP Code: publicfunctionWho():void /*CONSTRUCTOR*/ { varu:URLLoader;/*loadxmlortitlelinks*/ u=newURLLoader(); u.load(newURLRequest('XML/Who.xml')); u.addEventListener(Event.COMPLETE,PX); th=newSprite(); addChild(th); } I'm open to any suggestions on this.... Something obvious I'm missing
help w/ a null error   (89 Views)
greetings, another newbie question... I am trying to use a drag n drop function to place a word in a correct spot. once the word is dragged to this spot I want the movie to go to the "correct" frame. it works, but I get this error message about "void and null" here's the code Code: if (Ego.hitTestObject(hitSpot)) { gotoAndPlay("egoCorrect"); Ego is the MC I'm dragginghitSpot is the area I'm dragging it tooegoCorrect is where it's supposed to goto once the collision happen
TypeError: #1009 null object reference and a loader   (109 Views)
I'm having some trouble with the stage in AS3 when loading a swf into another swf. I have a loader swf loading a swf with a document class which imports a few other classes. A sample from one of those imported classes follows: Code: // constructor function ModelInfo() { if (!allowInstantiation) { throw new Error("Error: Instantiation failed: Use ModelInfo.getInstance() instead of new."); } else { createMouseOverHeading(); createMouseOverSubHeading(); createMouseOverDetails(); } } public static function getInstance(input:Stage):ModelInfo { if (instance == null) { myStage = input; allowInstantiation = true; instance = new ModelInfo(); allowInstantiation = false; } return instance; } As soon as the progress handler traces that the loader has loaded the entire swf (but before the init handler gets executed) I receive 1009 null object reference errors everywhere the stage is accessed. Now.. unfortunately, general confusion does not make for a very good question...so, Should the "addchild" for the loaded swf be on on the loader's onComplete handler, or somewhere else I've read about "ADDED_TO_STAGE" in several places, but how can I incorporate this into the above code Should the swf that is loaded compile properly on it's own to work with the loader Can anyone refer a good article that explains the problem I'm having I've already tried several and I'm not confident that I understand it.
Flash getChildByName return null if publis setting is Flash 9   (103 Views)
I am facing a weird problem. The following code returns null if targeted player is Flash player 9 but works fine for Flash Player 10. PHP Code: var_mc:MovieClip=getChildByName("introMC")asMovieClip; It works fine if I give a delay using setTimeout. I am not sure what I may be doing wrong. I have attached the source files. (Flash CS5 format)
Parameter child must be non-null   (72 Views)
can someone help me please i have an external class that creates an instance named mc. then mc.addEventListener(MouseEvent.MOUSE_DOWN, drag); in function drag, if i try: addChild(mc); it works fine but when i try: addChild(e.target as MovieClip); i get the error Parameter child must be non-null
setting up site buttons / null object reference   (109 Views)
I'm currently trying to build my first flash site.. I have just set up the buttons which get to each 'section' via frame labels and the AS3 gotoAndStop function. These work without error until my 'sections' contain movieclips that are referenced in my actionscript layer... Because they do not exist in 'all frames', whenever I click my buttons I get the error, "Error #1009: Cannot access a property or method of a null object reference." It took me a while to understand and track down why I was getting this. I removed the short bit of code in my actionscripts layer that referenced the movieclips in each section (I had some custom scrollbars set up) and it worked without error. How do I get around this
TypeError: Error #2007: Parameter type must be non-null.   (82 Views)
It's monday morning and somehow my brain won't comprehend why this error is happening...... could anyone take a look and shed some light on this please TypeError: Error #2007: Parameter type must be non-null. at flash.events::EventDispatcher/addEventListener() at pages::MyProfile/initListeners() at pages::MyProfile() here is my code ActionScript Code: package business.types { import flash.events.Event; /** * @author Erik */ public class ServerConnectionEvent extends Event { public static const AUTHENTICATION_BY_ACCOUNT_COMPLETE : String = "authentication_by_account_complete"; public static const AUTHENTICATION_BY_ACCOUNT_FAIL : String = "authentication_by_account_fail"; public static const AUTHENTICATION_BY_COOKIE_COMPLETE : String = "authentication_by_cookie_complete"; public static const AUTHENTICATION_BY_COOKIE_FAIL : String = "authentication_by_cookie_fail"; public static const LOGOUT_COMPLETE : String = "logout_complete"; public static const LOGOUT_FAIL : String = "logout_fail"; public static const REGISTRATION_COMPLETE : String = "registration_complete"; public static const REGISTRATION_FAIL : String = "registration_fail"; public static const PROFILE_RETRIEVE_COMPLETE : String = "profile_retrieve_complete"; public static const PROFILE_RETRIEVE_FAIL : String = "profile_retrieve_fail"; public var isSuccess : Boolean; public var data : Object; public function ServerConnectionEvent ( type : String, isSuccess : Boolean = true, data : Object = null ) { super( type ); this.isSuccess = isSuccess; this.data = data; } } } This is the other class, which is using this custom Event: ActionScript Code: private function onGetProfileComplete ( lObj : Object ) : void { trace( "business.ServerConnection.onGetProfileComplet e(" + [ lObj ] + ")" ); dispatchEvent( new ServerConnectionEvent( ServerConnectionEvent.PROFILE_RETRIEVE_COMPLETE, true , lObj ) ); } And this is the method where the error is thrown: ActionScript Code: private function initListeners () : void { trace( "pages.MyProfile.initListeners(" + [] + ")" ); ServerConnection.getInstance( ).addEventListener( ServerConnectionEvent.PROFILE_RETRIEVE_COMPLETE , onProfileDownloadComplete ); ServerConnection.getInstance( ).addEventListener( ServerConnectionEvent.PROFILE_RETRIEVE_FAIL , onProfileDownloadFail ); } private function onProfileDownloadComplete ( pEvt : ServerConnectionEvent ) : void { trace( "pages.MyProfile.onProfileDownloadComplete(" + [ pEvt ] + ")" ); var lData : Object = pEvt.data; } private function onProfileDownloadFail ( pEvt : ServerConnectionEvent ) : void { trace( "pages.MyProfile.onProfileDownloadFail(" + [] + ")" ); }
LoaderInfo url as null for too long   (77 Views)
I have a class that loads a handful of external swfs, and a preloader class to handle them all as a single object. I was having some strange problems with the loading process and tried tracing the urls to see which file was bugging. For my surprise, almost all loaderInfo objects reported theirs url as null. With a bit of testing I came to the conclusion that they only report some url when the file is almost completely loaded. The docs say something about "possibly wrong urls" before progress events, but that would be in cases where redirect happen, and everything here is local with simulate download option. Also, "event.target.url" inside the very progress event handler reports null unless the target's loading is almost done. Unfortunately I don't have any piece of code with less than a hundred lines to show. But is there any undocumented behavior, known bug or common coding error that generates such situation
AS3: conditional statement to determine if an xml child is null... help!   (111 Views)
With this code, I need to determine if the xml child is null and form a conditional statement upon that info. I have it very close but something is just "un-tweeked" enough that it wont work correctly. AS3 and XML provided below...
having trouble setting things to null   (188 Views)
I can trace it: Code: trace(thumbArray[i].getChildAt(6).name); //output: tmbLoader but if I try this: Code: thumbArray[i].getChildByName("tmbLoader") = null; I get an error: ActionScript Error #1105: Target of assignment must be a reference value.
TypeError: Error #2007: Parameter text must be non-null. AS3 and PHP   (88 Views)
, Im very new to flash and im trying to send a contact form. Ive modified a template that was working originally... using flash cs4, actionscript 3 and php This is the error I'm getting Code: TypeError: Error #2007: Parameter text must be non-null. at flash.text::TextField/set text() at moviebak_fla::contactus_12/completeHandler() at flash.events::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at flash.net::URLLoader/onComplete() Thisis the AS3 Code: // Set text formatting colors for errors, waiting..., and success mechanisms var errorsFormat:TextFormat = new TextFormat(); errorsFormat.color = 0xFF0000; var waitingFormat:TextFormat = new TextFormat(); waitingFormat.color = 0x339900; var successFormat:TextFormat = new TextFormat(); successFormat.color = 0x3366FF; // hide the little processing movieclip processing_mc.visible = false; // Assign a variable name for our URLVariables object var variables:URLVariables = new URLVariables(); // Build the varSend variable var varSend:URLRequest = new URLRequest("http://stevechaffins.com/form.php"); varSend.method = URLRequestMethod.POST; varSend.data = variables; // Build the varLoader variable var varLoader:URLLoader = new URLLoader; varLoader.dataFormat = URLLoaderDataFormat.VARIABLES; varLoader.addEventListener(Event.COMPLETE, completeHandler); // Handler for PHP script completion and return function completeHandler(event:Event):void { // remove processing movieclip processing_mc.visible = false; // Clear the form fields theName.text = ""; theEmail.text = ""; theHome.text = ""; theCity.text = ""; theState.text = ""; theZip.text = ""; thePhone.text = ""; theSubject.text = ""; theMessage.text = ""; // Load the response from the PHP file status_txt.text = event.target.data.return_msg; status_txt.setTextFormat(successFormat); } // Add an event listener for the submit button and what function to run submit_btn.addEventListener(MouseEvent.CLICK, ValidateAndSend); // Validate form fields and send the variables when submit button is clicked function ValidateAndSend(event:MouseEvent):void{ //validate form fields if(!theName.length) { status_txt.text = "Please enter your name."; status_txt.setTextFormat(errorsFormat); } else if(!theEmail.length) { status_txt.text = "Please enter an email address"; status_txt.setTextFormat(errorsFormat); } else if(!validateEmail(theEmail.text)) { status_txt.text = "Please enter a VALID email address"; status_txt.setTextFormat(errorsFormat); } else if(!theMessage.length) { status_txt.text = "Please enter a message."; status_txt.setTextFormat(errorsFormat); } else { // is good so send the message to the parse file // Show the little "processing_mc" movieclip processing_mc.visible = true; // Ready the variables for sending variables.userName = theName.text; variables.userEmail = theEmail.text; variables.userHome = theHome.text; variables.userCity = theCity.text; variables.userState = theState.text; variables.userZip = theZip.text; variables.userPhone = thePhone.text; variables.userSubject = theSubject; variables.userMessage = theMessage.text; // Send the data to the php file varLoader.load(varSend); // Put a temporary message in the response field while the PHP file sends back // If the code does not connect to the PHP file this message will remain visible to user status_txt.text = "Waiting for server connection..."; status_txt.setTextFormat(waitingFormat); } // close else after form validation } // Close ValidateAndSend function ////////////////////////////////////////////////////////////// // Validate email function function validateEmail(str:String):Boolean { var pattern:RegExp = /(\w|[_.\-])+@((\w|-)+\.)+\w{2,4}+/; var result:Object = pattern.exec(str); if(result == null) { return false; } return true; } //////////////////////////////////// and my php.. PHP Code: as i said im very new so please excuse me if ive left anything important out...
function default arguments = null   (81 Views)
I've been searching for this all over the net to no avail; Hope someone points me in the right direction. Let's say I have a function like this which purpose is to tween a glow filter: Code: public function glow(glowDuration:Number = -1,glowColor:uint=null){ I am omitting a lot of stuff from the actual function for the purposes of demonstration. Now before you all go "you can't assign null to a uint", I know I can't. Please bear with me until the end of this post. Ok, so in the function, I then check for values: Code: if(glowDuration!=-1){duration=glowDuration} if(glowColor!=null){color=glowColor} //then I go on using the values I need customTweenEngine.tween("blur",duration,color,blah,blah) "color" is a global variable in my class that can be set either at construction, or after, or in this function. I want my tween class to be flexible and so, i want to user to be able to set "color" anytime. So the function could be used: Code: var fx:FX = new FX(0xFF0000) fx.glow() //OR var fx:FX = new FX() fx.color = 0xFF0000 fx.glow() //OR var fx:FX = new FX() fx.glow(0xFF0000) //OR EVEN var fx:Fx = new FX(0xFF0000) fx.glow(0x99CCEE) My problem is: You cannot assign null to a uint. At the same time, I cannot check for (if glowColor!=0), because the user might want to set it to 0 (black); I cannot also just assign glowColor to color without checking, because if the user provided no data, "color" should remain unchanged. For now, I reverted to: Code: public function glow(glowDuration:Number=-1,glowColor:*=null){ if(glowColor!=null)(color = uint(glowColor) Which works, but isn't satisfying for three reasons: 1) The user can provide any datatype and that ain't "clean" 2) I will have to have loads of those, and I worry about optimization (flash gurus correct me if I am wrong, but typed data is faster than untyped, right) 3) My anal instincts itch when I look at "glowColor:*". I shouldn't have to use *! And while I am at it, I have the exact same problem with booleans. I need to have (glowInner:Boolean = null), because I want to check if the user provided a value (true or false) before changing the global "inner". If i find some answers I'll post them here. If the way I am thinking is utterly stupid please don't hesitate to point it out.
Error #2007: Parameter text must be non-null   (171 Views)
this may be somehow a common error, but I couldn't track down where is the problem. I'm getting the following error trying to use a code to randomly pick a quote from a xml file. The flash/code works fine, however in IE eventually the error shows up which is really annoying. In Firefox it seems like everything is working fine. The error is: TypeError: Error #2007: Parameter text must be non-null. at flash.text::TextField/set text() at quotes_fla::MainTimeline/rotateQuote() at flash.utils::Timer/flash.utils:Timer::_timerDispatch() at flash.utils::Timer/flash.utils:Timer::tick() Code: import caurina.transitions.Tweener; var quote:Array = new Array(); var totalQuotes:Number; quoteMC.alpha = 0; var rotateTimer:Timer = new Timer(5000, 100);//rotates the quote every 2 seconds for 100 times rotateTimer.addEventListener("timer", rotateQuote);//add a listener to the timer rotateTimer.start();// start the timer function init():void { var quotesXML:XML = new XML(); quotesXML.ignoreWhitespace = true; var XMLURL:URLRequest = new URLRequest("flash/quotes1.xml"); var myLoader:URLLoader = new URLLoader(XMLURL); myLoader.addEventListener("complete", xmlLoaded); function xmlLoaded(event:Event):void { quotesXML = XML(myLoader.data); totalQuotes = quotesXML.quote.length(); for (var i:int = 0; i < quotesXML.quote.length(); i++) { quote[i] = quotesXML.quote[i].text; } var initRandom:Number = randomNumber(0, totalQuotes); Tweener.addTween(quoteMC, {alpha:1, time:5}); quoteMC.quote_txt.text = String(quote[initRandom]); } } function rotateQuote(evt:TimerEvent) { quoteMC.alpha = 0; Tweener.addTween(quoteMC, {alpha:1, time:5}); quoteMC.quote_txt.text = ""; var randomness:Number = randomNumber(0, totalQuotes); quoteMC.quote_txt.text = quote[randomness]; } function randomNumber(low:Number, high:Number):Number { var low:Number = low; var high:Number = high; return Math.round(Math.random() * high - low) + low; } init(); I'm totally new at as3 so any help will be welcome.
Please PLease help [TypeError: Error #1009: null object reference]   (104 Views)
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 = 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 = 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
Cannot access a property or method of a null object reference   (207 Views)
Hi , Im 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;varholder:Sprite=newSprite();addChild(holder);PainelNumeros(holder);functionPainelNumeros(mc:Sprite){_container=newSprite();draw();mc.addChild(_container);}functiondraw():void{varorigX=23;varorigY=126.5;vardeltaX=24.5;vardeltaY=17.9;varlarguraBox=17.8;varalturaBox=9.4;varposX=origX;varposY=origY;varelemento=0;for(vari=1;i
timestamp function call while loading xml file produces a null object reference error   (227 Views)
all, I'm trying to add timestamp to the xml file address if the swf wil be loaded from the web server but it gives me a null object reference error depending on if there is timestamp() function call or not. Here's my code that doesn't work as I was expectin: ActionScript Code: //... public function init():void { try{ xmlLoader = new URLLoader(); xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioError); xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded); trace("Class LoadXML/ address: "+address); xmlLoader.load(new URLRequest(address+timestamp())); }catch(e:Error){ _error = String(e); trace("Class LoadXML/ catch error: "+e); this.dispatchEvent(new Event("XML.ERROR")); } } private function timestamp():String{ return stage.loaderInfo.url.indexOf("http") == 0 "t=" + new Date().time : ""; } private function ioError(e:IOErrorEvent):void { _error = String(e); trace("Class LoadXML/ io error: "+e) this.dispatchEvent(new Event("XML.ERROR")); } private function xmlLoaded(e:Event):void { xmlData = new XML(e.target.data); this.dispatchEvent(new Event("XML.COMPLETE")); } //... When I called my LoadXML Class 3 times it outputs 3 times: Code: Class LoadXML/ address: start.xml Class LoadXML/ catch error: TypeError: Error #1009: Cannot access a property or method of a null object reference. Class LoadXML/ address: play.xml Class LoadXML/ catch error: TypeError: Error #1009: Cannot access a property or method of a null object reference. Class LoadXML/ address: end.xml Class LoadXML/ catch error: TypeError: Error #1009: Cannot access a property or method of a null object reference. I copied the tricky part from abeall: http://www.actionscript.org/forums/s...724#post971724 When I load just addresses without the timestamp xmlLoader.load(new URLRequest(address)); it outputs everything I was already expecting when the timsetamp function call where involved, (as I was testing some considerable errors). Code: Class LoadXML/ address: start.xml Class LoadXML/ address: play.xml Class LoadXML/ address: end.xml Class LoadXML/ io error: [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: file:///E|/flash/as3/projectName/lib/work/end.xml"] Thank you in advance.
Unable to load images in an array; null child   (66 Views)
, What I'm trying to do is to create a class loading three images as a pile into a movie clip and be able to switch from one image to another (with a fade effect) thanks to a method (setPic). The problem I have is when I want to store my loaded image into my array ( magnitude[i-1] = loader.content; ) it doesn't load anything, provoking the addchild(magnitude[i-1]); to return a null error. I know the file is properly loaded because if I addchild(loader.content) directly it does load the image (but I can't store it and access it later obviously). Any help would be much appreciated. ActionScript Code: package { import flash.net.URLLoader; import flash.net.URLRequest; import flash.net.URLRequestHeader; import flash.events.Event; import flash.events.IOErrorEvent; import flash.display.MovieClip; import fl.transitions.Tween; import fl.transitions.easing.*; import flash.display.Loader; import flash.display.Bitmap; public class ThumbClass extends MovieClip { public var numLevels:int = 3; public var currStatus:int = 3; public var magnitude:Array = new Array; public function ThumbClass(floor:int, zone:int) { var i:int; var loader:Loader=new Loader(); for (i=1; i
Are Object variables null if Object is null?   (62 Views)
If I set an Object = null, does that remove all references to the Object's variables assuming there are no external references to said variables Or do I have to manually set all said variables = null Thank you in advance for your time.