Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-06-2007, 05:13 PM   #1
GoneNuts
Member
 
Join Date: Nov 2007
Posts: 90
Question remove child with if statement

is it possible to remove child with a if statement.

if the child loaderM = true then remove loaderM?

ActionScript Code:
function Load_Add2(event:MouseEvent):void{                     if (loaderM = true){         removeChild(loaderM);         }                 loaderM.load(new URLRequest("mainT.swf"));         addChild(loaderM);         loaderM.x = 127.5;         loaderM.y = 50;                     }

what I am trying to do if the var loaderM has placed a child on the stage then remove it and then reload another swf file mainT.swf. I am using loaderM on different keyframes to load and add different children which there is no problem with but when I load different swf's the last swf file is still present I need to remove the previous swf file then load the new one to the stage.

when i use the if statement to remove the child if loaderM is true I get this error.


1067: Implicit coercion of a value of type Boolean to an unrelated type flash.display:Loader.

dose anyone have any bright ideas or am I just missing something.

Last edited by dr_zeus; 12-06-2007 at 05:21 PM. Reason: added [as][/as] formatting tags
GoneNuts is offline   Reply With Quote
Old 12-06-2007, 05:22 PM   #2
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

I'm guessing you want something like this:

ActionScript Code:
if(loaderM != null)
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 12-06-2007, 05:22 PM   #3
xwielder
Senior Member
 
Join Date: Aug 2007
Location: NE Ohio
Posts: 520
Send a message via AIM to xwielder
Default

ActionScript Code:
if (loaderM) { }


Get rid of the " = true"
xwielder is offline   Reply With Quote
Old 12-06-2007, 05:26 PM   #4
xwielder
Senior Member
 
Join Date: Aug 2007
Location: NE Ohio
Posts: 520
Send a message via AIM to xwielder
Default

also... "=" is an asigning operator. You were trying to assign loaderM to a value of true. So, you could do it in the following 3 ways:

ActionScript Code:
if (loaderM == true) if (loaderM != null) if (loaderM)

hope this helps.
xwielder is offline   Reply With Quote
Old 12-06-2007, 05:29 PM   #5
GoneNuts
Member
 
Join Date: Nov 2007
Posts: 90
Default

xwielder thanks m8t works like a charm...

I wasn't missing somthing this time I had something extra lol
GoneNuts is offline   Reply With Quote
Old 12-06-2007, 05:32 PM   #6
noflashlight
Registered User
 
Join Date: Aug 2007
Location: New York, NY
Posts: 69
Send a message via MSN to noflashlight
Default

Quote:
Originally Posted by xwielder View Post
ActionScript Code:
if (loaderM) { }
This translates into: "if loaderM is truthy"... Every language has different definitions of this.
In AS3 truthy means anything that is NOT:
null
'' (empty single quote string)
"" (empty double quote string)
0
false


might be more to that list.
noflashlight is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
remove child problem Macman17 ActionScript 3.0 4 10-11-2007 11:07 PM
remove child removes event sekopasa ActionScript 3.0 0 07-05-2007 08:21 AM
How to remove all child elements from a movie clip without knowing their names lpx ActionScript 3.0 3 07-04-2007 12:15 PM
a "close" button on child swf bloombloom ActionScript 2.0 0 02-14-2007 01:26 AM
Help With a Simple Conditional Statement jcolletti ActionScript 1.0 (and below) 1 06-05-2003 03:37 PM


All times are GMT. The time now is 08:28 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.