ActionScript 3.0 :: Remove All The MCs As They All Get The Same Instance Name For Every New Mc Attached
Jan 6, 2012I'm creating a highscore list like this:
[Code]...
I'm creating a highscore list like this:
[Code]...
I just moved to AS3 and I learnt how to attach a movieclip.
ActionScript Code:
var attachedMC = new (getDefinitionByName(PageName) as Class)();
holder.addChild(attachedMC);
Where PageName is the string containing the Class of the movieclip in the library and holder is the instance name of the MC to be attached to.
But what instance name do I use to refer to the movieclip that got attached?
In AS2, the code would have gone like this
ActionScript Code:
holder.attachMovie(PageName, "instanceName", 1);
The instance name part of the code seems to be missing in AS3. SO how do I refer the the attached MC or "child"?
In the code I am working on I am attaching MCs to other MCs. However, when I remove the second MC the first one gets removed too. HexStore contains a load of game hex MCs. LastLocation is the last hex MC clicked. myBrigade is the extra MC that needs to be removed from the LastLocation MC.[code]...
View 4 RepliesThis is just an example.. however i am trying to attach a M.C to attachHere. This is fine. However the following code is thn meant to remove 2 of the attached M.C's but i dont know how to reference it so that it removes the clips that are attached to attachHere...it works fine if i just attach the M.c's to the stage...
[Code]...
how would i go about writing a function that looks at an mc(empty mc) and deletes any attached movie clips (if there are any).
View 12 RepliesI have a movie called "my.fla" in which I attach some MC's.I also have buttons that load swf's in a "container".But when I test the buttons,the attached MC's in "my.fla" keep appearing before the swf loads.I tried EVERYTHING with removeMovieClip,but I can't get it to work(The swf's I load also have attachMovie in them)
Code:
MovieClip.prototype.attach = function(base) {
base["content"+nr].attachMovie("shirt_"+nr, "clip"+nr, nr);
if (nr == tot) {[code]....
I have a small problem over here. I've attach an MC with attachMovie() and the instance names that were inside of that MC disappeared.
Code:
getWinLogin.onRelease = function() {
zona.createEmptyMovieClip("winLogin", getNextHighestDepth());
[code]....
I copied this code from the web that creates snow and I have this code on frame 100. I want to remove this movie clip when it starts back again on frame 1.
[Code]...
I have a mc in the library, linkage is "del". Here is the code I use to attach to the movie
Code:
delbt.onPress = function () {
if (typeof(_root.del) == undefined) {
_root.attachMovie ("dele", "del", _root.getNextHighestDepth ());
_root['del']._x = 100;
_root['del']._y = 100;
[Code] .....
This works fine to a point. In the "del" mc I have a button to remove "del" mc if no longer required.
Code:
on (release) {
unloadMovie(_root.del)
}
I discovered that this only remove the content and not the mc that holds it "del". So I tried
Code:
on (release) {
_root.del.removeMovieClip ();
}
But this does nothing.
Is it possible to remove an MC from an MC if its not even attached to the stage?
View 11 RepliesHow would I go about writing a function that looks at an mc (empty mc) and deletes any attached movie clips (if there are any).
View 11 RepliesI have 25 instances of a movieclip "star", duplicated and assigned variables using the following code:
Code:
for(n = 0; n < 25; n++) {
star.duplicateMovieClip("star"+n, n+1000);
with(eval("star"+n)) {
startype = random(3);
}};
I now have it so that when I click on any instance of "star", I'm taken to another frame, and in that frame I'd like to be able to look up the variable "startype" for that particular instance only. How exactly can I do this?
I need to remove some movieclips that are attached dynamically so they do not show up underneath the new movieclips that will be attached when a user clicks the next button. I've tried removeMovieClip with little success. I am able to remove one or two of them, but not all. I need all of the previously attached movies gone.
Here is the as2 for it.
PHP Code:
//Set functions
function show_movie() {
menu_mc._visible = true;
buttons_mc._visible = false;
teacherinfo_mc._visible = false;
} function displayInfo() {
[Code] .....
Is it possible in AS2 to remove an attached movieclip instance in reverse order? I want to give the user the ability to click an erase button and remove the most recent instance of an attached movie. I have tried .swapDepths and getting inconsistent results. Here is what I have:
this.onMouseDown = function(){var drawdot:MovieClip;
drawdot = this.attachMovie("dot", "dot_mc", this.getNextHighestDepth(), {_x:_xmouse, _y:_ymouse});
[code].....
I am trying to make this class remove a dynamic Movieclip that was attached on the mainstage using attachMovie(); it wont let me remove the movieclip tho
here is my code
Code:
class close_btn extends MovieClip
{
function onPress () : Void
[Code]....
How do you remove each attached/duplicated movie clip on the screen?
Is there an easy script for this?
Lately I've found myself constantly writing removeEventListeners everywhere, which makes code quite messy. I know it's a best practice and such, but in general it has no sense. Garbage collector should handle such a simple task by itself, shouldn't it? Is it that hard to remove all listeners automatically when object is set to null?
So I just want to be sure if that's the case. Does setting an object to null, automatically remove all attached event listeners? In my case scenario is like this - I create an object and attach bunch of event listeners to it, then after a while I need to re-initialize this object. Of course setting this object to null is much easier then unbinding every listener by hand. And on most part listeners are anonymous functions, which means that it's not possible without code refactoring. When I simply re-initialize a variable with new I do not get duplicate listeners and such, but I'm not sure that it's previous value, along with all the listeners gets garbage-collected. Is it?
I want to apply actions to a movieClip nested inside a dynamicly attached movieClip, with the attachMovie method; it doesn't works when the movieClip is attached by a button:
1.when the swf movie loads with an attachMovie method the remove_btn clears the window_mc
[Code]....
Say I create a movieclip which acts like a button, meaning that it has an over state, out state etc. I then create five instance of this movieclip and give each one an instance name e.g. b1, b2, b3, b4 and b5. Is there anyway of removing the states actions of say b1 without having to create a new button just for this? I was hoping there was something like b1.turnOffEffects = true (In my dreams, lol).
View 1 RepliesI have 10 thumbnails loaded using a for loop through XML. Each thumbnail is clickable and have an event listener attached. [code]...
My problem is that the images are stacking on top of each other, and never being removed.
Ideally I what to removeChild(); to the previous child added when the showPicture function runs. But I have no idea how to achieve this.
removing object instance from memory.I have created a class that move objects(movie clip) on stage. and on fram 1 i created 100 instances of this class using loop. now when user click on movie clip it should be remove from stage as well as from memory. using removeChild() it is removed from stage but it is not removed from memory. for testing i use initialy only one instance to check my code and when click it is removed from stage but not from memory. here is the code
// this code is on frame 1
function move()
{
[code]...
i used delete and assigning null and GC but nothing works. any one who knows how to remove the object instance from memory I applied every thing but object instance is still in memory (because there is a trace in fall class which continuously running and i guess the object still exist in memory)
I am loading an SWF file into another parent SWF. I remove the loaded SWF using the unloadAndStop() method and set the loader to null. But the instance of the loaded SWF still remains there in the memory.
View 2 RepliesI did a file/import/video and pointed to a video on my server and this is all on the first frame. On my aa layer I have the following[code]...
As you can see, when the video finishes, it hops to frame 2 and continues to the website. What started happening on a few occasions, is the timeline would randomly jump back to frame 2 for no apparent reason. I'm assuming it's because I didn't remove the instance of the video, or something along those lines? This whole issue on;y started when I introduced the video.
I am using a loop to add 10 shapes to the stage, then i just want to click on one at a time, in any random order and make it alpha 0, im using this code.. it gets rid of some shapes but not all. i dont get it?
Code:
var shape:MovieClip;
for (var i:Number = 0; i < 10; i++)
{
[Code]....
im trying to grab the instance name of something on stage, set it to a variable then remove it.
iv tried:
Actionscript Code:
var something = object1something.removeMovieClip();
that works. problem is im setting variables at runtime depending on a user click.tried this too..
Actionscript Code:
var myvar;object1.onRelease = function() {myvar = this._name;}
tracing this out reveals that it is actually _level0.object1.also tried adding the string "_level0." + object1. still dosen' work.what im trying to do is click on objects. store there instance names into an array then remove them all when i do something else. such as press space.
package com.test{
import flash.display.Sprite;
import flash.display.MovieClip;
[code]....
I'm writing a video game and I have used timers all over the place to make everything go. Now I want to be able to pause the game, completely. Meaning, I need to stop and start all timer instances at once, or globally. So I created a Timer subclass called CustomTimer, put some statics in there, came up with the attached code. Now my problem is that I'm pretty sure I've created a memory leak, in that the instances array will just grow and wont allow or gc. So, my question is, is there an "onDestroy()" method or somesuch, that I can override, and use that moment to remove instance refs from the instances array? Or, is there a smarter way to do this? an application object with a pause method perhaps?
View 11 RepliesDoes 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?
View 1 RepliesI have a library object (SomethingMC) which extends a custom class (Something). Something, in turn, extends MovieClip.If adding SomethingMC to the stage within Flash CS3 IDE, is it possible for it's super class (Something) to assign an instance name from a class constant (Something.THE_CONSTANT)?
package
{
import flash.display.MovieClip;[code].....
The above does not work. It throws Error #2078: The name property of a Timeline-placed object cannot be modified. if the instance is assigned a name in the IDE, and it just doesn't work if no name is assigned in the IDE.
I have a BUNCH of bumpers of four types bounceUp, bounceDown, bounceLeft, bounceRight. during a collision which you hit determines the bounce so they always do the same thing so here's my question.....can i just name every bounceUp instance the same thing and then just add that one instance name to the list the collision detector checks?
i just dont wanna go through and name a hundred each of bounceUp s and bounceDown s individually as the potential for screaming increases proportionally.......