Hi,
Sorry, I am a little confused - I may have looked at your question wrong...
Your error says
"1120: Access of undefined property contactWindow"
etc.
Where is "contactWindow" created - if you have no variable called
contactWindow in the scope of your removerChild function, it will
complain - I guess if you create stuff dynamically, you may have this
problem. You either have to declare all your child instances, look in an
array, or be a bit more "abstract" in your remove function:
If you want to remove all objects from the stage (or a clip - substitute
stage with the name of the clip), you can loop through them one by one:
Start by checking what's on your stage / in your clip like this:
function removerChild():void{
var count:int = stage.numChildren();
for(var i:int = 0;i < count;i++) {
var clip:DisplayObject = stage.getChildAt(i);
trace("clip is " + clip + " name " + clip.name);
//You might be able to determine what type of movieclip your child is by
casting it -
//if the cast does not work, it will probably be null (not sure if it
throws an Exception)
if(clip as AboutUsWindow) {
stage.removeChild(clip);
}
}
}
I would recommend that you put your "dynamic" windows inside another
container clip on the stage. That way, it might just be easier to remove
all the children in the container rather than checking if they are a
specific "instance".
function removerChild():void{
var count:int = container.numChildren();
for(var i:int = 0;i < count;i++) {
container.removeChildAt(i);
}
}
This will only work if you are getting rid of everything each time you
call the function removerChild. If you want to keep certain things on
the stage, it may be easier to pass in an argument(s) saying what
clip(s) to leave onstage - I will leave that for you to decide.
Hopefully I have got the "right end of the stick" this time...
Glen
Gustavo Duenas wrote:
Hi Glen, the problem is not the creation of the window(which is movie
clip exported to actionscript), is to removing then in a function.
Regards,
Gustavo
On Jun 3, 2009, at 11:04 AM, Glen Pike wrote:
function click(e:MouseEvent):void{var newWindow:AboutUsWindow = new
AboutUsWindow()://??addChild(newWindow)}Gustavo Duenas wrote:
Hi Matt I did as you sent me, but something wrong happened this is
the warning flash gave me:1120: Access of undefined property
contactWindow.and so on with the other parts of the code , code
is:function removerChild():void{ if(stage.contains(contactWindow)){
stage.removeChild(contactWindow); }else
if(stage.contains(productGeneral)){
stage.removeChild(productGeneral); }else
if(stage.contains(productWindow)){ stage.removeChild(productWindow);
}else if(stage.contains(aboutWindow)){
stage.removeChild(aboutWindow); }else
if(stage.contains(ecuacocoaWindow)){
stage.removeChild(ecuacocoaWindow); }else
if(stage.contains(suppWindow)){ stage.removeChild(suppWindow); }else
if(stage.contains(eWindow)){ stage.removeChild(eWindow); }else
if(stage.contains(proWindow)){ stage.removeChild(proWindow); } }This
is added to the click event of my buttons.The click is a function
that creates an object based on an object that is export for
actionscriptlike:function click(e:MouseEvent):void{var
newWindow:AboutUsWindow = new AboutUsWindow():}see? is the regular
way, problem is when I run the code above to try to get rid of those
windows, but they are not still on stage..thatwas the reason? or I
miss something else.Regards,gustavoOn Jun 2, 2009, at 2:02 PM, Matt
Gitchell wrote:
The container would be the stage in that instance, yes. I used it
becauseStage extends DisplayObjectContainer, and you could use that
chunk of codefor any DisplayObjectContainer (MovieClip, Sprite) as
well.I should also mention that we're talking AS3.--MattOn Tue, Jun
2, 2009 at 10:38 AM, Gustavo Duenas LRS
<gdue...@leftandrightsolutions.com> wrote:
in this case what is container? is stage.?like
thisif(stage.contains(contactWindow)){stage.removeChild(contactWindow);}is
like this, if not please explain me what this container is
about.GustavoOn Jun 2, 2009, at 12:07 PM, Matt Gitchell wrote: if
(container.contains(itemToRemove)){
container.removeChild(itemToRemove);};On Tue, Jun 2, 2009 at 8:45
AM, Gustavo Duenas LRS <gdue...@leftandrightsolutions.com> wrote:
Hi I have movie clips, that are created one I click a button, I'd
like to
know how couldI remove then, something to put in the buttons,
problem is when I try toremovethe movieclip from the stage(I put
the orders en every single button Ihavethere), it says that is
not created yet, there is a way to know when themovie clip is on
there and if this is therejust remove it.Like
if(stage.movieclipName=true){removeChild(movieClipName);}there
is a way like this or something else around.Regards,Gustavo
Duenas_______________________________________________Flashcoders
mailing
listflashcod...@chattyfig.figleaf.comhttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing
listflashcod...@chattyfig.figleaf.comhttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________Flashcoders mailing
listflashcod...@chattyfig.figleaf.comhttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________Flashcoders mailing
listflashcod...@chattyfig.figleaf.comhttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________Flashcoders mailing
listflashcod...@chattyfig.figleaf.comhttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________Flashcoders mailing
listflashcod...@chattyfig.figleaf.comhttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders