Search Results

Search found 159 results on 7 pages for 'removechild'.

Page 1/7 | 1 2 3 4 5 6 7  | Next Page >

  • XmlNode.RemoveChild() recursive

    - by Lord Vader
    Hi, my problem is the following: How can I remove selected ChildNodes from XmlNode recursively? My XML-file looks like... ..<element type="TextBox" id="xslFilePath"> <parameters> <parameter id="description"> <value><![CDATA[Pfad zur XSL]]></value> <value lang="en"><![CDATA[XSL-file's path]]></value> </parameter> <parameter id="tooltip"> <value><![CDATA[Pfad zur XSL]]></value> <value lang="en"><![CDATA[XSL-file's path]]></value> </parameter> </parameters> <values> <value><![CDATA[/include/extensions/languageReferences/xsl/default.xsl]]></value> </values> </element> <element type="DropDownList" id="imageOrientation"> <parameters> <parameter id="description"> <value><![CDATA[Anordnung]]></value> <value lang="en"><![CDATA[Orientation]]></value> </parameter> <parameter id="tooltip"> <value><![CDATA[Anordnung]]></value> <value lang="en"><![CDATA[Orientation]]></value> </parameter> </parameters> <items> <item id="" selected="true"> <parameters> <parameter id="value"> <value><![CDATA[vertical]]></value> </parameter> <parameter id="description"> <value><![CDATA[senkrecht]]></value> <value lang="en"><![CDATA[vertical]]></value> </parameter> </parameters> </item> <item id="" selected="false"> <parameters> <parameter id="value"> <value><![CDATA[horizontal]]></value> </parameter> <parameter id="description"> <value><![CDATA[waagerecht]]></value> <value lang="en"><![CDATA[horizontal]]></value> </parameter> </parameters> </item> </items> <values> <value><![CDATA[horizontal]]></value> </values> </element>... I would like to remove all nodes (type of value) where the parentNode is type of parameter with id="description" but not value-notes as children of values or parameter with id="value" In XSLT I would say e.g.: //value[parent::parameter[@id='description'] and @lang='en']The problem is: I have the language code: e.g. "de" and now I would like to remove all sibling value nodes if an value with lang="de" exists and remove all sibling nodes excluding the value without any lang-attribute if lang="de" not exists (as fallback) I hope, you can help me to write an c# Code to replace recursively all undesired value-nodes.

    Read the article

  • Trying to use RemoveChild() on XmlNodeList messes up my XmlNode collection

    - by user299090
    Hi there, I'm trying to remove a specific node from a XmlNodeList named listaWidths. This specific list has 5 items before I use RemoveChild(). But, after the RemoveChild() statement, the list stays only with 1 item. XmlNodeList listaWidths = xmlDoc.SelectNodes("/MsBuild:Report/MsBuild:Body/MsBuild:ReportItems/MsBuild:Tablix/MsBuild:TablixBody/MsBuild:TablixColumns/*", nsmgr); int indexEpoca = 0; //Remover época XmlNode node = listaWidths[indexEpoca]; XmlNode parent = listaWidths[indexEpoca].ParentNode; parent.RemoveChild(node); This is a RDL Reporting Services XML. The specific XML code is here: <Tablix Name="Tablix3"> <TablixBody> <TablixColumns> <TablixColumn> <Width>1.602in</Width> </TablixColumn> <TablixColumn> <Width>1.61in</Width> </TablixColumn> <TablixColumn> <Width>1.6323in</Width> </TablixColumn> <TablixColumn> <Width>1.6023in</Width> </TablixColumn> <TablixColumn> <Width>1.6033in</Width> </TablixColumn> </TablixColumns> (...) I've tried every combination possible, with no luck whatsoever. What am I doing wrong? Thank you.

    Read the article

  • ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller error - AS

    - by Dimitree
    I have this code snippet inside a function that checks if an object exists on stage and removes it: public function closeContent(e:MouseEvent):void{ removeChild(txt); removeChild(ldr.content); removeChild(_closeButton); container_mc.visible = false; statusText.text=""; if (contains(submitButton)) { removeChild(submitButton); } if(contains(saveinfoButton)) { removeChild(saveinfoButton);} I tried to change stage with this and root but alawys get this error ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller

    Read the article

  • javascript removeChild() and appendChild() VS display=none and display=block|inline

    - by Kucebe
    I'm developing a web application that shows some controls and descriptions dinamically (I don't want to use jQuery or other libraries). At this moment i make appear and disappear controls using: element.setAttribute("style", "inline"); and element.setAttribute("style", "none"); but i'm thinking about using: element.appendChild(childRef); and element.removeChild(childRef); So, which one is the best solution in terms of system speed and elegance of the code? (and of course, are there better solution?)

    Read the article

  • javascript removeChild(this) from input[type="submit"] onclick breaks future use of form.submit() un

    - by maximumduncan
    I have come across some strange behaviour, and I'm assuming a bug in firefox, when removing a input submit element from the DOM from within the click event. The following code reproduces the issue: <form name="test_form"> <input type="submit" value="remove me" onclick="this.parentNode.removeChild(this);" /> <input type="submit" value="submit normally" /> <input type="button" value="submit via js" onclick="document.test_form.submit();" /> </form> To reproduce: Click "remove me" Click "submit via js". Note that the form does not get submitted, this is the problem. Click "submit normally". Note that the form still gets submitted normally. It appears that, under Firefox, if you remove a submit button from within the click event it puts the form in an invalid state so that any future calls to form.submit() are simply ignored. But it is a javascript-specific issue as normal submit buttons within this form still function fine. To be honest, this is such a simple example of this issue that I was expecting the internet to be awash with other people exeriencing it, but so far searching has yealded nothing useful. Has anyone else experienced this and if so, did you get to the bottom of it? Many thanks

    Read the article

  • Javascript .removeChild() only deletes even nodes?

    - by user1476297
    first posting. I am trying dynamically add children DIV under a DIV with ID="prnt". Addition of nodes work fine no problem. However strange enough when it comes to deleted nodes its only deleting the even numbered nodes including 0. Why is this, I could be something stupid but it seem more like a bug. I could be very wrong. Please help Thank you in advance. <script type="text/javascript"> function displayNodes() { var prnt = document.getElementById("prnt"); var chlds = prnt.childNodes; var cont = document.getElementById("content"); for(i = 0; i < chlds.length; i++) { if(chlds[i].nodeType == 1) { cont.innerHTML +="<br />"; cont.innerHTML +="Node # " + (i+1); cont.innerHTML +="<br />"; cont.innerHTML +=chlds[i].nodeName; cont.innerHTML +="<br />"; } } } function deleteENodes() { var prnt = document.getElementById("prnt"); var chlds = prnt.childNodes; for(i = 0; i < chlds.length; i++) { if(!(chlds[i].nodeType == 3)) { prnt.removeChild(chlds[i]); } } } function AddENodes() { var prnt = document.getElementById("prnt"); //Only even nodes are deletable PROBLEM for(i = 0; i < 10; i++) { var newDIV = document.createElement('div'); newDIV.setAttribute("id", "c"+(i)); var text = document.createTextNode("New Inserted Child "+(i)); newDIV.appendChild(text); prnt.appendChild(newDIV); } } </script> <title>Checking Div Nodes</title> </head> <body> <div id="prnt"> Parent 1 </div> <br /> <br /> <br /> <button type="button" onclick="displayNodes()">Show Node Info</button> <button type="button" onclick="deleteENodes()">Remove All Element Nodes Under Parent 1</button> <button type="button" onclick="AddENodes()">Add 5 New DIV Nodes</button> <div id="content"> </div> </body>

    Read the article

  • ActionScripting Issue: adding/removing children

    - by user1890698
    I have three movie clips all linked to the stage and I want them to behave like a button/ But I am not using a button because I have not found a way to have each part (up, over, down, hit) be animated and not just change when the mouse is in use with it. So far I have been able to have all three appear on my stage and show when I have the mouse over and as well when I click, but I think I'm doing something wrong with removeChild. Each MC should appear one at a time and now all three show up when I hover over and seem to "flash". Here's my code: var mainMoon:swayingMoon = new swayingMoon(); mainMoon.x = 50; mainMoon.y = 10; addChild(mainMoon); var hoverMoon:glowMoon = new glowMoon(); hoverMoon.x = 50; hoverMoon.y = 10; var movieMoon:clickedMoon = new clickedMoon(); movieMoon.x = 50; movieMoon.y = 10; mainMoon.addEventListener(MouseEvent.ROLL_OVER, showHoverMoon); mainMoon.addEventListener(MouseEvent.ROLL_OUT, hideHoverMoon); hoverMoon.addEventListener(MouseEvent.CLICK, startMovieMoon) function showHoverMoon(event:MouseEvent):void { addChild(hoverMoon); } function hideHoverMoon(event:MouseEvent):void { removeChild(hoverMoon) } function startMovieMoon(event:MouseEvent):void { addChild(movieMoon); }

    Read the article

  • how to remove dynamically loaded images in javascript

    - by jesse
    I'm loading in 3 images (named 1.jpg, 2.jpg, 3jpg) dynamically to 3 divs called "div1", "div2" and "div3". function loadImages() { for (var i = 1; i < 3; i++ ) { var img = document.createElement("img"); img.src = "vegetables/"+i+".jpg"; img.id = "a"+i+""; var divName = "div"+i+""; document.getElementById(divName).appendChild(img); } } That works, but the removing part I can't seem to get to work.. function removeImages() { for (var i = 1; i < 3; i++ ) { var oldImages = "a"+i+""; var divName = "div"+i+""; document.getElementById(divName).removeChild(oldImages); } } Thank you.

    Read the article

  • Remove a child of root of XML using java

    - by Sachin Mhetre
    This is my xml file. - <deviceparameters> - <parameter componenttype="TextBox"> <name>Operating Type</name> <oid>1.3.6.1.4.1.31163.5.1.1</oid> <writable>true</writable> <description>The operating type defines which waveform type is used. This configuration takes several seconds to execute</description> - <paramvalues type="Integer"> <value default="No">123</value> </paramvalues> </parameter> - <parameter componenttype="TextBox"> <name>Active Waveform Status</name> <oid>1.3.6.1.4.1.31163.5.1.2</oid> <writable>false</writable> <description>Show the status of the waveform configured by operatingType</description> - <paramvalues type="String"> <value default="yes">Active</value> </paramvalues> </parameter> </deviceparameters> I want to remove node with name 'Active wavwform Status'. How can I reomve that particular node from xml. The code I have written is below. rootElement = doc.getDocumentElement(); NodeList nList = doc.getElementsByTagName("parameter"); String nodeName = TF_name.getText(); System.out.println(""+nList.getLength()); for (int temp = 0; temp < nList.getLength();temp++) { Node nNode = nList.item(temp); Element eElement = (Element) nNode; String upname1 = getTagValue("name", eElement); if(upname1.equals(nodeName)) { System.out.println("Parent: "+nNode.getParentNode().getNodeName()); System.out.println("nodename: "+nNode.getNodeName()); System.out.println("rmoving ...."); rootElement.removeChild(nNode); System.out.println("removed..."); } }

    Read the article

  • Help on Removal of Dynamically Created sprites.

    - by Brrr Ice Tea
    import flash.display.Sprite; import flash.net.URLLoader; var index:int = 0; var constY = 291; var constW = 2; var constH = 40; hydrogenBtn.label = "Hydrogen"; heliumBtn.label = "Helium"; lithiumBtn.label = "Lithium"; hydrogenBtn.addEventListener (MouseEvent.CLICK, loadHydrogen); heliumBtn.addEventListener (MouseEvent.CLICK, loadHelium); lithiumBtn.addEventListener (MouseEvent.CLICK, loadLithium); var myTextLoader:URLLoader = new URLLoader(); myTextLoader.addEventListener(Event.COMPLETE, onLoaded); function loadHydrogen (event:Event):void { myTextLoader.load(new URLRequest("hydrogen.txt")); } function loadHelium (event:Event):void { myTextLoader.load(new URLRequest("helium.txt")); } function loadLithium (event:Event):void { myTextLoader.load(new URLRequest("lithium.txt")); } var DataSet:Array = new Array(); var valueRead1:String; var valueRead2:String; function onLoaded(event:Event):void { var rawData:String = event.target.data; for(var i:int = 0; i<rawData.length; i++){ var commaIndex = rawData.search(","); valueRead1 = rawData.substr(0,commaIndex); rawData = rawData.substr(commaIndex+1, rawData.length+1); DataSet.push(valueRead1); commaIndex = rawData.search(","); if(commaIndex == -1) {commaIndex = rawData.length+1;} valueRead2 = rawData.substr(0,commaIndex); rawData = rawData.substr(commaIndex+1, rawData.length+1); DataSet.push(valueRead2); } generateMask_Emission(DataSet); } function generateMask_Emission(dataArray:Array):void{ var spriteName:String = "Mask"+index; trace(spriteName); this[spriteName] = new Sprite(); for (var i:int=0; i<dataArray.length; i+=2){ this[spriteName].graphics.beginFill(0x000000, dataArray[i+1]); this[spriteName].graphics.drawRect(dataArray[i],constY,constW, constH); this[spriteName].graphics.endFill(); } addChild(this[spriteName]); index++; } Hi, I am relatively new to flash and action script as well and I am having a problem getting the sprite to be removed after another is called. I am making emission spectrum's of 3 elements by dynamically generating the mask over a picture on the stage. Everything works perfectly fine with the code I have right now except the sprites stack on top of each other and I end up with bold lines all over my picture instead of a new set of lines each time i press a button. I have tried using try/catch to remove the sprites and I have also rearranged the entire code from what is seen here to make 3 seperate entities (hoping I could remove them if they were seperate variables) instead of 2 functions that handle the whole process. I have tried everything to the extent of my knowledge (which is pretty minimal @ this point) any suggestions? Thanks ahead of time!

    Read the article

  • jQuery: one-liner for removing all children but one

    - by user1352530
    HTML code is: <li> <a href="#" /> <ul> <li> <a href="#"/> </li> </ul> </li> I want to delete any node under $(this) = li that is not a link. If there are more than one link, just the first one is saved, and if there are links inside the ul tag, they are not included because they are descendants and no childrens. Something like this (I am cloning and outputting html): $(this).clone().remove('not(a:first)').html(); //Assuming remove looks for "a" as a first child Does not work, so I try with this: $(this).clone().children().remove('not(a:first)').parent().html(); Does not work so I try with this: $(this).clone().remove('not(>a:first)').html(); I need the original element as a reference after removal for chaining more operations EDIT: Ok! Second one works with a little syntax correction as some appointed (:not( instead of not() but I would like to know if there is any other solution similar to the third line so I don't have to do children().remove().parent(). Thank you!

    Read the article

  • Jquery returns index -1 always

    - by jfreak53
    This is my index code that I use to return the buttons parent div's index: j('#optionform').index( j(this).parent() ) I'm trying to find out the DIV index of the button clicked, so I can remove the DIV. The HTML layout is like so: <form id="optionform" onsubmit="return false;"> <label><input type="checkbox" id="s_name" value="s_name"> Survey Name </label> <label><input type="checkbox" id="s_type" value="s_type"> Survey Type </label><br> Filter Results:<br> <div id="template" style="display: none;"> Column: <select id="fcolumn[]"> <option></option> <option value="s_name">Survey Name</option> <option value="s_type">Survey Type</option> </select><br> Filter Type: <select id="ftype[]"> <option></option> <option value="=">Equals</option> <option value="LIKE">Like</option> </select><br> Filter content: <input type="text" id="fcontent[]"><br> <img src="images/add.png" width="32px" onclick="addTemp(); return false;"> <img src="images/delete.png" width="32px" onclick="alert(j(this).attr('src')); remTemp(j('#optionform').index( j(this).parent() )); return false;"> </div> <div class="template" style="display: block;"> Column: <select id="fcolumn[]"> <option></option> <option value="s_name">Survey Name</option> <option value="s_type">Survey Type</option> </select><br> Filter Type: <select id="ftype[]"> <option></option> <option value="=">Equals</option> <option value="LIKE">Like</option> </select><br> Filter content: <input type="text" id="fcontent[]"><br> <img src="images/add.png" width="32px" onclick="addTemp(); return false;"> <img src="images/delete.png" width="32px" onclick="alert(j(this).attr('src')); remTemp(j('#optionform').index( j(this).parent() )); return false;"> </div> <div class="template" style="display: block;"> Column: <select id="fcolumn[]"> <option></option> <option value="s_name">Survey Name</option> <option value="s_type">Survey Type</option> </select><br> Filter Type: <select id="ftype[]"> <option></option> <option value="=">Equals</option> <option value="LIKE">Like</option> </select><br> Filter content: <input type="text" id="fcontent[]"><br> <img src="images/add.png" width="32px" onclick="addTemp(); return false;"> <img src="images/delete.png" width="32px" onclick="alert(j(this).attr('src')); remTemp(j('#optionform').index( j(this).parent() )); return false;"> </div> </form> But it always returns -1 in the index.

    Read the article

  • removeChild on a li inside a ul inside a div with an id?

    - by Prozaker
    I have the following code on a webpage: <div id="emails"> <ul> <li>email1</li> <li>email2</li> </ul> </div> <a href="#" onClick="javascript:deleteEmail">click</a> and I want to remove the first email, i've been trying with this: function deleteEmail(){ var ul = document.getElementById('alt_emails').getElementsByTagName('ul'); ul.removeChild(ul.childNodes[0]); } im kinda new to Javascript DOM, so if there's a better way to do it, please let me know. Note: I would like to do this without any kind of js framework.

    Read the article

  • TypeError: Error #1009: Cannot access a property or method of a null object reference. at RECOVER_fyp1_fla::MainTimeline/abc1()

    - by user2643323
    TypeError: Error #1009: Cannot access a property or method of a null object reference. at RECOVER_fyp1_fla::MainTimeline/abc1() Hi, what does this mean? Can anybody figure it out? Thanks. Code: swatter.addEventListener(Event.ENTER_FRAME,abc1); Mouse.hide(); function abc1(e:Event) { swatter.x = mouseX; swatter.y = mouseY; enter code here mosq1.y = mosq1.y + 2; mosq2.y = mosq2.y + 3; mosq3.y = mosq3.y + 4; mosq4.y = mosq4.y + 5; mosq5.y = mosq5.y + 6; if (mosq1.y > 640) { mosq1.y = -50; } if (mosq2.y > 640) { mosq2.y = -50; } if (mosq3.y > 640) { mosq3.y = -50; } if (mosq4.y > 640) { mosq4.y = -50; } if (mosq5.y > 640) { mosq5.y = -50; } if(swatter.hitTestObject(mosq1)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq1.parent.removeChild(mosq1); } if(swatter.hitTestObject(mosq2)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq2.parent.removeChild(mosq2); } if(swatter.hitTestObject(mosq3)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq3.parent.removeChild(mosq3); } if(swatter.hitTestObject(mosq4)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq4.parent.removeChild(mosq4); } if(swatter.hitTestObject(mosq5)) { //SoundMixer.stopAll(); //three_start_sound1.play(); mosq5.parent.removeChild(mosq5); } } enter code here

    Read the article

  • Change collision action

    - by PatrickR
    I have a collision detection and its working fine, the problem is, that whenever my "bird" is hitting a "cloud", the cloud dissapers and i get some points. The same happens for the "sol" which it should, but not with the clouds. How can this be changed ? ive tryed a lot, but can seem to figger it out. Collision Code - (void)update:(ccTime)dt { bird.position = ccpAdd(bird.position, skyVelocity); NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init]; for (CCSprite *bird in _projectiles) { bird.anchorPoint = ccp(0, 0); CGRect absoluteBox = CGRectMake(bird.position.x, bird.position.y, [bird boundingBox].size.width, [bird boundingBox].size.height); NSMutableArray *targetsToDelete = [[NSMutableArray alloc] init]; for (CCSprite *cloudSprite in _targets) { cloudSprite.anchorPoint = ccp(0, 0); CGRect absoluteBox = CGRectMake(cloudSprite.position.x, cloudSprite.position.y, [cloudSprite boundingBox].size.width, [cloudSprite boundingBox].size.height); if (CGRectIntersectsRect([bird boundingBox], [cloudSprite boundingBox])) { [targetsToDelete addObject:cloudSprite]; } } for (CCSprite *solSprite in _targets) { solSprite.anchorPoint = ccp(0, 0); CGRect absoluteBox = CGRectMake(solSprite.position.x, solSprite.position.y, [solSprite boundingBox].size.width, [solSprite boundingBox].size.height); if (CGRectIntersectsRect([bird boundingBox], [solSprite boundingBox])) { [targetsToDelete addObject:solSprite]; score += 50/2; [scoreLabel setString:[NSString stringWithFormat:@"%d", score]]; } } // NÅR SKYEN BLIVER RAMT AF FUGLEN for (CCSprite *cloudSprite in targetsToDelete) { //[_targets removeObject:cloudSprite]; //[self removeChild:cloudSprite cleanup:YES]; } // NÅR SOLEN BLIVER RAMT AF FUGLEN for (CCSprite *solSprite in targetsToDelete) { [_targets removeObject:solSprite]; [self removeChild:solSprite cleanup:YES]; } if (targetsToDelete.count > 0) { [projectilesToDelete addObject:bird]; } [targetsToDelete release]; } // NÅR FUGLEN BLIVER RAMT AF ALT ANDET for (CCSprite *bird in projectilesToDelete) { //[_projectiles removeObject:bird]; //[self removeChild:bird cleanup:YES]; } [projectilesToDelete release]; }

    Read the article

  • DOMDocument groupping nodes, with clone, nodeClone, importNode, fragment... What the better way?

    - by Peter Krauss
    A "DOMNodeList grouper" (groupList() function below) is a function that envelopes a set of nodes into a tag. Example: INPUT <root><b>10</b><a/><a>1</a><b>20</b><a>2</a></root> OUTPUT of groupList($dom->getElementsByTagName('a'),'G') <root><b>10</b> <G><a/><a>1</a><a>2</a></G> <b>20</b></root> There are many ways to implement it, what is the better? function groupList_v1(DOMNodeList &$list,$tag,&$dom) { $list = iterator_to_array($list); // to save itens $n = count($list); if ($n && $list[0]->nodeType==1) { $T = $dom->createDocumentFragment(); $T->appendChild($dom->createElement($tag)); for($i=0; $i<$n; $i++) { $T->firstChild->appendChild( clone $list[$i] ); if ($i) $list[$i]->parentNode->removeChild($list[$i]); } $dom->documentElement->replaceChild($T,$list[0]); }//if return $n; }//func function groupList_v2(DOMNodeList &$list,$tag,&$dom) { $list = iterator_to_array($list); // to save itens $n = count($list); if ($n && $list[0]->nodeType==1) { $T = $dom->createDocumentFragment(); $T->appendChild($dom->createElement($tag)); for($i=0; $i<$n; $i++) $T->firstChild->appendChild( clone $list[$i] ); $dom->documentElement->replaceChild($T,$list[0]); for($i=1; $i<$n; $i++) $list[$i]->parentNode->removeChild($list[$i]); }//if return $n; }//func // ... YOUR SUGGESTION ... // My ugliest function groupList_vN(DOMNodeList &$list,$tag,&$dom) { $list = iterator_to_array($list); // to save itens $n = count($list); if ($n && $list[0]->nodeType==1) { $d2 = new DOMDocument; $T = $d2->createElement($tag); for($i=0; $i<$n; $i++) $T->appendChild( $d2->importNode($list[$i], true) ); $dom->documentElement->replaceChild( $dom->importNode($T, true), $list[0] ); for($i=1; $i<$n; $i++) $list[$i]->parentNode->removeChild($list[$i]); }//if return $n; }//func Related questions: at stackoverflow, at codereview.

    Read the article

  • Javascript add a PHP file.

    - by Jordan Pagaduan
    var editing = false; if (document.getElementById && document.createElement) { var butt = document.createElement('BUTTON'); var buttext = document.createTextNode('Ready!'); butt.appendChild(buttext); butt.onclick = saveEdit; } function catchIt(e) { if (editing) return; if (!document.getElementById || !document.createElement) return; if (!e) var obj = window.event.srcElement; else var obj = e.target; while (obj.nodeType != 1) { obj = obj.parentNode; } if (obj.tagName == 'TEXTAREA' || obj.tagName == 'A') return; while (obj.nodeName != 'P' && obj.nodeName != 'HTML') { obj = obj.parentNode; } if (obj.nodeName == 'HTML') return; var x = obj.innerHTML; var y = document.createElement('TEXTAREA'); var z = obj.parentNode; z.insertBefore(y,obj); z.insertBefore(butt,obj); z.removeChild(obj); y.value = x; y.focus(); editing = true; } function saveEdit() { var area = document.getElementsByTagName('TEXTAREA')[0]; var y = document.createElement('P'); var z = area.parentNode; y.innerHTML = area.value; z.insertBefore(y,area); z.removeChild(area); z.removeChild(document.getElementsByTagName('button')[0]); editing = false; } document.onclick = catchIt; This code is a quick edit and I want to add a PHP script that will UPDATE my database base on the changes on the text.

    Read the article

  • Flash AS3: Loading bar not finished when movie starts playing

    - by flashey
    Hi, I'm using the same code I always use for preloading another swf but it's not working this time. The problem this time is that when the loading bar gets to 16% every time you can hear the movie I'm loading playing in the background. I can just add a stop to the first frame of the movie I'm loading ("trial_1.swf") but how do I tell it to go to the second frame once it has loaded? Any help is much appreciated! Here's my code: var myrequest:URLRequest=new URLRequest ("trial_1.swf"); var myloader:Loader = new Loader(); myloader.load(myrequest); myloader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progresshandler); function progresshandler(myevent:ProgressEvent):void { var myprogress:Number=myevent.target.bytesLoaded/myevent.target.bytesTotal; bar_mc.scaleX=myprogress*1.5; myTextField_txt.text = Math.round(myprogress*100)+"%" } myloader.contentLoaderInfo.addEventListener(Event.COMPLETE, finished); function finished(myevent:Event):void { addChild(myloader); removeChild(myTextField_txt) removeChild(bar_mc); removeChild(logo_mc); }

    Read the article

  • Am I doing AS3 reference cleanup correctly?

    - by Ólafur Waage
    In one frame of my fla file (let's call it frame 2), I load a few xml files, then send that data into a class that is initialized in that frame, this class creates a few timers and listeners. Then when this class is done doing it's work. I call a dispatchEvent and move to frame 3. This frame does some things as well, it's initialized and creates a few event listeners and timers. When it's done, I move to frame 2 again. This is supposed to repeat as often as I need so I need to clean up the references correctly and I'm wondering if I'm doing it correctly. For sprites I do this. world.removeChild(Background); // world is the parent stage Background = null; For instances of other classes I do this. Players[i].cleanUp(world); // do any cleanup within the instanced class world.removeChild(PlayersSelect[i]); For event listeners I do this. if(Background != null) { Background.removeEventListener(MouseEvent.CLICK, deSelectPlayer); } For timers I do this. if(Timeout != null) { Timeout.stop(); Timeout.removeEventListener(TimerEvent.TIMER, queueHandler); Timeout.removeEventListener(TimerEvent.TIMER_COMPLETE, queueCompleted); Timeout = null; } And for library images I do this if(_libImage!= null) { s.removeChild(Images._libImage); // s is the stage _libImage= null; } And for the class itself in the main timeline, I do this Frame2.removeEventListener("Done", IAmDone); Frame2.cleanUp(); // the cleanup() does all the stuff above Frame2= null; Even if I do all this, when I get to frame 2 for the 2nd time, it runs for 1-2 seconds and then I get a lot of null reference errors because the cleanup function is called prematurely. Am I doing the cleanup correctly? What can cause events to fire prematurely?

    Read the article

  • Collision with CCSprite

    - by Coder404
    I'm making an iOS app based off the code from here In the .m file of the tutorial is this: -(void)update:(ccTime)dt { NSMutableArray *projectilesToDelete = [[NSMutableArray alloc] init]; for (CCSprite *projectile in _projectiles) { CGRect projectileRect = CGRectMake( projectile.position.x - (projectile.contentSize.width/2), projectile.position.y - (projectile.contentSize.height/2), projectile.contentSize.width, projectile.contentSize.height); NSMutableArray *targetsToDelete = [[NSMutableArray alloc] init]; for (CCSprite *target in _targets) { CGRect targetRect = CGRectMake( target.position.x - (target.contentSize.width/2), target.position.y - (target.contentSize.height/2), target.contentSize.width, target.contentSize.height); if (CGRectIntersectsRect(projectileRect, targetRect)) { [targetsToDelete addObject:target]; } } for (CCSprite *target in targetsToDelete) { [_targets removeObject:target]; [self removeChild:target cleanup:YES]; } if (targetsToDelete.count > 0) { [projectilesToDelete addObject:projectile]; } [targetsToDelete release]; } for (CCSprite *projectile in projectilesToDelete) { [_projectiles removeObject:projectile]; [self removeChild:projectile cleanup:YES]; } [projectilesToDelete release]; } I am trying to take away the projectiles and have the app know when the CCSprite "Player" and the targets collide. Could someone help me with this? Thanks

    Read the article

  • Enemy collision detection with movie clips

    - by user18080
    I have created multiple movieclips with animations within them. It is an obstacle avoidance game and I cannot seem to be able to get my enemies to contact my playableCharacter. The enemies I have created are each embedded on certain levels of my game. I have created an array, enemiesArray to have each of my enemies placed within it. Here is the code for that: //step 1: make sure array exists if(enemiesArray!=null && enemiesArray.length!=0) { //step 2: check all enemies against villain for(var i:int = 0;i < enemiesArray.length; i++) { //step 3: check for collision if(villain.hitTestObject(enemiesArray[i])) { //step 4: do stuff trace("HIT!"); removeChild(enemiesArray[i]); enemiesArray.splice(i,1); removeChild(villain); villain = null; } } } What I am unsure of is whether or not my enemiesArray is actually holding the movieclips I have suggested. If it was, this code would be tracing back a "HIT" for every time I ran into an enemy and would kill my character. It is not doing that however. I am thinking I have to push my movieclips into my array but I don't know how to do that or where for that matter. Any and all help would be much appreciated.

    Read the article

  • Iterate over framesets with XPath expression in JavaScript?

    - by Derek Mahar
    Why does the following JavaScript, when run in Firefox 3.6.3, delete all FRAMESET elements in a document, but the similar script that instead uses an XPath expression to select the FRAMESET elements, does not? Is document.evaluate() simply unable to match FRAMESET elements? Is there an error in the XPath expression? Is there some other error? Select all FRAMESET elements using method document.getElementsByTagName() (succeeds): var framesets = document.getElementsByTagName('frameset'); for (var i = 0; i < framesets.length; i++) { framesets[i].parentNode.removeChild(framesets[i]); } Select all FRAMESET elements using an XPath expression (fails): var framesets = document.evaluate("//frameset", document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); for (var i = 0; i < framesets.length; i++) { framesets[i].parentNode.removeChild(framesets[i]); }

    Read the article

  • Loading and removing images with DOM, Javascript

    - by jesse
    I'm new to DOM and I'm having trouble removing multiple images that I loaded this loads 7 images (1.jpg, 2.jpg, etc..) function loadImages() { for (var i = 1; i < 8; i++ ) { var img = document.createElement("img"); img.src = "images/"+i+".jpg"; var idName = "img"+i+""; document.getElementById(idName).appendChild(img); } } this should remove all of them, but doesn't.. I think it breaks at the removeChild line. function removeImages() { for (var i = 1; i < 8; i++ ) { var idName = "img"+i+""; var d = document.getElementById(idName); d.removeChild(document.getElementById(img)); } } I think I'm doing something fundamentally wrong, because I don't fully understand how this works...

    Read the article

  • In esenthel engine how can I remove some object from Gui class?

    - by Gajet
    I know many people in this site may not know esenthel engine at all and my question may be better answered at engine forum but I'm putting it here to share the name of a real easy to code gameengine with all of you: you can easily add a Button for example to your GUI class (gui is it's shared instance) with Gui += buttonInstance.create("click on me") but I'm just wondering how can you remove an on object from from Gui members. as far as I know there is no such a method as removeChild or getChildren or anything similar.

    Read the article

1 2 3 4 5 6 7  | Next Page >