Xml :: Descendants With Multiples Conditions?
Apr 21, 2011Example of my XML list:
<listnode>
<nodeA id="1">
<nodeB id="1" />
[code]......
Example of my XML list:
<listnode>
<nodeA id="1">
<nodeB id="1" />
[code]......
AS: 3.0 | Platform: Flex 3.I've been trying to figure this out for hours now and I've unable to decipher how to either correct or workaround this problem. Let me bring you up to speed. My user is doing a search, through a Tree component. To maintain the speed of the app, I convert the dataprovider to XML using the SimpleXMLEncoder (Of course this could be the start of my fall). Anyway, I have a list similar to this:[code]If that is the case, I would like the search to check those children and the grandchildren, and great grandchildren is any. So I've been trying to figure out the best method to perform this. Unfortunately, I haven't deviced a way to actually do it.I will need to be able to search the itemname and the parentid. So when I was using the descendant function I was doing this:[code]However using this method, it would never return a value, even though I know the value I am searching for is within the XML variable. So with that failure, I've decided to manually zoom through the XML to find what I am looking for. I am using a FOR LOOP to accomplish this.[code]
View 1 RepliesI'm playing with Modules and they work as advertised: the module swf's ares built and deployed in the output directories automatically. My problem is that if I use descendants of mx:Module, the IDE does NOT do all this nice work for me. I've listed the module in the Flex Modules section of the project properties, but still nothing. I'm going to end up repeating a lot of code in each module (to fulfill an interface) if I cannot figure out how to make the IDE do its thing.
View 1 Repliesi have an XML like
var test:XML = new XML( <record id="5" name="AccountTransactions"
<field id="34" type="Nuber"/>
</record>);
i want to remove all the attributes other than id and type in all nodes of XML. by this code i am unable to do this. can you suggest better solution, other than loops.
var atts:XMLListCollection = new XMLListCollection(test.descendants().attributes().((localName() != "id") && (localName() != "type")));
atts.removeAll(); trace(test)
it still show all attributes.
There must be a simpler way than to say:
PHP Code:
if(x == 5 || x == 10 || x == 15) //etc
{
y += 1;
}
Is there a way to set it so that if "x = multiple of 5" then "y += 1;"
I did a search and didn't find what I was looking for so if this is a repeat of a previous thread I apologize.
Essentially I'm looking to add multiple instances of the same mc I have in the library. I found some code while searching around, but can't seem to get it to work. I don't get multiple mc's on the stage[code]....
I am trying to determine what events I need to wait for in a test in order to ensure that my custom component has updated all of its properties. I was using VALUE_COMMIT, but for some reason that isn't working out for me. I want some easy mechanism for tracing every event dispatched from a component. Is this possible?
View 1 RepliesI've been trying to figure out how to display the descendants (in this case exchangeRate and PlacesOfInterest) of a parent node with a specific attribute.To set the scene - the user clicks on a button which sets a string variable to a destination eg. japan or australia.The code then runs through a set of nodes in the XML and any that have a matching attribute is traced - simple enoughWhat I can't figure out is how to then display only the child nodes of the node with that attribute.I'm sure there has to be a way of doing it and I'll probably be banging my head against the desk when I find it
public function ParseDestinations(destinationInput:XML):void
{
var destAttributes:XMLList = destinationInput.adventure.destination.attributes();
[code].....
cleaner way of searching through all of the descendants of an XML object and replacing all % values with actual values. I specify x, y, height and width positions in terms of percentages, and so must convert these to actual positions - it seems madness to first search and replace x values, then y values,
[code]...
I'm working on a presentation who loads a gallery built in a .swf file.
I'm using the following code (Actionscript 3):
var container:Loader = new Loader();
container.load(new URLRequest("gallery-v1.swf"));
addChild(container);
container.x = 0;
container.y=100;
So far so good this code works ok, loading gallery-v1.swf in the correct place. But the gallery also load a few swf itself.
The result is when I load the gallery, is placed in the correct position, but the gallery also loads other swf files on the root(?) of my project, in the 0,0 position and overlapping or clearing my job!
I'd *like* to use E4X filtering to enable users to sort some content.... the XML structure looks something like this:
<item title="" type="" />
type="" is the issue, as each item could have multiple types... for ease of use, i'd love to be able to do something like type="print, web, video"but obviously that doesnt work.... Does anyone have experience with some kind of 'tagging' structure for items loaded from XML?
I'm setting up this animation of photo transitions. Each "set" consists of a photo and two lines of text on top of it, and so forth...I based it on this tutorial [URL], and most of it works, but stumbling on how to show the two separate lines of text...I'm guessing I need another array for the 2nd line of text after "description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;" (see below) ?
function loadXML(loaded) {if (loaded) {xmlNode = this.firstChild; image = []; description = []; total = xmlNode.childNodes.length; for (i=0; i<total; i++) { image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
[Code].....
when I use:
var a = parent.addChild(cloud);
a.x=10;
a = parent.addChild(cloud);
a.x=100;
I only get one cloud made at the position (100,y) (or, the last cloud I declare is the only one to show). How do I add multiples of a movie clip ?EDIT: I tried using addChild(new cloud) but the compiler says "Call to a possibly undefined method cloud."
Lets say I have a string like so...
../images/work/environment/images/biz1.jpg
as you can see the set of characters of "images" in that string twice.
I need to replace the second "images" with something else. Had there only been one "images", I would have done something like this...
Code:
var url:String = "../images/work/environment/images/biz1.jpg";
// Pattern we are looking for in string
var imagesPattern:RegExp = images;
// Replace
AddThumb( url.replace(imagesPattern, "thumbs"));
Because there are two "images" this will not work.
im kind of new to flash, and i have a question. On my scene, i have buttons generated from a xml file that can be dragged. I took the code from a tutorial on the web and added the drag function. I also have a drop zone where i put the button and it do some function. Here is my question, when i drop the button on the drop zone, the button stay in the center of the drop zone. If i drop another button to the drop zone, i want the previous button to return to its original position. How ?
Is there some kind of function to retrieve the last button used ? But even with this function, the problem is that if you click a new button, but change your mind and click on another one without dropping it in the drop zone, the last button is not the one in the drop zone anymore.
Ok here is the problem... I have this code:
[AS]
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
[code]......
I ve used next script:
onClipEvent (load) {
if((_root. mc1._visible=true) and (_root.mc2=true)) {
_root.mc3._visible=true;
}else{
_root.mc3._visible=false;
}}
To achieve next: mc3 is visible only when mc1 and mc2 are visible else its hidden, but this dont work, with this script on load all clips are visible on stage mc1, mc2, mc3, inspite there is a script which is hiding mc1, and mc2...(they should appear on stage on mouse event and this was ok before a inserted script from beginning of post, now they are always visible). How should I write this to make mc3 visible only when mc1 and mc2 are both visible on stage.
if(description_1 = "HELLO" && date_1 = 1981){
do Crap()
}else{
[code]......
whats the format for having 2 conditions???[code]
View 4 RepliesI'm having some difficulties using conditions with XML and AS3.
Having something like this in my XML:
Code:
<?xml version="1.0"?>
<schedule>
<class>
<name day="monday">AAA</name>
[Code]...
Is there a way to have more conditions in an "if" statement? For example I have 3 conditions:
condition 1: a=5
condition 2: b=3
condition 3: c=12
So, if a=5, b=3 and c=12, I want to trace("success") for example. But it's necessary that all 3 conditions are executed. How can I do that?
I've got two functions that work separately, but don't like to work together. Specifically, function "onEnterFrame" stops working after function "connectT."
function onEnterFrame(){
connectT();
checkBounds();
}
[code]....
I used a tutorial to attempt to set up my code so that after a button is released and an external .swf is loaded the same button can't be activated again (on release or on rollover) until a different button is released.
Here is an example of my actionscript. What I'm trying to do here is just have the button not replay the mc in the over state if it's movie clip is already loaded in[code]...
I've got a function which is constantly running to see if a set of movie clips (ball0_mc, ball1_mc etc.) have been placed in a target zone. Once the ballPlaced[#] value is true for a partiuclar moive clip, the movie clip starts acting in different ways depending on which other balls have been placed in a target zone (i.e. their ballPlaced[#] value is also true).
The 'if' and 'else if' conditional statements are contained within the playVideo() function which is constantly running through the ENTER_FRAME event. [code]...
Depending on the time of day (user machine time) and the amount of money raised the header needs to show different scenes and building construction progress.1. Is there some example script out there that would conditionally call on 1 of 4 times of the day (morning, noon, late afternoon or overnight) for me?2. And the % of the funds raised (variable data passed from the site?) will reveal that equivalent portion of the building constructed. So if 25% of the funds are in then 1/4 of the building will be shown completed. Is there an example script that would receive that data from an external source and then call 1 of 4 pre-built building movie clips?
View 0 RepliesI have several input text boxes all of which are activated by the use of the enter key. I only want the one the user is using to run its script when they press enter instead of the keylistener on all of them picking up when enter is pressed. I have tried
ActionScript Code:
listenForEnterObject = new Object();
listenForEnterObject.onKeyDown=function(){
[code]....
I have some code that needs to read like the following:IF the original position(origX) DOES NOT EQUAL where my object is(this._x) AND delay variable(delay) is set to 0, then I need to display a movieclip. There is an X on the movieclip so users can close it, and when they click the X, the delay variable is set back to 1, so the movieclip won't keep loading.
ActionScript Code:
var delay = 1;
if (origX == this._x && delay == 1)
{
[code]....
So the way I see it, there are three conditions in a drag/drop assessment situation; The dragged object is on the correct drop targetThe dragged object is on an incorrect drop targetThe dragged object is not on any targetAssuming there are multiple drag and drop targets, I can do this, but it only satisfies the first two condition:
ActionScript Code:
function stage_onMouseUp(event:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_UP, stage_onMouseUp);
[code].....
I'm having a strange problem w/ race conditions when using attachmovie. I have a class linked to a movie clip that I'm attaching to the stage. The class is fired off when the movie clip is attached but also other classes are getting loaded at the same time while the movie clips is attached. Even though the other classes are called after the movieclip is attached, they are getting loaded faster and therefor the class linked to the attached movie clip cannot access their functions. I'm looking for a listener that will fire off an event ONLY when the attached movieclip is fully loaded but I can't seem to find any examples of associating a listener to a attachmovie method.
View 1 RepliesI want to set multiple conditions for an if statement, but I don't want the conditions to all have to be true, I want to say if (a or b or c or d, etc. is true) then do this. I don't want to say if (a && b && c && d, etc. is true). Is it possible to have an if statement with an "or" in the condition? If so, what's the proper syntax for that?
View 1 Replies