Detecting Number Of Attributes In ChildNode
Hi there everyone,
im trying to write a handfull of XML functions in AS2.0
and im trying to find a way of getting flash to detect
the number of attributes in a childNode.
<item name="aaron" location="sydney" sex="male"/>
as in finding out how many of these ^ there are in each item.
any ideas as to how I would do this? I've tried for...in... statements
and even trying to access them as objects i.e. ...ode[0].attributes["name"]
but it never works - I always have to hard code...ode[0].attributes.name
to get the value.
im sure theres a way to do this, there has to be a way.
please show me the way
Thanks in advance !!!
KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 05-21-2004, 12:28 AM
View Complete Forum Thread with Replies
Sponsored Links:
Detecting Number Of Attributes In ChildNode
Hi there everyone,
im trying to write a handfull of XML functions in AS2.0
and im trying to find a way of getting flash to detect
the number of attributes in a childNode.
<item name="aaron" location="sydney" sex="male"/>
as in finding out how many of these ^ there are in each item.
any ideas as to how I would do this? I've tried for...in... statements
and even trying to access them as objects i.e. ...ode[0].attributes["name"]
but it never works - I always have to hard code...ode[0].attributes.name
to get the value.
im sure theres a way to do this, there has to be a way.
please show me the way
Thanks in advance !!!
View Replies !
View Related
AS 2.0: Looping Through A ChildNode Of A ChildNode Problem
Morning everyone!
I've been working on a flash presentation for work. It's pretty much a mini-site with links to PDF's files and DOCS for distributors. I am feeding everything from an XML file so we can easily update this presentation for our other products.
I've run into a problem on the last part of this swf and I can't seem to get the proper syntax to get this working properly. I am looping through the childNodes and creating MC and filling with data. I can loop through the first set of childNodes no problem. But its when one of these first set childNodes has a set of childNodes itself, I cant pair up that data with it's parent on the flash movie.
So here's my XML:
Code:
<page title="KIT CONTENTS">
<documents>
<doc title="Patient Instructions" file="pdf/patient_inst.pdf">Patient instructions are specifically designed with the patient in mind.</doc>
<doc title="Specimen Collection Tube" file="pdf/collectiontube.pdf">The patented specimen Collection Tube doubles as a convenient, sanitary dispenser.</doc>
<doc title="Return Mailer Kit" file="">This includes:
<list>
<bullet>Specific, detailed directions with colorful pictures to reduce ambiguity</bullet>
<bullet>Specimen Collection Tube and Collection Paper to obtain fecal sample</bullet>
<bullet>Absorbent sleeve, Specimen Pouch and Return Mailer box for mailing Collection Tube to doctor's office or laboratory</bullet>
</list>
</doc>
</documents>
<sidebar>
<bar title="Patient Instructions" image="images/p_inst.jpg" file="PatientInstructions.pdf"/>
<bar title="Specimen Collection Tube" image="images/ctube.jpg" file="collectiontube.pdf"/>
</sidebar>
</page>
And I cant line up the 3 <bullet> items under the <doc title="Return Mailer Kit" file=""> I cant seem to attach the bullet items to the movieclip that holds its parent info.
Here's my AS for the <documents> loop:
Code:
for (var i = 0; i<dcount; i++) {
var item_mc = mcDocs.attachMovie("MC_Docs", "item"+item_count, item_count);
item_mc._y = item_count*item_spacing;
item_count++;
// If a Doc item has Bullets, loop and create the MC
if (docs.childNodes[i].hasChildNodes()){
var list = docs.childNodes[i].childNodes[1];
var bullet = list.childNodes;
var bitem = bullet.nodeValue;
for (var b = 0; b<dcount; b++) {
var list_mc = item_mc.attachMovie("MC_Bullet", "list"+list_count, list_count);
list_mc._y = list_count*list_spacing;
list_count++;
list_mc.txtBullet.text = list.childNodes[b].childNodes;
}
}
// Dynamic Symbols for Doc Loop
item_mc.txtDocTitle.text = docs.childNodes[i].attributes.title;
item_mc.txtDocIntro.text = docs.childNodes[i].firstChild;
}
Is anyone able to show me what I'm doing wrong?
Here's an image of what I am seeing:
TIA!
View Replies !
View Related
Number Of Attributes
Hi
I have an XML file with different attributes in 1 node
for example
Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<products>
<ecoteck>
<product>
<name>lisa</name>
<image thumb="lisa_s.jpg" large="lisa_b.jpg" colors="lisa_colors.jpg" tech="lisa_tech.jpg"/>
<details inhoud="15 Kg" vermogen="1,8 - 5,5 KW" gewicht="85 Kg" verwarmingsvolume="110 m3" verbruik="0,4 - 1,25 Kg/u"/>
</product>
</ecoteck>
</products>
can we find with actionscript how many attributes are in the third node
thanx
View Replies !
View Related
Detecting If A Var Is An Odd Number?
Hi,
I need to check whether a varaible is an odd number, as I alternate which part of the movie I play.
something like....
if(i=oddNumb)
{
gotoAndPlay(...)
}
else
{
gotoAndPlay(...)
}
I was thinking if i could take the value of the variable divide it by 2, and then check whether the answer is a decimal and then I could tell if it was an odd number., But Im not sure how to do this, ive checked the AS dictionary and a searched the forums.
Your help greaty appreciated
View Replies !
View Related
Detecting Number Of Files In A Dir With AS
Hi all. Is there a way to make flash detect how many files are in a particular directory, and then use that number to define the range of a random number?
I've made a slideshow for a friend that loads random images, but I've had to specify the range manually. It's for his dad, and I want for him to be able to just plonk new images in whenever he likes and it will just work.
I'm using MX 2004.
Any help greatly appreciated, cheers!
View Replies !
View Related
Detecting Frame Number?
Alright, I'm having a little issue...Currently, I have a navigation bar where when you roll over a button, a movieclip plays. On the roll out, the movie plays in reverse, making it appear to rescede to where it came from. If you roll out too quickly, it skips to the resceding part, and it makes it look like it skips.
Is there any way to tell what frame a movieclip is on? If I can get that, I can write an If Then statement that would ensure it would wait till it got to the finished frame, and THEN do the rescedeing.
View Replies !
View Related
Detecting Frame Number?
Alright, I'm having a little issue...Currently, I have a navigation bar where when you roll over a button, a movieclip plays. On the roll out, the movie plays in reverse, making it appear to rescede to where it came from. If you roll out too quickly, it skips to the resceding part, and it makes it look like it skips.
Is there any way to tell what frame a movieclip is on? If I can get that, I can write an If Then statement that would ensure it would wait till it got to the finished frame, and THEN do the rescedeing.
View Replies !
View Related
Detecting And Removing Number From String
I am trying to figure out a way to detect and remove a number from a string. The value of the string is entered from a input text field. I need to detect leading zeros and remove them from the string. I understand the logic but familiar enough with the AS syntax yet.
//Found this to detect the first digit in the string
check = myString .charAt( 0 )
Need help forming the if statement to detect if leading digit is '0' and if = 0 remove it from string.
Thanks for any help you might be able to provide....
View Replies !
View Related
Input Text - Detecting ODD Number.
Hi people,
I've got a few input text fields and a submit button on an order form I've designed. Trouble is you can only order in multiples of 2. Naturally I have a warning stating that orders must be multiples of that number but there is always room for idiocy!
Lets say my order input text box is called "order" and the button used to proceed to payment is called "submit". How do I detect an ODD number entry and have it run an mc called "warning"?
Does that make sense to anyone because I'm confusing even myself - which admittedly isn't hard for me today.
Thanks.
View Replies !
View Related
Detecting Current Frame Number?
I have a movieclip placed in the main timeline. Inside that movieclip, there is another movieclip.
I need to know the current frame number of the inner movieclip when the animation is playing.
And report that current frame number back to the actionscript in the main timeline.
Anyone know how to achieve that? Thank you!
View Replies !
View Related
Input Text - Detecting ODD Number.
Hi people,
I've got a few input text fields and a submit button on an order form I've designed. Trouble is you can only order in multiples of 2. Naturally I have a warning stating that orders must be multiples of that number but there is always room for idiocy!
Lets say my order input text box is called "order" and the button used to proceed to payment is called "submit". How do I detect an ODD number entry and have it run an mc called "warning"?
Does that make sense to anyone because I'm confusing even myself - which admittedly isn't hard for me today.
Thanks.
View Replies !
View Related
Detecting A Character And Number In Input Text
I'm working on a delivery costing system for my company using postcode input from users and I've got an idea I needs some help with...
For you non Brits out there UK postcodes work on two blocks of 2-4 characters each.
L2 2HH - Liverpool central
M24 2TN - suburb of Manchester
IV56 7NQ - outter Inverness
You get the idea. So the first part of a UK postcode, wether it be 2 characters or 4 characters MUST have atleast one numeric and one non-numeric character in it. How do I detect this?
At the moment I've just got my CHECK POSTCODE button to run a few functions only if my POSTCODE (input text) field length it greater or equal to 2 characters. So how do I easily detect an input of numeric and non-numerical characters without having to resort to indexOf ...a...b...c...1...2...3...?
View Replies !
View Related
Detecting A Character And Number In Input Text
I'm working on a delivery costing system for my company using postcode input from users and I've got an idea I needs some help with...
For you non Brits out there UK postcodes work on two blocks of 2-4 characters each.
L2 2HH - Liverpool central
M24 2TN - suburb of Manchester
IV56 7NQ - outter Inverness
You get the idea. So the first part of a UK postcode, wether it be 2 characters or 4 characters MUST have atleast one numeric and one non-numeric character in it. How do I detect this?
At the moment I've just got my CHECK POSTCODE button to run a few functions only if my POSTCODE (input text) field length it greater or equal to 2 characters. So how do I easily detect an input of numeric and non-numerical characters without having to resort to indexOf ...a...b...c...1...2...3...?
View Replies !
View Related
Detecting Frame Number And Loading External Movies
i am trying to load a movie by trying to traget a specific frame but to no avail. i read some time ago here on the board that you could use the _currentframe property to do this sort of thing and its doing my head in !!
here's the specifics
i have 2 movie clips called 'pic1' and 'imagebox'
'pic1' acts as a thumbnail with an image inside, and an empty button in it which when you click on it prompts a box to open (imagebox), and then once that is fully open it loads the larger version (as an external swf file) of the image so as to minimise download time.
the actionscripting i've used is as follws:
Button inside pic1:
on (release) {
with (_root.imagebox) {
gotoAndPlay (2);
}
if (_root.imagebox._currentframe==25) {
loadMovie ("externalmov.swf", "externalmov");
}
}
'Imagebox' has a tween inside it which makes the box bigger to accommodate the larger image, with a stop action on frame 1 and on frame 25. Inside this mc is an empty mc called 'externalmov' which acts as a target for the external swf file to load into.
try as i may the _currentframe property does not seem to work. all i want it to do is the following:
if it is at such a frame please please please load external moviw externalmov.swf
is there another way of doing this??am i no where near?
thanx for you help!
View Replies !
View Related
XML Childnode's Value
Hi everybody, I was wondering how can I get XML child node's values. For example :
I have this file tracks.xml:
<tracks>
<track songname="Promiscuity" artist="Manu Chao" url="http://mydomain/Promiscuity.mp3"/>
<track songname="Final Countdown" artist="Europa" url="http://www.europa.edu/Europe%20-%20The%20Final%20Countdown.mp3"/>
<track songname="Dream On" artist="Manolo Camp" url="http://www.manolocamp.net/music/mp3/Manolo%20Camp%20-%20Dream%20on.mp3"/>
</tracks>
I know that is a pretty basic question , but how can I list only the song names?
Thanks!
View Replies !
View Related
Reading In XML Childnode Name?
Hi,
I am reading in an XML file and want to know if i can target the childnode by name (much like you can with attributes).
Normally the structure is consistent and i use ...firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;... where 1 is the node number.
This is because the xml file read in is not consistent. For example, a property may have 4 images or it may have none but i need to be able to read image1, 2, 3 , 4 etc.
I hope this makes sense!
Thanks in advance
Nick
<?xml version="1.0" encoding="ISO-8859-1"?>
<xml >
<slideshowname>ar</slideshowname>
<properties>
<property>
<addr2>St. Johns</addr2>
<town>New</town>
<county>WestS</county>
<price>£21,000</price>
</property>
<property>
<addr2>Chapel</addr2>
<town>Hungford</town>
<county>West</county>
<price>£10,000</price>
<image1>C:xml_feedjrECIMAGE1 011676.JPG</image1>
<image2>C:xml_feedjrECIMAGE2 011676.JPG</image2>
<image3>C:xml_feedjrECIMAGE3 011676.JPG</image3>
<image6>C:xml_feedjrECIMAGE6 011676.JPG</image6>
</property>
<property>
<addr2>Close</addr2>
<town>Thatch</town>
<county>Berks</county>
<price>£62,500</price>
<image1>C:xml_feedjrECIMAGE1 0110569.JPG</image1>
<image6>C:xml_feedjrECIMAGE6 0110569.JPG</image6>
</property>
</properties>
</xml>
View Replies !
View Related
Display Next ChildNode Using AS?
Ok, I have this extremely simple XML displaying movie I made using the Display XML in Flash tutorial, and now I want to know what to do so that I can click on a button and make the whole data change to the next ChildNode. For example,
Code:
<?xml version="1.0"?>
<inventors>
<person>
<name>Thomas Edison</name>
<comment>Inventor of many things such as the incandescent lightbulb.</comment>
</person>
<person>
<name>Doug Engelbart</name>
<comment>Invented the mouse at the Stanford Research Institute</comment>
</person>
</inventors>
it first displays the first person named "Thomas" and all of its info, and when I click a "next" button I want it to display the info of the next person shown in the XML file. I think it is done using nextSibling or something like that... but I dont know how to use it... any ideas?
View Replies !
View Related
How Do You ChildNode Numbers?
In this xml:
Code:
<scoreboard>
<quarter q="1" hg="3" hb="2" ag="7" ab="0" period_secs="1792" period_complete="Y" />
<quarter q="2" hg="6" hb="6" ag="13" ab="3" period_secs="1949" period_complete="Y" />
<quarter q="3" hg="11" hb="14" ag="19" ab="6" period_secs="1990" period_complete="Y" />
<quarter q="4" hg="12" hb="16" ag="21" ab="10" period_secs="1640" period_complete="Y" />
</scoreboard>
I know that if i use
Code:
_root.htg = this.firstChild.childNodes[0].attributes.hg;
then I will get 3. How do I increase the childNodes[0] by 1 if the corresponding period_complete = Y?
View Replies !
View Related
XML - How To Tell Which Is ChildNode, Firstchild, Etc...?
I'm not sure how to tell which is the childNode. So, I did this trace in actionscript and it said I have 7 childNodes... I'm a little puzzled, so can anyone tell me what what are the 7 childNodes?
Thanks,
FletchSOD
Code:
xml_tags = "<?xml version='1.0'?>";
xml_tags += "<initMenus>";
xml_tags += " <menu name='submenu'>";
xml_tags += " <menu name='submenu'>";
xml_tags += " <item name='item1'/>";
xml_tags += " <item name='item2'/>";
xml_tags += " <item name='item3'/>";
xml_tags += " </menu>";
xml_tags += " <menu name='submenu'>";
xml_tags += " <item name='item4'/>";
xml_tags += " <item name='item5'/>";
xml_tags += " <item name='item6'/>";
xml_tags += " </menu>";
xml_tags += " <item name='itemA'/>";
xml_tags += " </menu>";
xml_tags += "</initMenus>";
var menu_xml = new XML();
menu_xml.parseXML(xml_tags);
menu_xml.ignoreWhite = true;
node_xml = menu_xml.firstChild.childNodes[1];
trace(node_xml.childNodes.length);
View Replies !
View Related
XML Fading To The Next ChildNode Help On Looping
Hey all,
I'm on to the next problem! I'm wondering if anyone could give some idea/tutorial/link or something that would steer me in the right direction! I have a node fading in and out, but when it fades out I want it to loop to the next picture/output to display.
eg.
promo1 displays, after it fades out I want promos2 to fade in and out! And so on, etc.
For my dynamic output I have:
PHP Code:
output = xmlDoc_xml.firstChild.childNodes[0].childNodes[0].firstChild;
Which needs to be something like:
PHP Code:
output = xmlDoc_xml.firstChild.childNodes[n].childNodes[0].firstChild;
So that it may loop and retrieve the appropriate node I want.
Check out the AS:
PHP Code:
load_xml = new XML();
load_xml.ignoreWhite = true;
load_xml.onLoad = function(success) {
if (success) {
process(load_xml);
} else {
trace("Something is wrong, we're not opening!");
}
};
//Load up the XML file into Flash
load_xml.load('images.xml');
//---Function that will be called when xml loads succesfully
//xmlDoc_xml is now a reference to the XML object where our information is stored
item_arr = new Array("img", "startdate", "enddate", "url");
function process(xmlDoc_xml) {
for (var n = 0; n<xmlDoc_xml.firstChild.childNodes.length; n++) {
if (xmlDoc_xml.firstChild.childNodes[n].nodeName == "promo") {
for (var i = 0; i<xmlDoc_xml.firstChild.childNodes[n].childNodes.length; i++) {
if (xmlDoc_xml.firstChild.childNodes[n].childNodes[i].nodeName == item_arr[i]) {
trace(xmlDoc_xml.firstChild.childNodes[n].childNodes[i].firstChild.nodeValue);
}
}
trace("Is it working "+xmlDoc_xml.firstChild.childNodes[0].childNodes[0].firstChild);
output = xmlDoc_xml.firstChild.childNodes[0].childNodes[0].firstChild;
}
//trace("Come to poppa " +xmlDoc_xml.firstChild.childNodes[n].childNodes[0].childNodes.length);
}
}
MovieClip.prototype.fade = function(endAlpha, speed) {
trace("called11");
if (this._alpha>endAlpha) {
speed *= -1;
}
this.onEnterFrame = function() {
if (Math.abs(endAlpha-this._alpha)>Math.abs(speed)) {
this._alpha += speed;
} else {
this.onEnterFrame = undefined;
myInterval = setInterval(beginFadeOut, time());
this._alpha = endAlpha;
}
};
};
MovieClip.prototype.fadeIn = function(begalpha, speed) {
trace("called22");
this._alpha = 0;
if (this._alpha<begalpha) {
speed *= -1;
}
this.onEnterFrame = function() {
if (Math.abs(begalpha-this._alpha)>Math.abs(speed)) {
this._alpha -= speed;
} else {
this._alpha = begalpha;
}
};
};
mc.fade(0, 7);
function beginFadeOut() {
clearInterval(myInterval);
mc.fadeIn(100, 7);
}
function time() {
sec = ((30/5)*1000);
trace("seconds called");
return sec;
}
I am attaching a zip file, that is similar/shorter to what I am doing.
When it fades out I need another to fade in!
Appreciation in advance!
cbs
View Replies !
View Related
Get A ChildNode By It's Unique Attribute ID
Hello everyone,
From a php processed xml file i want to grab a specific childnode by it's unique ID which is in the attribut tag ID in the page childnode.
For example i want to get the <pageTitle> and <pageContent> for the page with ID="6"
Code:
<Page ID="11" SiteSubjectID="7" PageTypeID="1" PageType="Main page" SubjectPageOrder="1">
<Page ID="6" SiteSubjectID="3" PageTypeID="1" PageType="Main page"= SubjectPageOrder="1">
<PageTitle>
<![CDATA[ Order info ]]>f(clean);
</PageTitle>
<PageContent>
<![CDATA[ Order info content ]]>f(clean);
</PageContent>
</Page>
<Page ID="2" SiteSubjectID="2" PageTypeID="1" PageType="Main page" SubjectPageOrder="1">
The way I grab the content now is by using the [i] from the for loop i created to get all the content and replace that with the number on which place it resides in the loop.
Code:
title_txt.text = _root.valuesArray['Pages'][2]['PageTitle'];
But since the childnodes are not be giving back in that order i get the wrong content back.
How can i reach the content in the childnode with for example ID="6" so that i get the right content back indepent from where the childnodes resides in the loop?
Thnx in advance
Greetz
Undersound
View Replies !
View Related
Can I Create New Textfields For Each ChildNode?
Hi, i have a situation where i am recreating an all flash site into a hybrid site once the folks figured out that their search terms can't be used by google in a flash site...
anyway, there are numerous paragraphs of text that they would like to retain formatting for. I am reading in in the text using separate childNodes in an XML file for each paragraph break. however, i would like to know if i can create new textfields everytime i loop through a childNode structure and then write out the new textfield with the current Node's value used as the text property for the TextField instance.
here's how i think it might work in my head:
Code:
var paragraph;
for (var i = 0; i < xml.firstChild.childNodes[0].childNodes.length; i++) {
this.createTextField(name, depth, x, y, width, height);
paragraph = xmlNodeDecl.firstChild.childNodes.firstChild;
newTextField.text += paragraph;
}
is what i'm trying to do possible and if so, has anyone done something like this before? right now i'm not getting any output whatsoever.
thanks for any help.
ian
View Replies !
View Related
Flash / XML ChildNode Question
Hey All,
I am working on a site which has an XML-driven tree component in it. I have already figured out that if I want a node to open and be selected onLoad I use:
Code:
_root.theTree.setIsOpen(_root.theTree.getTreeNodeAt(0), true, true, true);
However, the first node of my XML file has a child node which I would like to have selected onLoad instead. Id greatly appreciate it if someone could tell me how I would go about coding this so that when my site loads it opens the first node (revealing the child nodes) with the first child node selected. Thanx in advance!
View Replies !
View Related
Loading XML From The Back (Last Childnode)
Hello, i got a problem regarded about XML thumbnails.
I'm making a pair of scrollable slider menus with XML thumbnails on them.
- Both sliders are identical and the thumbnails are from the same XML.
- While the top slider slide to the right, the slider on the bottom will slide to the left.
- The yellow box is the screen, which is also the visible area.
- The red box is the 1st thumbnail (i=0) & the green box is the last thumbnail (i=total).
Ok now's the problem:
- The slider menu #1 is loading thumbnail starting from 1st thumbnail (i=0).
ActionScript Code:
function loadThumb() { var target_mc = thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth()); target_mc.loadMovie(thumbnails[i]);}
- I want the slider menu #2 to load thumbnail starting from the last thumbnail (i=total).
Is ther anyway i can do it with declaring another variable for example:
ActionScript Code:
var j = total-i;target_mc.loadMovie(thumbnails[j]);
Tried so hard and cant make it work @@ ... pls help me in this, Thanks.
View Replies !
View Related
Xml Load Works But No Childnode Access
Hi,
I am having trouble displaying my movie properly in Flash 5.
Code:
allGalleries = new XML();
allGalleries.onLoad=handleLoad;
allGalleries.load('es_galleries.xml');
//this works well
_root.statusfield=allGalleries;
//this returns zero instead of 46
_root.statusfield=allGalleries.firstChild.childNodes.length;
this is the url:
www.edithschneider.com/preview/test.html
Does anybody have an idea what this might be about?
How can I proceed to find the error?
View Replies !
View Related
Variable Representing Childnode Length
Okay I'm trying to make a variable inside of an xml onLoad function. I want the variable to be a number representing the length of firstchild.childnodes. This doesn't seem to be working. Check out my code.
ActionScript Code:
//Start xml onLoad functioninXML.onLoad = function() { var len:Number = inXML.firstChild.childNodes.length; for (i=0;i<this.firstChild.childNodes.length;i++) { //Populate arrays with xml data src.push("images/"+ this.firstChild.childNodes[i].firstChild.firstChild); //titles.push(this.firstChild.childNodes[i].firstChild.nextSibling.firstChild); //desc.push(this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.firstChild); //link.push(this.firstChild.childNodes[i].firstChild.nextSibling.nextSibling.nextSibling.firstChild); //Attach picture holders from library attachMovie("picx","p"+i, i); //Set attributes for each image with(eval("p"+i)){ holder.loadMovie("images/"+ this.firstChild.childNodes[i].firstChild.firstChild); _x = (i/3)*450-150; } } eval("p"+(picnum-1))._alpha = 60; eval("p"+(picnum+1))._alpha = 60;}
Code:
<?xml version='1.0' encoding='iso-8859-1'?>
<pics>
<pic>
<src>1.gif</src>
<titles>Cold Coffee America</titles>
<desc>Flash contact form for Cold Coffee America.</desc>
<link>http://www.coldcoffeeamerica.com</link>
<tech>
<t>Flash 8</t>
</tech>
</pic>
<pic>
<src>2.gif</src>
<titles>National Freelance Directory</titles>
<desc>PHP/MySQL backend for National Freelance Directory.</desc>
<link>http://www.worldslargestforum.com/freelance</link>
<tech>
<t>PHP</t>
<t>MySQL</t>
<t>CSS</t>
</tech>
</pic>
<pic>
<src>3.gif</src>
<titles>National Freelance Directory</titles>
<desc>PHP/MySQL backend for National Freelance Directory.</desc>
<link>http://www.worldslargestforum.com/freelance</link>
<tech>
<t>PHP</t>
<t>MySQL</t>
<t>CSS</t>
</tech>
</pic>
<pic>
<src>4.gif</src>
<titles>National Freelance Directory</titles>
<desc>PHP/MySQL backend for National Freelance Directory.</desc>
<link>http://www.worldslargestforum.com/freelance</link>
<tech>
<t>PHP</t>
<t>MySQL</t>
<t>CSS</t>
</tech>
</pic>
<pic>
<src>5.gif</src>
<titles>National Freelance Directory</titles>
<desc>PHP/MySQL backend for National Freelance Directory.</desc>
<link>http://www.worldslargestforum.com/freelance</link>
<tech>
<t>PHP</t>
<t>MySQL</t>
<t>CSS</t>
</tech>
</pic>
View Replies !
View Related
XML Trouble Reading The .length Of A ChildNode.
Hey guys. N00b here.
I'm doing a little experimenting with my WordPress and Flash, but I've run into a wall. I'm sure there's something I'm not seeing clearly, so I'm asking for your opinions.
The actionscript goes like this:
function loadXML(loaded) {
if (loaded) {
item = this.firstChild.firstChild.childNodes[6];
trace(item);
blogtitle = [];
total = item.length;
trace(item);
for (i=0; i<total; i++) {
blogtitle[i] = item.firstChild.childNodes[i].nodeValue;
}
trace(blogtitle[0]);
} else trace("Failed to load XML");
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.robobeau.com/wp/?feed=rss2");
The following is part of the RSS feed I'm trying to read:
<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2" -->
<rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<channel>
<title>robobeau.</title>
<link>http://robobeau.com/wp</link>
<description>Skeet, skeet, skeet!</description>
<pubDate>Fri, 30 Nov 2007 02:31:27 +0000</pubDate>
<generator>http://wordpress.org/?v=2.2</generator>
<language>en</language>
<item>
<title>2nd Test.</title>
Ok, so the problem I'm running into is that the trace for item.length keeps showing up as UNDEFINED.
As soon as I can jump this hurdle I can keep playing with the "for" statement.
Any opinions?
View Replies !
View Related
Please Help Problem With Childnode Pointing To Image File From XML
Hi,
I'm trying to point to the image file in this XML i screenshotted below. I'm using XML Notepad to easier see how many childnodes i need and such. But... I'm having a problem with pointing to the image file url, when its not standing alone.
Here is an example on how i pointed to a text file: (that worked) and linked it to a dynamic text field in Flash.
Code:
_root.streetaddress = this.firstChild.childNodes[0].childNodes[0].childNodes[5].childNodes[0].firstChild.nodeValue;
streetaddress_txt.text = _root.streetaddress;
But how can i point to a image file when it stands together with things like "priority" and such? (look at the image).
Please help!
If there is some more info you need(to answer), that i might be able to provide, please ask.
(BTW: I didnt make this xml, and isnt really that good in it. Only know the basics, alas.)
View Replies !
View Related
Shared Object To Store A Unique Id Number Var And Frame Number Var
Hi, I am a complete novice to action script when it comes to objects. I know what I want to do is done with the shared object. Basically I want to create a tutorial that stores a cookie on the users’ machine with a unique id variable telling flash what frame the user was at last. When the user revisits it would prompt "continue where left off or start the tutorial over. I read the action script dictionary regarding the shared object, but being a designer I really need to visualize it before I can comprehend this.
Thanks,
Justin
View Replies !
View Related
Variable From Flash As Childnode Variable
Is it possible to take a variable from Flash and use it as an xml childNode variable?
Code:
function loadXML(loaded) {
if (loaded) {
i = int(_root.shoe_id);
_root.shoe = this.firstChild.childNodes[i].childNodes[0].firstChild.nodeValue;
_root.shoe_color = this.firstChild.childNodes[i].childNodes[1].firstChild.nodeValue;
shoe_txt.text = _root.shoe;
shoe_color_txt.text = _root.shoe_color;
} else {
content = "info unavailable";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("brand_info.xml");
View Replies !
View Related
Random Number Then Delete Number Till Reset
Last edited by pixcels : 2006-10-18 at 22:41.
I am trying to create a type of quiz thing. It is a stand alone move and can not have anything loaded into it.
Problem:
I need a random item from an array, then after the item is displayed I need it to delete itself so that it will not show again. After the array is down to the last item it calls in the array again and starts all over.
Below is code that I have found but it does not delete the array item after it has been show from the array, or restart.
Code:
Array.prototype.shuffle = function() {
var shuffledArray = [];
var copyArray = this.slice(0);
for (var j = 0; j<this.length; j++) {
randomNo = Math.floor(Math.random()*copyArray.length);
shuffledArray[j] = copyArray[randomNo];
copyArray.splice(randomNo, 1);
}
return shuffledArray;
};
testArray = ["1", "2", "3", "4", "5", "6", "7"];
newArray = testArray.shuffle();
//Text area component
theText.text = "newArray = "+newArray
//Button component
theBtn.onRelease = function(){
newArray = testArray.shuffle();
var tempArray = Math.floor(Math.random()*testArray.length)
var totalArray = Math.floor(tempArray+=newArray[0])
var slicedArrary = tempArray.splice(0)
theText.text = "newArray = "+newArray[0]
}
View Replies !
View Related
AS2 - Image Set Number Of Rows/dynamic Colum Number
I have a simple image gallery that is loading images in, creating movieclips, and then lining them up into 3 columns and rows. This woks fine as long as there is only 9 images, but I have more then that. If I have it pull more then the 9 it adds in more rows I need it to add in more columns no more rows.
Here is the function that creates the gallery:
title_array is the array of images.
Code:
function createGallery() {
nbrColumns =2;
leftMargin = 7;
topMargin = 5;
cellWidth = 165;
cellHeight = 165;
//thumbnails.setMask(albumHolder.albumHolderMask);
for (i=0; i<title_array.length; i++) {
thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
var cellX = i % nbrColumns;
var cellY = Math.floor(i / nbrColumns);
thumbHolder._x = leftMargin + cellX * cellWidth;
thumbHolder._y = topMargin + cellY * cellHeight;
thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
thumbLoader.loadMovie(title_array[i]);
}
}
View Replies !
View Related
Round Number To Next Number That Has Only Zeros Behind It (ie: 20, 100, 3000)
I want to make a graph and I want the highest number in the graph to be a solid figured number.
so if the highest part that needs to be graphed is 12,000 I want the graph to go up to 20,000 ( the next highest number with only zeros behind it.)
for instance I want to round:
11 to 20
253.3454 to 300
4500001 to 5000000
I am sure I neet to use Math.Ceil() in combination with something else but I am unsure how?
any suggestions?
THANKS!
View Replies !
View Related
Random Number Variable That's Different From Previous Number
I have this line of code in my game that works great. However it would work even better if when it the code was executed the next random number was not the same as the one before it. For example if "speech" is on frame 6 when the code is executed I would like the random number to be between 2 and 12 but not 6. (I don't want the same frame to come up as it confuses the kindergarteners and preschoolers using the program.) Here's the code that's working for me now.
ActionScript Code:
speech.gotoAndStop(Math.floor(Math.random()*11)+2);
View Replies !
View Related
Need Urgent Help How To Check If The Generated Number Is A Whole Number
Hi,
I have a simple issue but I need some assistance. I am calculating a number and the result number sometimes a whole number but in some cases decimals are present. Decimals do not need change but whole numbers need to change. So for example if the end result is "6" I need it to show it as "6.0" in a field beacuse that is the way the calculator should display it according to request.
How can I check that the result number is a whole number and then add ".0" to it?
I just included a simple script below.
if (outputnumber == ?) {
resultNum = Number(String(outputnumber+".0"));
} else {
resultNum = outputnumber;
}
Thanks,
Attila
View Replies !
View Related
[XML] How To Get The Value Of The Xml Attributes
Hi
I would like to get the information of an xml file so that I can show it in a clip.
I can import my xml file and print out all of its data with trace() but I can't make a simple to print the values the attributes of each node.
Here is my very simple xml file, called doc.xml
Code:
<myroot>
<person name="foo" age="18" />
<person name="bar" age="19" />
</myroot>
My loading function for the xml file works, but not the one with my loop to get the attributes values.
Code:
// LOADING OF THE XML (works well)
var loader:URLLoader = new URLLoader();
var adress:URLRequest = new URLRequest ("doc.xml");
loader.load(adress);
loader.addEventListener(Event.COMPLETE, loadXML);
function loadXML(eventObject:Event){
var xml = new XML(eventObject.target.data);
trace(xml);
}
Code:
// XML ATTRIBUTES VALUES
// error 1120: Access of undefined property xml.
function printXML(eventObject:Event){
var myarray = xml.firstChild.childNodes;
for (var i = 0; i < myarray.length; i++)
{
var current = myarray[i];
trace(current);
}
}
What do I have to modify in my printXML function so that I can get in my loop the value of the attributes of each nodes?
many thanks for your help
merci pour votre aide
View Replies !
View Related
Get Attributes From XML
This is my code that loads my xml, and with some help I have been able to get at certian information in the file, but there are some attributes "w" and "d" that I need to get at and I am not quite sure how to do that. Can someone help me with this.
ActionScript Code:
var myXML:XML = new XML();
myXML.ignoreWhite = true;
libraryList_ar = new Array();
combo_list.dataProvider = libraryList_ar;
myXML.onLoad = function(success) {
if (success) {
//trace(this);
var libraries = this.firstChild;
var dValue = this.firstChild.attributes.name;
//trace(dValue);
combo_list.textField.label.text = "Library";
var libCount = libraries.childNodes.length;
//trace(libCount);
var libItems = libraries.firstChild.childNodes.length;
//trace(libItems);
for (var i = 0; i<libCount; i++) {
libraryList_ar[i] = new Object();
libraryList_ar[i].label = libraries.childNodes[i].attributes.Text;
libraryList_ar[i].data = libraries.childNodes[i];
//save reference here
}
}
};
myXML.load("itemMenu.xml");
myXML looks like this
HTML Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<menu name="Library">
<menu Text="BedRoom">
<item name="Bed" ItemSWF="bed" w="65" d="84" />
<item name="Bunk bed" ItemSWF="bunkBed" w="43" d="81" />
</menu >
<menu Text="Chairs">
<item name="Recliner" ItemSWF="chair" w="40" d="35" />
</menu >
<menu Text="Sofas">
<item name="Leather Sofa" ItemSWF="sofa" w="85" d="37" />
</menu >
</menu >
View Replies !
View Related
How Do I Use XML Attributes
Hi I have some code I am writting for my village website.
I want to show some pictures I have the following which works but would like to know how to apply the read attributes for the XML data instead of using firstChild etc.
Here is my XML
Code:
]<?xml version="1.0" encoding="ISO-8859-1"?>
<pictureinfo>
<banner imagename = "pic1.jpg" imageurl = "http://www.mywebsite.co.uk" captiontxt = "Test 1"/>
<banner imagename = "pic2.gif" imageurl = "http://www.bbc.co.uk" captiontxt = "Test 2"/>
<banner imagename = "pic3.gif" imageurl = "http://www.mywebsite.com" captiontxt = "Test 3"/>
</pictureinfo>
<configdata>
<configitems holdtime = "10" fadeitem = "20" />
</configdata>
and here is my Action Script
Code:
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
var urls:Array = new Array();
var picname:Array = new Array();
var captions:Array = new Array();
var hold:Number = 0;
var fade:Number = 0;
//
my_xml.onLoad = function() {
var photos:Array = my_xml.firstChild.childNodes;
for (i=0; i<photos.length; i++) {
urls.push(photos[i].attributes.imageurl);
picname.push(photos[i].attributes.imagename);
captions.push(photos[i].attributes.captiontxt);
}
hold = my_xml.firstChild.nextSibling.firstChild.attributes.holdtime;
fade = my_xml.firstChild.nextSibling.firstChild.attributes.fadeitem;
};
my_xml.load("http://www.mywebsite.co.uk/picturedata.xml");
This is ok if they are in the correct order (in the XML file) I have used the "attributes" command to read in the data but dont know the correct syntax to use if I dont want to use "nextSibling.firstChild" etc.
Is there a way of reading my XML using the "pictureinfo" & "configdata" tags so that the order does not matter?
I hope that makes sense
Regards Dave
View Replies !
View Related
Xml Attributes.
Allright, simple questions.
i have the two following chilNode in my xml document:
Code:
<woman age="25" hairColor="Brown" name="Kay"></woman>
<woman age="22" hairColor="Pink" name="Jessica" favoriteFilm="The adventure of Jack Burton"></woman>
when my xml is loaded into flash,
1) can i know how many attributes each nodes contains ?
2) how can i list the attribute name in each node ?
What i want to do is put the name of the attributes, not there value, the name of the attributes in an array I want to have this result:
ActionScript Code:
var xWoman0:Array = new Array ("age","hairColor","name");
var xWoman1:Array = new Array ("age","hairColor","name","favoriteFilm");
if someone have an idea, please share.
thanx.
[EDIT/CyanBlue]
Please use the proper code syntax to format the code.
Read this page to find out more about the tag information
[/EDIT]
View Replies !
View Related
XML Attributes
Hi, I'm trying to get a grip on getting attributes from loaded XML. When I run this trace to get the attribute "runtime" from my XML file, it comes up as undefined. My XML file looks like this and is loading—I can trace the childNodes:
<?xml version="1.0" encoding="UTF-8"?>
<videoList>
<item myurl="input/FLV/lumiere2.flv" runtime="335" />
<item myurl="input/FLV/lumiere3.flv" runtime="34" />
</videoList>
=========
Attach Code
var inputXML:XML = new XML();
inputXML.ignoreWhite = true;
var Vidname:Array = new Array ();
var Vidlength:Array = new Array ();
inputXML.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
trace (this.firstChild.childNodes.attributes.runtime);
}
}
inputXML.load ("input/XML/vidlist.xml")
View Replies !
View Related
|