ActionScript 2.0 :: Remove Child From MC Thats Not Even Attached To Stage?
Jan 9, 2009Is it possible to remove an MC from an MC if its not even attached to the stage?
View 11 RepliesIs it possible to remove an MC from an MC if its not even attached to the stage?
View 11 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]...
I created movie clips that I want to add to the stage (from the library) by the use of buttons. I have a total of six buttons (and six moviclips) but I am trying to get the first two to work before I move on to the next buttons. The problem is I can't seem to remove the movie clip when another button is clicked, or the same button... Like I said I am new at this and I think a created a mess of things... I am getting error 2007 now
import flash.events.MouseEvent;
import flash.display.MovieClip;
mix_btn.addEventListener(MouseEvent.CLICK, addbear);
[Code]....
It may sound stupid, but how can I remove a definite child from the stage?[code]...
View 5 RepliesI am trying to remove a swf that I import to the stage, but it is not working.
Code:
function btn_cima_3call(clickEvent:MouseEvent):void{
page = 5;
esconder();
content.gotoAndStop(page);
ld.load(new URLRequest("trabalhosV0.swf"));
ld.x = 0;
ld.y = 100;
addChild(ld);
}
So when 1 button is pressed this swf is imported to the stage. but im now trying to remove this when another button is pressed and it isnt working?
Code:
function btn1call(clickEvent:MouseEvent):void{
removeChild(ld);
page = 1;
content.gotoAndStop(page);}
Im trying to remove a swf that i import to the stage, but it is not working:
Im doing like this:
Code:
function btn_cima_3call(clickEvent:MouseEvent):void{
page = 5;
esconder();
[Code]....
I'm trying to use a variable to remove a child from the stage and I get this error:
Scene 1, Layer 'action', Frame 108, Line 471067:
Implicit coercion of a value of type String to an unrelated type
flash.display:DisplayObject.
What I'm trying to do is to link some keys to add movie clips to the stage. But I need to have only one movie clip at the time on the stage, so, if I press a key to add a movie clip on the stage, the one that is already there needs to be remove. So I set a variable called "actualConf" to hold witch movie clip is on the stage. I simplified the code a bit to add it here (If I press "Q", the movie clip "lise" is added to the stage, then if I press "W", I want the movie clip "lise" to be removed than "nancy" to appear), I added a comment where I get the error :
Code:
Select allstop();
var actualConf:String = "null";
var lise:mcLise;
var liseX:Number = 50
var liseY:Number = 50
[Code] .....
Because I will have about 15 keys linked to 15 possible movie clips, I don't want to use the "if" condition 15 times.
I have a movie clip on the stage with the instance name "ball". In my code, I addChild(ball) to a Ball object called "mainBall". After doing that, I want to remove "ball" from the stage. Finally, I add addChild(mainBall) to stage. The code takes place in my Document class:
var mainBall:MovieClip = new Ball()mainBall.addChild(ball)stage
.removeChild(ball)addChild(mainBall)
From the code, I get the error: "The supplied DisplayObject must be a child of the caller".
I have a map with various regions as movieclips. When you mouse over a region, a sprite appears containing xml data. Among this data is a hyperlink. I want the sprite to stay on the stage until one of two
things happens:
- you mouseout of the sprite
- you go to a new region
That seems to be the problem. I've successfully coded the program to remove the child if you mouseout of the sprite. But if you go to a new region, it makes a new sprite and now you have two sprites with xml data on the stage! If I remove the child when you mouseout of the region, then the sprite won't stay on the stage for you to click the hyperlink. How can I make the sprite stay on the stage until:
- you mouseout of the sprite
- you mouseout of the region IF you aren't on the sprite
I am using the following code to generate a bullet (I have a bullet it the library linked Bullet):
ActionScript Code:
function createBullet (bulletSpeed:Number, startx:Number, starty:Number) {
var bullet:MovieClip = new Bullet();
bullet.x = startx;
[Code].....
upon the bullet.x getting to less that 50 it deletes the movieclip ok (other instances of the bullet are still onstage, which is what I want) but it gives the error:
ActionScript Code:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at Function/<anonymous>()
I have made index swf which is loading other child swf's into index these swf's are images.swf,portfolio.swf, about.swf etc.., I have made 2 public function in each swf which is construct or diconstruct. when i unload any swf then i play disconstruct public function of every child swf.. I stuck in when I remove stage event listener of every child swf then it shows error.
[Code]...
I'd like to remove a child of the display list if it exists before adding another to the stage. This gives me Error the first time I call it because 'myMC' doesn't exist.
HTML Code:
function callMc(){
if(myMc) removeChild(myMc);
[Code]....
if I add a clip to the stage as a child and remove the parent and set the parent equal to null, does the child get collected and removed from memory? What if the child has an image loaded into it as its child?
In my application I'm loading a series of png images as overlays that can be tinted for customizing in this app. When I trace my memory, the basic app idles at 64,000 k. The exact second I load those overlay images it goes up to 205,000k. If I remove those clips and "clear" the stage I should go back down to 64,000 k if everything is removed and collected correctly, right? It's not, it's hanging at 215,000 k. Are my images being cached and that is the reason for the memory staying up? If so, how do I prevent that. Or upon removing the parent of the image how can I un-cache the image.
If a user switches between models and loads several different items then the application actually crashes the Flash environment because of too much memory usage. It also does the same to browsers.
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 Repliesi'm new to AS3 and i was wondering what is the best way to remove a child at a point. i tried Holder.removeChild(Holder.getObjectsUnderPoint(new Point(exampleX, exampleY))[0]); however that returned ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
View 2 RepliesI have an issue where removechild won't infact remove a child. I think its something to do with my dropTarget.parent issues. The concept of the code is that you drag a source onto a destination. When you drop the source onto the destination you will get a text field that says "Hello" or "Goodbye". The objective i want to achive is that once i drop a source onto the destination, removechild will remove any previouse textfields added. This is proving difficult.
[Code].....
public function GlobalSolutions()
{
Navigation(' Home ', 'index', 235, 0x97F9EC);
Navigation(' Office Supplies ', 'Office_Supplies', 295, 0x97F9EC);
[code]....
I want to remove the appropriate child (e.currentTarget) and create a new child in its place with the next line, but it doesn't work. What do?
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'm creating a highscore list like this:
[Code]...
I 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]....
do to the lack of good on Kongregate, I have come here =D
if(_root.row2.block1._x == _root.row1.block1._x)
{
_root.row2.block1.removeMovieClip();
[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.
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 11 Repliesin my package I declared my vars
[Code]....
Is there any way to access these dynamiccaly attached MCs like when I instantiate in Ex 1?
I am getting this error, whenever i loaded an external SWF file. I had an Interface, in which a glossary icon is set. So, when clicked, the glossary swf file has to be loaded in to Interface. So, I made a loader and added to display hierarchy, but left empty. So, when glossary icon is clicked, i am loading this specific glossary SWF file in to that loader. But, as it is added, the following Error is thrown. Here, assume glossary to be TestSlide.swf file (dummy content)
[Code]...
how to remove all child of a movieclip if no of child are not known
View 2 Repliesso I have a movieclip on the stage(lets call that selection movieclip) that once a button is clicked is going to open another movieclip(call this slideshow) I am trying to remove the selection movieclip when you launch the slideshow movieclip.
[Code]...
this is the script i am using
[Code]...
the problem is that when i click on first button the Movie Clip does load ok but when i click on second button the first movie cliip is visible, i have try everything i have read here but no luck, i want to learn how to remove first child and allow only the second child to show up, i am looking forward to add more buttons so the remove child should be for multiple buttons, i am learning and so far did purchase a online tutorial but did not help me with this situation,
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] .....