ActionScript 3.0 :: Removing Eventlistener From Deleted Instance?
Jan 18, 2010
in my main I have a system that allowed certain classes to be loaded and unloaded. When I load Game.as, it contains a trace statement when you press the left arrow key. When I remove the game instance from the stage, and set it to null, I can still press left arrow key, and the trace will come up. If I then make a new instance of game, it traces twice with only 1 click. When I close/load another time it traces three times.
I very specifically set:
Code:
mainContent.removeChild(game);
game = null;
Even trace statements confirmed that the game was being nullified, and the trace still continued.
I have an on enter frame listener defined in a function: Code: function sideClicked(e:MouseEvent):void { removeEventListener(Event.ENTER_FRAME, loop); var targetName=e.target.name; var a:Array=[];[Code] .....
The looptoposition() function simple calls a function from a custom class repetitively to move an object until it reaches its position. This is the function it calls from the included custom class: Code: public function rotateToPos(a:Number,b:Number,c:Number):void { if(!cubeReady){return;} if(cube.rotationY<b){ cube.rotationY+=3; [Code] .....
This gets the desired result visually - the cube rotates until the chosen point and then stops - however the listener continues. I have two problems: 1) I would like to remove the listener but can't seem to do so from the imported class - I'm having trouble referencing my functions in the root flash file. 2) I also need to declare that the function has completed - but the equalities mean that b is either greater or less than but never equal to? Whats a better way of getting the cube to rotate to a set position on each frame? The reason for the equalities are the cube can turn two different directions. So rotation could be negative.
I have an event listener on my main timeline and I have an mc with some AS which sits on the main timeline. I was just wondering if the following code is correct if I wanted to remove the event listener on the maintimeline from the AS written in the mc.
I have a navigation button that loads an external SWF. In this loaded SWF are more buttons (two, to be specific). Right now the goal of these buttons are just to take you to external URLs, but eventually I may want to control the timeline of the loaded SWF with them.
I have successfully loaded the SWF, but I am having trouble getting the buttons in the SWF to work. I have given each button an instance name, but I cannot add an EventListener to either of them. I can add an EventListener to the loaded SWF, but that doesn't really help me.
function pressWebNav(event:MouseEvent):void { var webStuff:Loader = new Loader(); webStuff.contentLoaderInfo.addEventListener(Event. COMPLETE, finished_loading);
[code]....
As you can see, my button pWebNav loads the SWF called webPortfolio.swf. When the SWF is done loading I am making the content of the SWF a MovieClip instead of a DisplayObject. I remove the EventListener that detects when it's done loading, assign it an x and y possition, and then add it to the stage.My troubles start when I go to add an EventListener to an instance in the loaded SWF. My thinking is because I've cast the SWF as a MovieClip, I can then access the instances within it. Obviously, that's not the case.
I selected all my stuffs & make them into a symbol and when i break the symbol up all the instance name was removed. Is there a way to break up the symbol without removing the instance name?
is there a way to remove a video instance from the stage with an 'if statement"? Kind of like :next1_btn.addEventListener(MouseEvent.CLICK, ongoPage2); function ongoPage2(Event:MouseEvent):void {
I am trying to make the instance 'red' be removed when all 3 objects have hit it here is my code:
var hit = 0; addEventListener(Event.ENTER_FRAME, hittest); function hittest(e:Event){ addChild(blue);addChild(green); addChild(pink); addChild(red); [Code] .....
Alright, so really I am having 2 difficulties here.
1) When a bullet hits an enemy, if 2 zombies are beside eachother, the bullet hits them both -- How can I make it so the bullet can only hit one?
2) When an enemy has health of 0, it dies, I am trying to get the enemy to be removed from the array that the bullet searches through so it will no longer be affected by the enemy, but it doesnt seem to work, the bullet still hits where the enemy was, as if the enemy is invisible.
Does creating a new instance of an Object that uses an identical name to an older instance, delete the previous instance? Or should the original instance be deleted first? The code uses a ridiculous amount of XML vars. Isn't it less memory intensive to parse the XML and save the properties to an Object, and then delete the XML Object, rather than keep the XML Object around and reference it's child nodes directly? Is it better form to break up a huge XML file (>600lines/3200vars) into smaller chunks?
I was sorting my symbols in my library moving them to folders and what not and then saved it, did some more drawing etc. Then tested movie and noticed that all my symbols are gone on my timeline, also noticed whenever there is a tween the symbol got deleted from that to. I was so pissed, I undo'd as far as I could go and it wasn't enoughI have ALL my symbols in my library, just ALL of them got removed from my timeline... there is a lot of them.
I was sorting my symbols in my library moving them to folders and what not and then saved it, did some more drawing etc. Then tested movie and noticed that all my symbols are gone on my timeline, also noticed whenever there is a tween the symbol got deleted from that to. I was so pissed, I undo'd as far as I could go and it wasn't enough -_-
I have ALL my symbols in my library, just ALL of them got removed from my timeline... there is a lot of them.
I am doing a small test with arrays. I have 5 purple movie clips, their instance names are: p1,p2,p3,p4,p5.
I have declared an empty array called purple. On press of each mc I want the particular mc to be added to the array, and on press again I want the particular mc to be deleted from the array.
However, this does not work, it seems to be deleting the lastly added mc name from the array no matter of which mc I unpress.
I am new with arrays, I am using pop and push. I will upload my file. Could someone have a look at it please? Is there another array command to add and delete the particular mc which is presses and unpressed, and not the one that was last added to the array?
- listener added with weak refference, therefore it shouldn't keep the GC away
- object set to null
- trace of the object m shows null
- debugger shows the value of m as null
But the "frame" trace still keeps on appearing, so where exactly is that object and how to check for it, how to delete it and kill it. I know that listeners keep objects in the memory, but then how to find them, and at the end of the day also used weakReference=true while assigning it, so that should take care of it. What exactly is going on here?
I created a empty folder on my desktop "Test" and then in the create a new project thing I linked it to the test folder, and then in the settings I clicked on delete project folder and it gave me two options and by mistake I selected the second one and then my worst nightmare, all my multimedia files which were on my desktop got deleted. I tried running 5-6 data recover softwares but none of them and I mean none of them found the files deleted by flash. All were showing me the files those were deleted by Shift+Delete, but that I dont want. How can I get those files which were deleted by flash cs5.
We area trying to create a virtual world application. We are using hitTest to make the avatar enter the room. That hitTest event is inside an onEnterFrame event of the avatar so every time the avatar is on the stage it runs the function and detects if it hits the hot spot or not.
So onEnterFrame we have: (shortURL is a variable that points to the movieClip) Code: Select allif(this.hitTest(shortURL.detectRoom1)){ attachDialogue(1, "room.swf"); }
[Code].....
The code works, however when the user clicks on no, the dialogueBox still appears since the avatar still hits the room's hotspot. If I remove the commented "delete attachDialogue" clicking the no button will remove the dialogueBox movieclip without any problems. However when the avatar walks on other hotspots it doesn't call the function again.
Are there other ways how we can remove the movieclip and set the attachCounter to 0 when the no button is clicked? Or how can we reuse a deleted function?
If I delete the "onEnterFrame" with this code: myClip.onEnterFrame=function(){ ____if (this._x<300) this._x+=5; ____else delete this.onEnterFrame; ____// to erase it, but you can simply empty it ____// else this.onEnterFrame=null; } How can I turn it on again?
I want to draw lines to make a region so that anything inside that region is deleted. The Case : You could say that there are many movieclips in stage but when I just selected by drawing circle or something even complex shape to it purposely then anything inside that shape is just gone.
I have this little crumby thing I'm working on. And in it, I draw a circle with a radial gradient fill. Then I add that circle to the array: "colourSplodeArray"
I have another circle that bounces around and hits walls, "creating" the previously mentioned circles. (So I have one that is not in the array, the rest are)[code]...
I created an input text box, and depending on what the user enters, it will create a file with that same name. However, for some reason, it's deleting the last character of the filename when it creates the file. For example, if you type "House" in the input text box, then the file that it will create will say "Hous.txt"What is causing this and how can it be fixed?
I was working on a large web site in Flash CS 5.5 on my hard drive Mac Pro V10.6.8, 6GB of memory. 176.78 GB of space left on the drive. I had set up the project in the Flash projects panel. I was opening files with"File open" and working on them. I have my fla files in a src folder and my classes in a com folder. This was the setup of my com folder.
I was working in Flash and it crashed, when it started up again. It didn't offer me a temp file and all the files in the com folder have been deleted except for the greensock folder. But even the greensock folder was missing files.
I went to the recent files when I click a file name I got this error. I have searched my hard drive by name for the files and can't find them. They are not in the Trash. I have talked to three different Adobe tech support people in India they all tell me the files can't be recovered and they don't know why it has happened and don't even seem to care that their program has deleted hours of work. I am waiting on yet another tech support person to call me back. Does anyone know why this has happened? I have been working in Flash for 11 years and never had it delete 186 files when it has crashed.
I was working on a large website in Flash CS 5.5 on my hard drive Mac Pro V10.6.8, 6GB of memory. 176.78 GB of space left on the drive. I had set up the project in the Flash projects panel. I was opening files with"File open" and working on them. I have my fla files in a src folder and my classes in a com folder. This was the setup of my com folder. I was working in Flash and it crashed, when it started up again. It didn't offer me a temp file and all the files in the com folder have been deleted except for the greensock folder. But even the greensock folder was missing files. I went to the recent files when I click a file name I got this error.
I have searched my hard drive by name for the files and can't find them. They are not in the Trash. I have talked to three different Adobe tech support people in India they all tell me the files can't be recovered and they don't know why it has happened and don't even seem to care that their program has deleted hours of work. I am waiting on yet another tech support person to call me back. Does anyone know why this has happened? I have been working in Flash for 11 years and never had it delete 186 files when it has crashed.