RemoveChild
Dear Friends,
i have deeloped a Ticker cum Alert RSS feed. It is working
fine except the alert option. What i did was i have a empty movie
clips and adding all the text int it and loading the movie clip to
new native winodow. when iam closing the native window i have to
remove all the text at movie clip and reset my application. My code
is:
stop();
var showalert:Boolean = true;
var goalert:Boolean = false;
var inc10:Number = 0;
var serverjointdate:String = new String();
var serverfuldate:String = new String();
var serverday:String = new String();
var serverdate:String = new String();
var servermonth:String = new String();
var serveryear:String = new String();
var serverhour:String = new String();
var serverminute:String = new String();
var serversecond:String = new String();
var xjointdate:String = new String();
var xday:String = new String();
var xdate:String = new String();
var xmonth:String = new String();
var xyear:String = new String();
var alertyarray:Array = new Array();
var alertinc:Number = 1;
function update(tit,link,categ) {
var myXML3:XML = new XML();
var XML_URL3 =link;
var myXMLURL3:URLRequest = new URLRequest(XML_URL3);
var myLoader3:URLLoader = new URLLoader(myXMLURL3);
myLoader3.addEventListener("complete", xmlLoaded3);
function xmlLoaded3(event:Event):void {
myXML3 = XML(myLoader3.data);
len3 = myXML3.channel.item.length();
for (inc10=0; inc10<len3; inc10++) {
//trace(myXML3.channel.item[inc10].pubDate);
//Tue, 16 Sep 2008 08:46:13 +0000
chkdate(myXML3.channel.item[inc10].pubDate,myXML3.channel.item[inc10].title,myXML3.channe l.item[inc10].category,myXML3.channel.item[inc10].description,myXML3.channel.item[inc10].l ink);
///-->trace("------------------------------");
function chkdate(dt,tit,cat,des,lin) {
var dateposi:Number = dt.indexOf(" ")+1;
var monthposi:Number = dt.indexOf(" ",dateposi)+1;
var yearposi:Number = dt.indexOf(" ",monthposi)+1;
xday = dt.substr(0,3);
xdate = dt.substr(dateposi,2);
xmonth = dt.substr(monthposi,3);
xyear = dt.substr(yearposi,4);
xjointdate = xday+", "+xdate+" "+xmonth+" "+xyear;
if (xjointdate == serverjointdate) {
var alt:alerttxt = new alerttxt();
alt.x = 10;
if (alertinc==1) {
alt.y = 10;
} else {
alt.y = alertyarray[alertinc-1];
alertyarray[alertinc] = alt.y+alt.height;
alertinc++;
alt.alerttit.htmlText = "<b><a
href=\""+lin+"\"><\a><\b>"+tit;
alt.alertdesc.htmlText = "<a
href=\""+lin+"\"><\a>"+des;
alerthold.addChild(alt);
alt.addEventListener(Event.ENTER_FRAME,altenter);
function altenter(event:Event) {
if (showalert == true) {
event.target.removeEventListener(Event.ENTER_FRAME,altenter);
//alerthold.removeChildAt(0);
alerthold.removeChild(alt);
alertinc = 1;
t.reset();
t.start();
/*alt.addEventListener(Event.ENTER_FRAME, altenter);
function altenter(event:MouseEvent) {
if(showalert == true){
event.target.removeEventListener(Event.ENTER_FRAME,altenter);
alerthold.removeChild(alt);
alertinc = 1;
t.reset();
t.start();
if (showalert == false) {
trace("can move now");
alertscr.source = alerthold;
if (goalert == true) {
showalertscr();
goalert = false;
//---------Checking Server Date -
Starts------------------------------------------
function
configureListeners4(dispatcher4:IEventDispatcher):void {
dispatcher4.addEventListener(Event.COMPLETE,
completeHandler4);
function completeHandler4(event:Event):void {
var loader4:URLLoader = URLLoader(event.target);
var datevars:URLVariables = new URLVariables(loader4.data);
//fuldt=Wed, 17 Sep 2008 10:23:09
+0000&dt=17&mth=Sep&yr=2008&hr=10&mts=23&sec=09
serverfuldate =datevars.fuldt;
serverday = datevars.day;
serverdate = datevars.dt;
servermonth = datevars.mth;
serveryear = datevars.yr;
serverhour = datevars.hr;
serverminute = datevars.mts;
serversecond = datevars.sec;
serverjointdate = serverday+", "+serverdate+"
"+servermonth+" "+serveryear;
for (inc9=0; inc9<=seldblist.length-1; inc9++) {
update(seldblist.getItemAt(inc9).label,seldblist.getItemAt(inc9).sellk+Math.random(),seld blist.getItemAt(inc9).selcat);
trace(seldblist.getItemAt(inc9).sellk+Math.random());
if (inc9==seldblist.length-1) {
showalert = false;
goalert = true;
//-->showalertscr();
var t:Timer = new Timer(10);
t.start();
Object(root).addEventListener(Event.ENTER_FRAME,eframe);
function eframe(event:Event) {
if (t.currentCount>=100 && showalert==true) {
var loader5:URLLoader = new URLLoader();
var request5:URLRequest = new URLRequest("
http://v5.test.arabianbusiness.com/testing/time/servertimenew.php?id="+Math.random());
try {
loader5.load(request5);
configureListeners4(loader5);
} catch (error:Error) {
trace("Unable to load requested document.");
t.reset();
t.start();
//---------Checking Server Date -
Ends------------------------------------------
var opt2:NativeWindowInitOptions = new
NativeWindowInitOptions();
opt2.transparent = true;
opt2.systemChrome = NativeWindowSystemChrome.NONE;
opt2.type = NativeWindowType.NORMAL;
opt2.resizable = false;
opt2.maximizable = false;
opt2.minimizable = false;
var newwindow2:NativeWindow = new NativeWindow(opt2);
newwindow2.stage.scaleMode = StageScaleMode.NO_SCALE;
newwindow2.title = "Alert Window";
newwindow2.width = 700;
newwindow2.height = 500;
newwindow2.x = newwidth - (newwindow2.width + 10);
newwindow2.y = bottomlimit - (newwindow2.height + 10);
newwindow2.alwaysInFront = true;
function showalertscr() {
/*var opt2:NativeWindowInitOptions = new
NativeWindowInitOptions();
opt2.transparent = true;
opt2.systemChrome = NativeWindowSystemChrome.NONE;
opt2.type = NativeWindowType.NORMAL;
opt2.resizable = false;
opt2.maximizable = false;
opt2.minimizable = false;
var newwindow2:NativeWindow = new NativeWindow(opt2);
newwindow2.stage.scaleMode = StageScaleMode.NO_SCALE;
newwindow2.title = "Alert Window";
newwindow2.width = 700;
newwindow2.height = 500;
newwindow2.x = newwidth - (newwindow2.width + 10);
newwindow2.y = bottomlimit - (newwindow2.height + 10);
newwindow2.alwaysInFront = true;*/
newwindow2.activate();
var setbg2 = new altbg();
setbg2.x = 0;
setbg2.y = 0;
newwindow2.stage.addChild(setbg2);
//-------adding drag bar for dragging - starts
var setdrg2 = new altdrg();
setdrg2.x = 0;
setdrg2.y = 0;
newwindow2.stage.addChild(setdrg2);
setdrg2.addEventListener(MouseEvent.MOUSE_DOWN,setdrgclick2);
function setdrgclick2(event:MouseEvent) {
newwindow2.startMove();
//-------adding drag bar for dragging - ends
//-------adding close button in setting screen - starts
var setclose2 = new setc();
setclose2.x = 370;
setclose2.y = 5;
newwindow2.stage.addChild(setclose2);
setclose2.addEventListener(MouseEvent.CLICK,
setcloseclick2);
function setcloseclick2(event:MouseEvent) {
alertscr.source ="";
newwindow2.stage.removeChild(alertscr);
//newwindow2.close();
newwindow2.visible = false;
showalert = true;
goalert = false;
//-------adding close button in setting screen - ends
newwindow2.stage.addChild(alertscr);
alertscr.x = 10;
alertscr.y = 50;
it is giving the following error:
ArgumentError: Error #2025: The supplied DisplayObject must
be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at
ABTickerNewCheck_fla:MainTimeline/chkdate/ABTickerNewCheck_fla:altenter()[ABTickerNewChec k_fla.MainTimeline::frame10:278]
pls help me. i got struct up. if i finish this option i can
finish my full project....
Thanks in ADvance,
RahimHaji
Hi,
garbage system is different from olders versions, check
google.
Your problem is, that you are removing child from parent,
what do NOT have that child. Make sure, that you are calling
removeChild on the parent of child you want to remove. if you have
link to the object you want to delete, youse this:
curitem.parent.removeChild(curitem);
Good Luck :)
Similar Messages
-
RemoveChild in 8.1.7
Hi,
i want to remove a child node (that was inserted with appendChild) but the sys.xmldom.removeChild(parent, child) always crashes with a "java.lang.NullPointerException".
Can this be a problem with my environment or my function parameters or what else?
Please help!
Thanks
WolfgangHey!
I've the same problem with appendChild(). It seems very strange because i display the ids of the nodes passed to the procedure and there is not a NullPointerException before the call to appendChild.
This the sample code :
t_CurrentNode xmldom.DOMNode;
t_ChildNodeToAdd xmldom.DOMNode;
t_ReturnedNode xmldom.DOMNode;
BEGIN
dbms_output.put_line('Current node id=' || t_CurrentNode.ID);
dbms_output.put_line(Child node id=' || t_ChildNodeToAdd.ID);
-- Here it displays correctly the ids
t_ReturnedNode := xmldom.appendChild(t_CurrentNode, t_ChildNodeToAdd);
-- This line crashes with a NullPointerException in
-- the line 277 of the source of xmldom and before .
-- in the line 0 of the source of xmlnodecover
END;
But at the line 277 of the source there is :
xmlnodecover (node.ID, child.ID, err) with err := -1 and reasonably with node.ID and child.ID != NULL so i don't understand... -
I have a proc, in which i have a logic to remove child from the xml node. I have a xml_doc variable pointed to the xml document.
Sample xml to explain my issue better:
<?xml version="1.0" encoding="UTF-8"?>
<oa:stackLayout id="294641" controllerClass="oracle...." textTranslationExpansion="50%"......>
<ui:contents>
<oa:spacer id="_czn1-spacer1_294644" ..../>
<oa:tableLayout id="294645" adminCustomizable="false" width="100%" ....>
<ui:contents>
<oa:rowLayout id="294642" extends="/../../..TextFeature" .../>
<oa:rowLayout id="294643" extends="/../../../IntegerInputWithRangeDisplay" .../>
</ui:contents>
</oa:tableLayout>
</ui:contents>
</oa:stackLayout>
/****************************Code Start************************/
Proc dummy_proc(....)
-- open XML parser
Open_Parser();
l_xmldoc :=parse_JRAD_Document(p_doc_full_name => l_jrad_doc);
// l_xmldoc contains the xml docuement
l_parent_xml_node // Contains the2nd ui:contents node
l_child_xml_node // contains the oa:rowLayout for 294642
dbmsoutput stmts for printing l_xmldoc document - Before removing the node
l_out_xml_node:=xmldom.removeChild(l_parent_xml_node,l_child_xml_node);
dbmsoutput stmts for printing l_xmldoc document - After removing the node
end
/****************************Code End ************************/
Issue :
Scenario 1: When the above proc is called through OAF page submit button, the child node is not getting removed.
Scenario 2: When i run the proc by passing the same values using a anonymous block the child node is getting removed.
Any help is appreciated, why when running the flow the OAF page is stopping the child node to be removed is my question.
Let me know for any specific questions...How it can be Privilege issue, in both the scenarios same values are getting passed to the procedure. And how xmldom.removechild depends on user priveleges?
Edited by: 870314 on Jul 12, 2011 2:02 AM -
Action script 3 question: addChild and removeChild on same button??
I'm trying to make a button that when u click once, the movieclip will be removed and second time back on stage and so forth....
somehow i get this error
==================================
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:DisplayObjectContainer/removeChild()
at sample_fla::MainTimeline/btnClick()
==================================
Anyone can help me with this, since I'm doing an interactive web for client and the deadline is near..... thanks in advance.
these are my code:
stop();
var swf:MovieClip;
var loader:Loader= new Loader();
var defaultswf:URLRequest= new URLRequest("./newSwfImport.swf");
//default swf when loaded
loader.load(defaultswf);
//add to stage
allSwfLoadHere.addChild(loader);
var boolean:Boolean = true ;
function btnClick(event:MouseEvent):void {
if(boolean == true){
allSwfLoadHere.removeChild(loader);
boolean == false
if(boolean ==false){
allSwfLoadHere.addChild(loader);
boolean == true
newSwfImport.addEventListener(MouseEvent.CLICK,btnClick);you have, at least, two errors:
1. you failed to use an if-else and
2. when trying to re-assign your boolean, you tested. ie, you used == when you should use =. so, your boolean remains true. then when you execute the 2nd time, you try and remove something that's already been removed.
use:
var swf:MovieClip;
var loader:Loader= new Loader();
var defaultswf:URLRequest= new URLRequest("./newSwfImport.swf");
//default swf when loaded
loader.load(defaultswf);
//add to stage
allSwfLoadHere.addChild(loader);
var boolean:Boolean = true ;
function btnClick(event:MouseEvent):void {
if(boolean){
allSwfLoadHere.removeChild(loader);
} else {
allSwfLoadHere.addChild(loader);
boolean=!boolean;
newSwfImport.addEventListener(MouseEvent.CLICK,btnClick); -
Hi All,
Got this code loading thumbs, and when their clicked loads a
bigger image etc...
function xmlLoaded (e:Event):void {
xml = XML(e.target.data);
images = xml.image;
for(var i:uint=0; i<images.length();i++){
var thumb:MovieClip = new MovieClip();
var thumbLoader:Loader = new Loader();
thumb.x = 65*i + spacing;
thumb.y = 370;
thumb.src = images[counter].@url;
thumb.mouseChildren = false;
thumb.buttonMode = true;
thumbLoader.load(new URLRequest(images[counter].@thumb));
addChild(thumb);
thumb.alpha = 0;
TweenMax.to(thumb, 1, {alpha:1, ease:Sine.easeIn});
thumb.addChild(thumbLoader);
thumbLoader.x = 24;
thumbLoader.y = -14;
thumb.addEventListener(MouseEvent.CLICK, clickedThumb);
counter++;
loader.load(new URLRequest(images[0].@url));
Problem happens with the following code - I go into
fullScreen and want to either hide the thumb etc... or remove it:
masker.addEventListener(MouseEvent.CLICK, fullScreen);
function fullScreen(MouseEvent):void
thumb.visible = false; // do not work
removeChild(thumb); // do not work
stage.displayState = StageDisplayState.FULL_SCREEN;
masker.x=0;
masker.y=0;
masker.width=stage.stageWidth;
masker.height=stage.stageHeight;
StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
masker.buttonMode = true;
Hope someone can provide an answer to this, as it's driving
me BONKERS ;) It's got to be down to how I am referring to it, the
path.
Kind Regards,
Boxing BoomI can see a few possible problems. One is that if you want to
reference a variable you create from multiple functions it needs to
be declared outside both functions. Such as reference 1 below.
Another is if you are creating many objects creating the same
variable you should add them to an array to be able to access them
later as below in reference 2.
Note sure if these may help, but thought I would throw them
out there. -
RemoveChild and Garbage Collector
I am still fuzzy on the Actionscript 3 framework.
If I remove a child from a container, is the removed child
automatically eligible for the garbage collection?
If not – what should I do to make it eligible?
If yes – what can be done to prevent it from being
permanently deleted should I need it?
container.removeChild(myDisplayObject)
Thank you!kglad,
Thank you very much for you response - things are much
clearer now.
I am trying to figure out some standard ways to deal with
unneeded objects. I am relatively new in OOP (and my OOP education
comes from JS and Flash) and it is not very obvious to me yet how
to approach garbage collection in general (and I realize how
important this kind routine is).
If this is not very time consuming - could you please share
some bullet points of how you do that. Do you have, say, a class
that performs clean up routine for all the objects or, may be, each
class has to have some method that cleans up after it? Also, what
would be an optimal way to keep track of the objects (some central
depository/library) so that one can find them easily. I've noticed
that there is a new class Dictionary in AS3 - can it be useful for
this task?
I know that I want too much and I need to pick up a book or
two on OOP but, still, I like to hear developers' experiences not
only because I tend to take short cuts but also because in many
cases what experience dictates is much more useful than academical
elaborations.
Again, thank you very much,
Andrei -
any idea why removeChild(splash_mc); is taking btnSet with it?
package
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.media.*;
import utils.Utils;
import gs.*;
import gs.easing.*;
import nav.*;
import flash.text.*;
import buttonSet.ButtonSet;
import preload.LinePreloader;
public class GoldClubMain extends MovieClip
private var btnSet:ButtonSet;
public var navModel:NavigationModel;
public var navView:NavigationView;
public var navController:NavigationController;
private var pre:LinePreloader;
//SOUND
// public var sound:mainBeat = new mainBeat();
// public var channel:SoundChannel;
// public var soundOn:SoundTransform = new SoundTransform(1, .5);
// public var soundOff:SoundTransform = new SoundTransform(0, .5);
public function GoldClubMain()
navView = new NavigationView(container_mc);
navModel = new NavigationModel()
navController = new NavigationController(navModel);
navView.model = navModel;
splash_mc.buttonMode = true;
splash_mc.addEventListener(MouseEvent.CLICK, enterSite);
btnSet = new ButtonSet()
btnSet.addButtons([homeBtn_mc, danceBtn_mc, partyBtn_mc, dineBtn_mc, featBtn_mc, calBtn_mc]);
navController.addCustomButton([homeBtn_mc, danceBtn_mc, partyBtn_mc, dineBtn_mc, featBtn_mc, calBtn_mc]);
addChild(btnSet)
btnSet.alpha = 0;
private function enterSite(event:MouseEvent):void
TweenLite.to(splash_mc, .5, {alpha:0});
TweenLite.to(tMaskL_mc, .5, {delay:.5, x:-133, ease:Strong.easeOut});
TweenLite.to(tMaskR_mc, .5, {delay:.5, x:627, ease:Strong.easeOut, onComplete:removeSplash});
private function removeSplash():void
TweenLite.to(tMaskL_mc, .5, {delay:.2, x:-400, ease:Strong.easeOut});
TweenLite.to(tMaskR_mc, .5, {delay:.2, x:900, ease:Strong.easeOut});
TweenLite.to(btnSet, .5, {delay:.8, alpha:1, onComplete:addPage});
private function addPage():void
removeChild(splash_mc);
navModel.load(new URLRequest("xml/Main.xml"));
Thanks!no, there are differences. but i don't know how any would be related to your issue.
but if removing one object seems to remove another additional object, you should check if that additional object is a child of the explicitly removed one. -
Loading .swf, addChild, and removeChild
Hello all,
I'm trying load an swf when you click a button, and load another in it's place when you click a different button. I'm using addChild to insert the swf onto the stage. Problem is that every time I click a new button, the new swf is loaded on top of the previous one, and I need the previous one to disappear. I tried using the removeChild method before the new swf is loaded to no effect.
Here's the function I'm using for the loader with my removeChild attempt in bold:
function newPage():void {
trace("load activated");
trace(""+target+".swf");
var req:URLRequest=new URLRequest(""+target+""+".swf");
var loader:Loader = new Loader();
if (loaderState==true){
top_mc.removeChild(loader);
loader.load(req);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoad);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
function preLoad(event:ProgressEvent):void {
var percent:Number=Math.round(event.bytesLoaded/event.bytesTotal*100);
top_mc.preload_txt.text=String(""+percent+"");
function fileLoaded(event:Event):void {
trace("file loaded");
top_mc.addChild(loader);
loaderState=true;
The error I get is as follows:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at main_fla::MainTimeline/newPage()
at main_fla::MainTimeline/workLoaderEnter()
at main_fla::MainTimeline/clickF()
Perhaps there is a way to give the addChild an instance name so that I can remove it later?
Any ideas?
Thanks!Part of the problem is your trying to remove the loader just after you define it... it is not a child of anything at that point. Try the following instead of what you have. Another problem you can avoid is to not nest functions...
var loader:Loader
var loaderState:Boolean = false;
function newPage():void {
if (loaderState){
top_mc.removeChild(loader);
var req:URLRequest=new URLRequest(""+target+""+".swf");
loader = new Loader();
loader.load(req);
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preLoad);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, fileLoaded);
function preLoad(event:ProgressEvent):void {
var percent:Number=Math.round(event.bytesLoaded/event.bytesTotal*100);
top_mc.preload_txt.text=String(""+percent+"");
function fileLoaded(event:Event):void {
top_mc.addChild(loader);
loaderState=true; -
Blank line after removeChild()
Can anybody help with this question?
Looking for answer in forum archives - I found several answers which doesn't work.
1) use - normalize() - no effect
2) transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "GMAadapter.dtd") - no effect
1. I have such XML:
<?xml version="1.0" encoding="windows-1251"?>
<PurchaseOrder>
<Company>Our company</Company>
<Product>
<Prod1>Tee</Prod1>
<Prod2>Coffe</Prod2>
</Product>
</PurchaseOrder>
2. I try to remove Node <Prod1> with all its content
document = builder.parse(new InputSource(new java.io.StringReader( xmlString )));
NodeList nodelist = document.getElementsByTagName("Product");
Node parentNode = nodelist.item(0);
NodeList childNodeList=parentNode.getChildNodes() ;
parentNode.removeChild(childNodeList.item(1));
3. After this I transform document to String
ByteArrayOutputStream out;
Transformer transformer=null;
TransformerFactory tfactory;
String resultTransformedXML;
tfactory = TransformerFactory.newInstance();
transformer = tfactory.newTransformer();
transformer.setOutputProperty(OutputKeys.METHOD, "xml");
transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
transformer.setOutputProperty(OutputKeys.ENCODING, "WINDOWS-1251");
transformer.setOutputProperty(OutputKeys.INDENT, "yes");
transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, "GMAadapter.dtd");
out = new ByteArrayOutputStream();
transformer.transform(new DOMSource(doc.getDocumentElement()), new StreamResult(out));
if (out != null)
resultTransformedXML = new String(out.toByteArray());
4. As the result I have such string
<?xml version="1.0" encoding="WINDOWS-1251"?>
<!DOCTYPE PurchaseOrder SYSTEM "GMAadapter.dtd">
<PurchaseOrder>
<Company>Our company</Company>
<Product>
<Prod2>Coffe</Prod2>
</Product>
</PurchaseOrder>
I' ll be glad for any reply!!Originally your Product element had 5 children:
1. A text node containing a newline
2. A Prod1 element
3. A text node containing a newline
4. A Prod2 element
5. A text node containing a newline
You deleted child 2 of those. What do you have now?
1. A text node containing a newline
2. A text node containing a newline
3. A Prod2 element
4. A text node containing a newline
I'm not sure what normalize() does but it might result in this:
1. A text node containing two newlines
2. A Prod2 element
3. A text node containing a newline
which looks the same in any case. -
Help with removeChild or another solution
I am a beginner to actionscript 3 and I've been working on a portfolio gallery in Flash that swaps XML images on click of a thumbnail. Currently everything works well but the images stack on each other and I want them to switch on click. I have searched all over the Internet trying to troubleshoot but the typical fix of
if(lArtLoader)
{artImageL.removeChild(lArtLoader)}
doesn't work.
Can someone please guide me in the right direction? Below is my code. Thank you so much for any help.
var artTitle:Array = new Array();
var artDescription:Array = new Array();
var artLargeImage:Array = new Array();
var artThumbnailImage:Array = new Array();
var artImageNum:Number = 0;
var maxImages:Number;
//LOAD XML
var artXMLURLLoader:URLLoader = new URLLoader();
artXMLURLLoader.load(new URLRequest("portfolio/art.xml"));
artXMLURLLoader.addEventListener(Event.COMPLETE, artProcessXML);
function artProcessXML(event:Event):void
var artXMLData:XML = new XML(artXMLURLLoader.data);
maxImages = artXMLData.title.length();
for (var i:Number = 0; i < maxImages; i++)
artTitle.push(artXMLData.title[i]);
artDescription.push(artXMLData.description[i]);
artLargeImage.push(artXMLData.largeImage[i]);
artThumbnailImage.push(artXMLData.thumbImage[i]);
loadArtThumb();
artThumbSrol.source = artThumbBox;
//LOAD THUMBNAILS
function loadArtThumb():void
var sArtLoader:Loader = new Loader();
sArtLoader.load(new URLRequest(artThumbnailImage[artImageNum]));
sArtLoader.x = 137 * artImageNum;
//STORE INFO IN THUMBNAILS
var lArtLoader:Loader = new Loader();
lArtLoader.load(new URLRequest(artLargeImage[artImageNum]));
var thisTitle:String = artTitle[artImageNum];
var thisDescription:String = artDescription[artImageNum];
sArtLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, artThumbLoaded);
function artThumbLoaded(event:Event):void
//ADD THUMBNAIL
artThumbBox.addChild(sArtLoader);
artThumbBox.buttonMode = true;
artThumbSrol.update();
sArtLoader.addEventListener(MouseEvent.CLICK, artLoadMainImage);
function artLoadMainImage(event:MouseEvent):void
//ADD LARGE IMAGE AND TEXT, SHOULD SWAP ON THUMBNAIL CLICK
artImageL.addChild(lArtLoader);
artHeadL.text = thisTitle;
artTextL.htmlText = thisDescription;
artTextL.wordWrap = true;
artImageNum++;
if (artImageNum < maxImages)
loadArtThumb();In this function:
function artLoadMainImage(event:MouseEvent):void
//ADD LARGE IMAGE AND TEXT, SHOULD SWAP ON THUMBNAIL CLICK
artImageL.addChild(lArtLoader);
artHeadL.text = thisTitle;
artTextL.htmlText = thisDescription;
artTextL.wordWrap = true;
you are taking whatever is in lArtLoader and adding it to artImageL as a new child object. So with every new click you are slapping down a new image on top of whatever is already there. To get rid of any existing child objects just look at what's in artImageL and toss it out before you put in anything new. It might look something like this:
function artLoadMainImage(event:MouseEvent):void
//ADD LARGE IMAGE AND TEXT, SHOULD SWAP ON THUMBNAIL CLICK
if(artImageL.numChildren > 0) {
artImageL.removeChildAt(0);
artImageL.addChild(lArtLoader);
artHeadL.text = thisTitle;
artTextL.htmlText = thisDescription;
artTextL.wordWrap = true; -
I am trying to delete all nodes from one parent node using the code below. However, this is not working. I have 12 children, but it only loops 6 times and also, the original xml file is not changed. The question that I have is, do I need to save the DOM doc back in order for the changes to take affect and also, why doesn't this code loop 12 times.
NodeList nd3 = nd2.item(0).getChildNodes();
System.out.println(nd3.getLength()); <-- prints 12
for (int m = 0; m < nd3.getLength(); m++) {
Node nod2 = nd3.item(m);
Node parent = nod2.getParentNode();
parent.removeChild(nod2);
System.out.println(nd3.getLength()); <-- prints 6Thanks. LukeThe classic delete-all gotcha!
You have children A, B, C, D, E, F (let's limit the example to 6).
You remove index 0, now you have children B, C, D, E, F.
You remove index 1, now you have children B, D, E, F.
You remove index 2, now you have children B, D, F.
You remove index 3... there isn't any index 3 so nothing happens. And so on.
How to fix your code? Always remove index 0 is one way.
PC² -
Where to put removeChild (Away3d 4.x)
Hey guys i need some help on how to change primitives and removing the previous primitive showing in the scene and also changing materials on the primitive with a click of a button.
Mainly just where to put removeChild.
This is for Away3d
package
import away3d.cameras.*;
import away3d.containers.*;
import away3d.controllers.*;
import away3d.core.base.SubGeometry;
import away3d.core.base.data.Vertex;
import away3d.debug.*;
import away3d.entities.Mesh;
import away3d.extrusions.*;
import away3d.filters.*;
import away3d.lights.*;
import away3d.materials.*;
import away3d.materials.lightpickers.*;
import away3d.materials.methods.*;
import away3d.primitives.*;
import away3d.textures.*;
import away3dplus.controllers.SimpleHoverController;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Vector3D;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
[SWF(backgroundColor="#000000",frameRate="30",quality="LOW")]
public class Main extends Sprite
//engine variables
private var view:View3D;
private var scene:Scene3D;
// debug
private var awayStats:AwayStats;
//light objects
private var pointLight:PointLight;
private var lightPicker:StaticLightPicker;
//material objects
private var redColorMaterial:ColorMaterial;
private var skyBoxCubeTexture:BitmapCubeTexture;
//Buttons
private var btnCube:Sprite = new Sprite
private var btnSphere:Sprite = new Sprite
private var btnCylinder:Sprite = new Sprite
private var btnTorus:Sprite = new Sprite
private var btnMaterial:Sprite = new Sprite
private var btnWireframe:Sprite = new Sprite
public function Main() {
init();
private function init():void {
initEngine();
initLights();
initCamera();
initMaterials();
initObjects();
initListeners();
drawButton()
btnCube.addEventListener(MouseEvent.CLICK, changeCube);
btnCube.x = 400;
btnCube.y = 25;
addChild(btnCube);
btnSphere.addEventListener(MouseEvent.CLICK, changeSphere);
btnSphere.x = 400;
btnSphere.y = 60;
addChild(btnSphere);
btnCylinder.addEventListener(MouseEvent.CLICK, changeCylinder);
btnCylinder.x = 400;
btnCylinder.y = 95;
addChild(btnCylinder);
btnTorus.addEventListener(MouseEvent.CLICK, changeTorus);
btnTorus.x = 400;
btnTorus.y = 130;
addChild(btnTorus);
//btnMaterial.addEventListener(MouseEvent.CLICK, changeMaterial);
btnMaterial.x = 15;
btnMaterial.y = 95;
addChild(btnMaterial);
btnWireframe.addEventListener(MouseEvent.CLICK, changeWireframe);
btnWireframe.x = 15;
btnWireframe.y = 130;
addChild(btnWireframe);
* Initialise the engine
private function initEngine():void {
//stage setup
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
// 3d view - window into 3d scene
view = new View3D();
addChild(view);
// 3d scene.
scene = view.scene;
// stats
awayStats = new AwayStats(view);
addChild(awayStats);
* Initialise the lights
private function initLights():void {
//point light
pointLight = new PointLight();
scene.addChild(pointLight);
lightPicker = new StaticLightPicker([pointLight]);
private function initCamera():void {
var hoverCameraManager:SimpleHoverController = new SimpleHoverController(view, 700, [pointLight]);
* Initialise Buttons
private function drawButton():void {
var textLabel:TextField = new TextField()
btnCube.graphics.clear();
btnCube.graphics.beginFill(0xFFFFFF); // white
btnCube.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
textLabel.text = "CUBE";
textLabel.x = 22;
textLabel.y = 4;
textLabel.selectable = false;
btnCube.addChild(textLabel)
var textLabel01:TextField = new TextField()
btnSphere.graphics.clear();
btnSphere.graphics.beginFill(0xFFFFFF); // white
btnSphere.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
textLabel01.text = "SPHERE";
textLabel01.x = 18;
textLabel01.y = 3;
textLabel01.selectable = false;
btnSphere.addChild(textLabel01)
var textLabel03:TextField = new TextField()
btnCylinder.graphics.clear();
btnCylinder.graphics.beginFill(0xFFFFFF); // white
btnCylinder.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
textLabel03.text = "CYLINDER";
textLabel03.x = 10;
textLabel03.y = 3;
textLabel03.selectable = false;
btnCylinder.addChild(textLabel03)
var textLabel04:TextField = new TextField()
btnTorus.graphics.clear();
btnTorus.graphics.beginFill(0xFFFFFF); // white
btnTorus.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
textLabel04.text = "TORUS";
textLabel04.x = 17;
textLabel04.y = 3;
textLabel04.selectable = false;
btnTorus.addChild(textLabel04)
var textLabel05:TextField = new TextField()
btnMaterial.graphics.clear();
btnMaterial.graphics.beginFill(0xFFFFFF); // white
btnMaterial.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
textLabel05.text = "MATERIAL";
textLabel05.x = 6;
textLabel05.y = 3;
textLabel05.selectable = false;
btnMaterial.addChild(textLabel05)
var textLabel06:TextField = new TextField()
btnWireframe.graphics.clear();
btnWireframe.graphics.beginFill(0xFFFFFF); // white
btnWireframe.graphics.drawRoundRect(0, 0, 80, 25, 10, 10); // x, y, width, height, ellipseW, ellipseH
textLabel06.text = "WIREFRAME";
textLabel06.x = 2;
textLabel06.y = 3;
textLabel06.selectable = false;
btnWireframe.addChild(textLabel06)
* Initialise the materials
private function initMaterials():void {
// red color
redColorMaterial = new ColorMaterial(0xFF0000, 0.8);
redColorMaterial.lightPicker = lightPicker;
skyBoxCubeTexture = new BitmapCubeTexture(new EnvPosX().bitmapData, new EnvNegX().bitmapData, new EnvPosY().bitmapData, new EnvNegY().bitmapData, new EnvPosZ().bitmapData, new EnvNegZ().bitmapData);
* Initialise the scene objects
private function initObjects():void {
var trident:Trident = new Trident(100);
trident.x = 0;
trident.y = 0;
scene.addChild(trident);
//Geometry - Geometry is a collection of SubGeometries, each of which contain the actual geometrical data such as vertices, normals, uvs, etc.
////PrimitiveBase - PrimitiveBase is an abstract base class for mesh primitives, which are prebuilt simple meshes.
//CubeGeometry A Cube primitive mesh.
var newCubeGeometry:CubeGeometry = new CubeGeometry(200, 200, 200, 50, 50, 50, true);
//SphereGeometry - A UV Sphere primitive mesh.
var newSphereGeometry:SphereGeometry = new SphereGeometry(50, 16, 12, true);
//CapsuleGeometry A UV Capsule primitive mesh.
var newCapsuleGeometry:CapsuleGeometry = new CapsuleGeometry(50, 100, 16, 12, true);
//ConeGeometry A UV Cone primitive mesh.
//var newConeGeometry:ConeGeometry = new ConeGeometry(50, 100, 16, 1, true, true);
//CylinderGeometry A UV Cylinder primitive mesh.
var newCylinderGeometry:CylinderGeometry = new CylinderGeometry(50, 50, 100, 16, 1, true, true);
//PlaneGeometry A Plane primitive mesh.
var newPlaneGeometry:PlaneGeometry = new PlaneGeometry(100, 100, 1, 1, true);
//RegularPolygonGeometry A UV RegularPolygon primitive mesh.
var newRegularPoligonGeometry:RegularPolygonGeometry = new RegularPolygonGeometry(100, 16, true);
//TorusGeometry A UV Torus primitive mesh.
var newTorusGeomentry:TorusGeometry = new TorusGeometry(50, 50, 15, 8, true);
// Entity - The Entity class provides an abstract base class for all scene graph objects that are considered having a "presence" in the scene,
// in the sense that it can be considered an actual object with a position and a size (even if infinite or idealised), rather than a grouping.
//Mesh - Mesh agregates instance of a Geometry, augmenting it with a presence in the scene graph, a material, and an animations tate.
// It consists out of SubMeshes, which in turn correspond to SubGeometries. SubMeshes allow different parts of the geometry to be assigned different materials.
//var cube:Mesh = new Mesh(newCubeGeometry, redColorMaterial);
//cube.x = 100;
//cube.y = 100;
//cube.z = 100;
//scene.addChild(cube);
//var sphere:Mesh = new Mesh(newSphereGeometry, redColorMaterial);
//sphere.x = -75;
//sphere.y = -150;
//scene.addChild(sphere);
//var capsule:Mesh = new Mesh(newCapsuleGeometry, redColorMaterial);
//capsule.x = -200;
//capsule.y = -150
//scene.addChild(capsule);
//var cone:Mesh = new Mesh(newConeGeometry, redColorMaterial);
//cone.x = -200;
//cone.y = 150;
//cone.showBounds = true;
//scene.addChild(cone);
//var cylinder:Mesh = new Mesh(newCylinderGeometry, redColorMaterial);
//cylinder.x = -75;
//cylinder.y = 150;
//scene.addChild(cylinder);
//var plane:Mesh = new Mesh(newPlaneGeometry, redColorMaterial);
//plane.x = -75;
//plane.y = 275;
//scene.addChild(plane);
//var poligon:Mesh = new Mesh(newRegularPoligonGeometry, redColorMaterial);
//poligon.x = -275;
//poligon.y = 275;
//scene.addChild(poligon);
//var torus:Mesh = new Mesh(newTorusGeomentry, redColorMaterial);
//torus.x = -275;
//scene.addChild(torus);
//SkyBox A SkyBox class is used to render a sky in the scene.
//var skyBox:SkyBox = new SkyBox(skyBoxCubeTexture);
//scene.addChild(skyBox);
// SegmentSet
//WireframeAxesGrid - Class WireframeAxesGrid generates a grid of lines on a given planeWireframeAxesGrid
//var wireFrameAxesGrid:WireframeAxesGrid = new WireframeAxesGrid(4, 400, 1);
//scene.addChild(wireFrameAxesGrid);
//WireframeGrid Class WireframeGrid generates a grid of lines on a given planeWireframeGrid
//var wireframeGrid:WireframeGrid = new WireframeGrid(10, 100, 5, 0x0000FF);
//wireframeGrid.x = 75;
//wireframeGrid.y = 275;
//scene.addChild(wireframeGrid);
//WireframePrimitiveBase
//WireframeCube - Class WireFrameGrid generates a grid of lines on a given planeWireFrameGrid
//var wireFrameCube:WireframeCube = new WireframeCube(100, 100, 100, 0x0000FF, 5);
//wireFrameCube.x = 75;
//scene.addChild(wireFrameCube);
//WireframeSphere - Class WireFrameGrid generates a grid of lines on a given planeWireFrameGrid
//var wireFrameSphere:WireframeSphere = new WireframeSphere(50, 16, 12, 0x0000FF, 5);
//wireFrameSphere.x = 75;
//wireFrameSphere.y = -150;
//scene.addChild(wireFrameSphere);
//WireframePlane
//var wireframePlane:WireframePlane = new WireframePlane(100, 100, 10, 10, 0x0000FF, 5);
//wireframePlane.x = 175;
//wireframePlane.y = 275;
//scene.addChild(wireframePlane);
* Initialise the listeners
private function initListeners():void {
addEventListener(Event.ENTER_FRAME, onEnterFrame);
* render loop
private function onEnterFrame(event:Event):void {
view.render();
* Intialise the buttons events
private function changeCube(event:MouseEvent):void {
var newCubeGeometry:CubeGeometry = new CubeGeometry(200, 200, 200, 50, 50, 50, true);
var cube:Mesh = new Mesh(newCubeGeometry, redColorMaterial);
cube.x = 100;
cube.y = 100;
cube.z = 100;
scene.addChild(cube);
private function changeSphere(event:MouseEvent):void {
var newSphereGeometry:SphereGeometry = new SphereGeometry(50, 16, 12, true);
var sphere:Mesh = new Mesh(newSphereGeometry, redColorMaterial);
scene.addChild(sphere);
private function changeCylinder(event:MouseEvent):void {
var newCylinderGeometry:CylinderGeometry = new CylinderGeometry(50, 50, 100, 16, 1, true, true);
var cylinder:Mesh = new Mesh(newCylinderGeometry, redColorMaterial);
scene.addChild(cylinder);
private function changeTorus(event:MouseEvent):void {
var newTorusGeomentry:TorusGeometry = new TorusGeometry(50, 50, 15, 8, true);
var torus:Mesh = new Mesh(newTorusGeomentry, redColorMaterial);
scene.addChild(torus);
private function changeWireframe(event:MouseEvent):void {
var wireFrameCube:WireframeCube = new WireframeCube(100, 100, 100, 0x0000FF, 5);
scene.addChild(wireFrameCube);
Thanks, MatthewFraudulent seller.
I received an empty package.- -
Back to the drawing board.
Thanks for your replies.
eBay is going through their required steps.
It will take a week or better to get my refund.
Thanks
Shopping for another "Mac Pro Late 2013" or I might settle for my "Mac Mini 2012 i7 16 Gig 256 SSD Intel 4000" refurb with warranty bought from Apple that I already have on hand.
Thank You
I don't know how this ended upon two threads.
I'm pretty sure I'm going to go with my 2012 Mac Mini i7 16 gig 256 SSD and Lacie Little Big Thunderbolt 1 512 SSD
That will be pretty punchy for me.
I'll only have about $1,000 in the computer itself with a three year Apple Care Warranty.
It should sell for $500 a year from now if I choose too.
I think it's going to work great.
I'm going to load it up with all of the software just like I was going to do on the Mac Pro.
It's good for three computers in the future so no money lost on the software
I'll probably just keep the Mini indefinitely for a backup even after I upgrade to the newer 2015 Mac Pro later next year.
Thanks -
Trouble unloading jpeg with unload() or removeChild()
Hi Everyone,
I'm working on a project that is like a jigsaw puzzle. The use can select from a few different puzzles that have different piece arrangements. Once the puzzle swf file is loaded, the user can select images from a gallery to place in the pieces to make a custom puzzle where the puzzle piece movie clip that was selected masks the image that was selected.
So the puzzle swf loads fine and I add it to the stage with:
addChild(puzzle);
The jpegs also load and get masked correctly. When I add the jpeg image, I add it to the puzzle object and the addChild looks like this:
puzzle.addChild(imageJPEGLoader);
imageJPEGLoader.load(new URLRequest(imageJPEGName));
imageJPEGLoader.x = 0;
imageJPEGLoader.y = 0;
imageJPEGLoader.mask = puzzle.maskPiece1_mc;
Where imageJPEGLoader is the loader I use to get the jpeg image.
Everything works great. However, if the user wants to change the image used, I want to remove the child (right?).
I thought this would work:
puzzle.removeChild(imageJPEGLoader);
but it doesn't. I get the following error:
ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display::DisplayObjectContainer/removeChild()
at puzzle.fla::MainTimeline/getImage()
I think I'm obviously not understanding the parent/child relationship fully. I thought if imageJPEGLoader was inside puzzle, that the dot syntax would get me to the object I needed. Everything works fine in this file except for putting a new jpeg on a piece that already had a jpeg masked.
Can someone please point me in the right direction?Can you show all of the relevant code as it is arranged in your file (functions, etc)?
-
I want to use for next loop to reduce code for doing removechild()'s
I have working if (addChild(bmp1)) ----removeChild(bmp1). But I need to do it 20 times. I thought I could use a for/next loop, but so far can't seem to get it right.
for (var i:Number=0; i<21; I++)
my_bmp.name = "bmp" + 1;
if (addChild(my_bmp))
removeChild(my_bmp);
This code passing the compiler, but when I execute it I get "A term is undefined and has no properties". I'm thinking it has something to do with my_bmp.name? I've tried several things and just can't crack it.The name of an object is just a string. to have the compiler treat it as an object you can use the getChildByName() method or even the bracket notation.
removeChild(this.getChildByname(my_bmp));
OR
removeChild(this[my_bmp]);
I am guessing that you intend to use "bmp"+String(i) instead of "bmp"+1 -
AddChild and removeChild (AS 3)
Hi
If I load an external swf (located in the same dir as the one
loading it) with addChild. It looks something like this
var url:String = "patfinder_extra1.swf";
var urlReq:URLRequest = new URLRequest(url);
ldr.load(urlReq);
addChild(ldr);
Now, I want to be able to close/remove this new child within
itself, image a little close button with the label "I'm a child and
will close my self if i click here!".
Now, this removeChild is a mystery and the new restrictions
in paths in AS 3 really makes it hard. To simply use
this.removeChild() returns errors.
Any tips of how to close this thingy?
:)you can use the code below to have the child movieclip remove
itself from its parent's display list, but that won't clear it for
garbage collection.
i would have the child call a function in the parent that
removes it and nulls all references to its loader so it can be
garage collected. -
It seems like the removeChild and unload method do the same
thing. Is it necessary to do both when you're removing the display
of an external swf from the stage?
Also, after loading in an external file then running code to
remove it, whether you use removeChild, unload, or both, the sound
will continue even though the movie is removed from the
DisplayList/stage. I've found a workaround which is using
Loader.content with the stop method and it works fine. However I am
wondering why the sound would continue even though removeChild
and/or unload removes the movie from the DisplayList/stage.
Thanks...
BrendaThe only way the Flash player will stop a sound from an
external SWF is by properly garbage collecting the sound object and
all of its events. This will only be done when there is absolutely
nothing referencing the object or any of its events.
The difference between removeChild and unload, is that unload
removes the content of the loader object, whereas removeChild can
potentially remove the loader object itself from the display
list.
Maybe you are looking for
-
HELP Needed with this error: Exception in thread "main" java.lang.NoClass
Folks, I am having a problem connecting to my MSDE SQL 2000 DB on a WindowsXP pro. environment. I am learning Java and writing a small test prgm to connect the the database. The code compiles ok, but when I try to execute it i keep getting this error
-
I need information on the DEFINE keyword on plSQL. There is a package which has definitions as below DEFINE A = &1 DEFINE B = &2 DEFINE C = &3 Begin End;/ The data for this being substituted through a .bat file whose content is as below sqlplus wedb/
-
Have iPhoto8.1.2, incompatible with OSX10.10.3, need to access iPhoto for some photos
-
Need avice..for beginner with FCP
I captured all my footage, however when wanted to start editing it asked me to render first which I did. But after I wanted to play my footage in the canvas it told me that some clips were dropped. I reset my canvas on "Full Window" and I was able to
-
Hello. I'm using Discoverer Viewer - version 9.0.2.54.10 and I'm having this problem. I generate a Report with a few parameters and some of them have a lot of values, more than 2048 characters. The thing is that I can see the table with data but the