Number Of Elements Inside An XML Node?
If myXML.person.length() gives me the number of person nodes in my XML file, then how do I count the number of elements inside each person node if each one has a different name (such as address, zip, etc.)?
Adobe > ActionScript 3
Posted on: 11/13/2008 11:18:47 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
XML Node Elements, Objects
Hi!
How do you traverse through xml attributes without knowing their real names? for example:
PHP Code:
for each (nodeXML in mainXMLList){ trace({clientname:nodeXML.@cname, clientURL:nodeXML.@clienturl}); }
meaning, that if i do not know if it is named a 'cname' or 'clienturl'. Also, If I do not know how many attributes there are in a node how do I do a subloop through each node?
My objective is I want to be able to reuse a function that loops through a common format xml file, say an xml listing all clients and details related to each client and another xml file can use the same function but with a different set of data say, a picture gallery file that contains details about each picture obviously you do not access a picture detail using the above code right? It is just not appropriate.
In this way I do not have to write the same function over and over for every xml file I want read and extracted...
Has anyone encountered this problem?
Xml Node Number HELP ME PLEASE
So I've created this thumbnail grid that uses xml. each thumbnail is a button that I would like to pass information on the another flash file. Here's my problem. I can't see to figure out the best way to figue out what node or xml branch I'm currently on. Is there an easy way to do this? I know how to get the total.... But than where can I go? HELP ME PLEASE. I only need to extract the integer.
HELP
XML Node To Number?
Can anyone tell me how to get the value of the childNodes[i] and make that into a number? That info hold how many images I have a path to in my XML file and I want to use that info to control my nav.
Code:
var pArray = new Array();
var tArray = new Array();
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function (success:Boolean):Void {
if (success) {
var xmlData = this.firstChild.childNodes[0].childNodes[0];
for (var i = 0; i<xmlData.childNodes.length; i++) {
pArray.push(xmlData.childNodes[i].childNodes[0].firstChild.nodeValue);
tArray.push(xmlData.childNodes[i].childNodes[1].firstChild.nodeValue);
}
containerMC.loadPic(0);
picInfo.alphaTo(100, speed_fadeIn, tweentype_fadeIn, speed_fadeIn);
} else {
picInfo.text = "Unable to load external file.";
}
}
myXML.load("xml/XMLdata.xml")
Get Number Of Elements In MovieClip?
Hello,
I would like to make a for-loop with the x and y position of the elements.
So what I do is make an emptyMovieClip:
ActionScript Code:
timeline.createEmptyMovieClip("plaats_connectoren",timeline.getNextHighestDepth());
plaats_connectoren = this.plaats_connectoren;
plaats_connectoren._x = 583;
plaats_connectoren._y = 115;
and then there are some elements on that movieclip (dynamic). And now I want to know how many elements there are on that movieclip with a for-loop:
ActionScript Code:
for (iteller = 1; iteller <= plaats_connectoren.length; iteller++){
ThisName = "connector"+ iteller;
trace(plaats_connectoren[ThisName]._x);
}
but that does not seems to work. The names of the elements at the movieclip are like this ' connector1 connector2 connector3 .. etc '
I hope someone can help me out?
Thank you at advance
[F8] Search For An XML Attribute And The Return Node Number
Hi everyone.
Just wondered if anyone had any ideas about the following:
I need to search through a series of nodes in an XML file for a specified attribute and then return the node number so that I can access the rest of the values contained inside.
Kirupa has an excellent xml search tutorial I've been looking at but it covers way more than I need!
If anyone could point me in the right direction so I can have a go that would be great.
Cheers.
How To Learn The Index Number Of An Array Node?
Hello all!
This is kind of complicated, I think. I have a multidimensional array:
myArray = newArray()
myArray[0] = new Item(buttonA, "nameA", ArrayA);
myArray[1] = new Item(buttonB, "nameB", ArrayB);
myArray[2] = new Item(buttonC, "nameC", ArrayC);
myArray[3] = new Item(buttonD, "nameD", ArrayD);
Thus, on the main screen there are 4 buttons (named ButtonA - ButtonD) and a dynamic text which displays a string according to the variable: Screen.
I am trying to make a function so when I onMouseOver one of the buttons, such as ButtonA the function finds out what Array ButtonA belongs to and sends "nameA", which is also part of myArray[0], to the dynamic text, Screen.
If someone would be so very kind as to help me, I would be very grateful.
How To Learn The Index Number Of An Array Node?
Hello all!
This is kind of complicated, I think. I have a multidimensional array:
myArray = newArray()
myArray[0] = new Item(buttonA, "nameA", ArrayA);
myArray[1] = new Item(buttonB, "nameB", ArrayB);
myArray[2] = new Item(buttonC, "nameC", ArrayC);
myArray[3] = new Item(buttonD, "nameD", ArrayD);
Thus, on the main screen there are 4 buttons (named ButtonA - ButtonD) and a dynamic text which displays a string according to the variable: Screen.
I am trying to make a function so when I onMouseOver one of the buttons, such as ButtonA the function finds out what Array ButtonA belongs to and sends "nameA", which is also part of myArray[0], to the dynamic text, Screen.
If someone would be so very kind as to help me, I would be very grateful.
__________________
- Brother Gabriel
Max Number Of Flash Elements In A HTML.
I was trying to see how many maximum flash elements can be present in a single HTML page. I was planning on having many such elements in a page which were generally of smaller width and heights. I saw that when I opened 50 such elements everything became slow and on opening another tab in firefox with the same 50 elements my ff crashed. What can be the reason and what is the max number of flash elements which are generally expected to be present in a page.
I dont see any shoot in CPU and memory and hence I cannot really understand what the problem is.
Slow Animation Linked With Number Of Elements?
Wondering if anyone knows of any potential problems with choppy animation of a panel (your basic simple rectangle) opening over top of some hefty complex vector images...it's not like I'm animating the vector image, but perhaps the player needs to recalculate the vector image anyways when you place something OVER top of it???
Am I correct assume this?
Any work arounds that anyone can think of?
thanx in advance
cheers
How To Push A Dynamic Number Of Elements Onto An Associative Array?
Hello,
I have been working with flash remoting in actionscript 3.0 and there is no result set class. I'm fairly new to AS3, but I am very fluent with AS2, and so far the migration has been easy.
I would like to create a result set class myself, but I am stuck on one part, pushing the dynamic number of elements onto the array, let me show you what I mean:
{ // start result function
var totalCount:Number = rs.serverInfo.totalCount; // # of records returned
var queryString:String = rs.serverInfo.intialData; // query string, each value separated by a comma
var queryArray:Array = new Array();
queryArray = queryString.split(",");
var columnString:String = rs.serverInfo.columnNames; // names of the columns, separated by a comma
var columnArray:Array = new Array();
columnArray = columnString.split(",");
var columnLength:Number = columnArray.length;
var myResultSet:Array = new Array();
// now I have the column names stored in columnArray, and the records stored in queryArray, I would like to make myResultSet an associative array with the column names matching the records. The records come back in the same order the column names do, so keep a recordPosition variable like this:
var recordPosition:Number = 0;
var columnPos:Number = 0;
for(var i:int = 0; i < columnLength; i ++){
recordPosition = i * columnLength;
// this is the part i'm stuck on, i'm currently hard coding my parsing of the query object now because of this, also I don't know if this is how you eval() correctly in AS 3.0
queryArray.push({[columnArray[columnPos]]: queryArray[i], ... [columnArray[columnPos+columnLength-1]]: queryArray[i+columnLength-1]);
}
}
From all the examples I've seen you have to push all the elements into the array at once, statically. I think it may just be some kind of concept I am missing, because I want to loop inside of the push(), but I know that is not possible.
Can anyone enlighten me on this?
How To Push A Dynamic Number Of Elements Onto An Associative Array?
Hello,
I have been working with flash remoting in actionscript 3.0 and there is no result set class. I'm fairly new to AS3, but I am very fluent with AS2, and so far the migration has been easy.
I would like to create a result set class myself, but I am stuck on one part, pushing the dynamic number of elements onto the array, let me show you what I mean:
{ // start result function
var totalCount:Number = rs.serverInfo.totalCount; // # of records returned
var queryString:String = rs.serverInfo.intialData; // query string, each value separated by a comma
var queryArray:Array = new Array();
queryArray = queryString.split(",");
var columnString:String = rs.serverInfo.columnNames; // names of the columns, separated by a comma
var columnArray:Array = new Array();
columnArray = columnString.split(",");
var columnLength:Number = columnArray.length;
var myResultSet:Array = new Array();
// now I have the column names stored in columnArray, and the records stored in queryArray, I would like to make myResultSet an associative array with the column names matching the records. The records come back in the same order the column names do, so keep a recordPosition variable like this:
var recordPosition:Number = 0;
var columnPos:Number = 0;
for(var i:int = 0; i < columnLength; i ++){
recordPosition = i * columnLength;
// this is the part i'm stuck on, i'm currently hard coding my parsing of the query object now because of this, also I don't know if this is how you eval() correctly in AS 3.0
queryArray.push({[columnArray[columnPos]]: queryArray[i], ... [columnArray[columnPos+columnLength-1]]: queryArray[i+columnLength-1]);
}
}
From all the examples I've seen you have to push all the elements into the array at once, statically. I think it may just be some kind of concept I am missing, because I want to loop inside of the push(), but I know that is not possible.
Can anyone enlighten me on this?
Help Getting The Text From Inside A Node.
Hey i need help getting the text form inside one of the nodes from an XML.
This is a section of my code:
ActionScript Code:
var ItemAttributesNode: XMLNode = ItemNode.childNodes[7];
var ASINNode: XMLNode = ItemNode.childNodes[0];
var xhgh: String = ASINNode.nodeValue; // i need help getting the text from inside this node. i think .nodeValue is wrong.
trace(xhgh);
this is part of the xml:
HTML Code:
<Item>
<ASIN>This is the text i need</ASIN>
</Item>
Creat Text Field Depending On The Number Of Elements Of An Array
Hi, I have this question, I dont know very well to explain it but here it goes:
I have an array, and i want that the values in the array apear in an text field.
however for example if there is 4 elements in the array it creat 4 text fields ...and so on..
how can I do that
Insert Html Tags Inside XML Node
What would be the correct way to insert a block of html inside an xml node?
Code:
<root>
<text>html goes here</text>
</root>
html block to go into the node:
Code:
<P><FONT>Hello <B>World</B></FONT></P><P><FONT>Hi you!</FONT></P>
Any help would be greatly appreciated.
Form Tag Elements Inside Flash
I need to be able to browse for a file inside of flash. Is there a way to reproduce the file browse tag from an html form inside of flash?
I am using php to check and upload the image. I can call php from flash its just that flash cannot browse the clients computer for files!
Really need help on this one!
Thanks,
Positioning Elements Inside Triangle
I want to develop a Christmas tree, how can i populate this triangle with elements dinammicaly loaded from the library?...the code so far..
<code>
for(var i:Number =0; i<MenuArr.childNodes.length ;i++){
var star:MovieClip = _root.attachMovie("estrella","star"+i,_root.getNex tHighestDepth());
star.starId = MenuArr.childNodes[i].attributes.id;
star.nombre = MenuArr.childNodes[i].attributes.nombre;
star.texto = MenuArr.childNodes[i].attributes.texto;
//Posicionamiento.
star._x = randRange(coordenadas[3], coordenadas[2]);
star._y = randRange(coordenadas[1], coordenadas[0]);
if(landing_mc.hitTest(star)){
//star._alpha = 20;
};
};
function boundsLanding():Void{
var bounds_obj:Object = landing_mc.getBounds(this);
for (var i in bounds_obj) {
coordenadas.push(bounds_obj[i]);
};
};
//Random a partir de un RANGO.
function randRange(min:Number, max:Number):Number {
//trace(min); trace(max);
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
};
</code>
txs in advance!
Position Elements With Stage Co-ordinates When Inside A MC
Hi... I am trying to dynamically set position on certain movie clips, which is normally fine.
However is it possible to set the position relative to the stage rather than the movie clip its in? So set the x + y co-ordinates relative to the stage?
Thanks for any help in advance.
Scott
How To Attach Library Elements Inside A Loaded Movie
Hello,
I have loaded a .swf multiple times, and all is working. I am indexing these .swf's in an array.
I now want to have control over which clip inside the .swf's are loaded. I have many clips inside, all with linkage classes and runtime sharing off.
Should runtime be on? I would assume this would cause conflict with loading multiple instances of the .swf
so how do I attach / remove the library elements into the loaded .swf's 'container' movieclip?
Problem Accessing Elements Inside A Dynamically Called MovieClip
I have a MovieClip setup with login and password section inside. It sits inside the library, and is dynamically called in, using attachMovie.
Problem:
When the MovieClip is on the stage, everything seems to work fine. I can click on the elements inside, etc. But when it's being called by AS2, I can't seem to access anything inside.
Here's an example:
/* =============================================== */
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
// login button
this.createEmptyMovieClip("login_mc",31);
login_mc.attachMovie("loginPanel","login_mc",this.getNextHighestDepth(), {_x:Stage.width / 2, _y: Stage.height / 2});
login_mc._visible = false;
loginBtn.onRollOver = function() {
login_mc._visible = true;
var panelAlphaIn:Tween = new Tween(login_mc, "_alpha", Strong.easeInOut, 0, 100, 5, false);
};
login_mc.onRollOut = function() {
var panelAlphaOut:Tween = new Tween(this, "_alpha", Strong.easeInOut, 100, 0, 5, false);
panelAlphaOut.onMotionFinished = function() {
login_mc._visible = false;
};
};
/* =============================================== */
'loginBtn' is the login mc instance, and 'login_mc' gets created dynamically and tweened in.
Thanks in advance~!
[AS] Get Number Of Images Inside A Folder
Hi there,
Is it possible to retrieve how many images are inside a folder to populate an array? Only with AS.
I want to load all images inside a folder into a MC without knowing how many are inside the image folder.
Using XFTree: Getting The Parent Node Of Selected Node?
I'm using the XFTree component (great component) and I'm hoping there is a way to return the parent node of whatever node is selected in the tree. Does anyone know.
I can use getSelectedNode() to return the selected node for example, but I can't use: getSelectedNode().ParentNode for instance since the selected node that is returned is no longer attached to its original XML object.
Also, (and this is the larger issue) I really have no idea where the documentation is for this. Is there any? Aside from the list o' methods in the actionscript panel I mean.
Thanks in advance!
Finding A Node In XML File Via Node Attrib?
Hi guys,
I thought this was going to be easy! I would like to search an XML file for a particular data set i.e. set of nodes depending on a passed variable. However, storing a subset of my XML file via
ActionScript Code:
var gallery = this.firstChild;
and then searching 'gallery' as you would an array-using a for()-doesn't work since this.firstChild isn't returning an array . Any ideas?
A sample of my XML and function are below.
Cheers!
Code:
<gallery>
<collection title="Christmas 2004">
<picture title="Tiny Disk" thumb="portfolio_images/thumbs/tinydisk.jpg" description="portfolio_text/tinydisk.txt" image="portfolio_images/tinydisk.jpg"/>
<picture title="Plug" thumb="portfolio_images/thumbs/plug.jpg" description="portfolio_text/plug.txt" image="portfolio_images/plug.jpg"/>
</collection>
<collection title="Christmas 2004">
<picture title="Tiny Disk" thumb="portfolio_images/thumbs/tinydisk.jpg" description="portfolio_text/tinydisk.txt" image="portfolio_images/tinydisk.jpg"/>
<picture title="Plug" thumb="portfolio_images/thumbs/plug.jpg" description="portfolio_text/plug.txt" image="portfolio_images/plug.jpg"/>
</collection>
</gallery>
And the AS function....
ActionScript Code:
function getCollection(collection) { //set the popup invisble when choosing a new gallery var gallery_xml = new XML(); gallery_xml.ignoreWhite = true; gallery_xml.onLoad = function(success) { if (success) { trace("XML loaded"); var gallery = this.firstChild trace("gallery:" +gallery instanceof Array); for(var i=0; i< gallery.length; i++){ trace("searching for collection..."); //find collection data if(gallery[i].attributes.title==collection) { trace(collection+ " collection found"); //store collection parent node var collection = gallery[i].childNodes; collectionInfo.text = collection.attributes.title; var totalItems = collection.childNodes.length; buildGallery(collection, totalItems); break; } else if(i==gallery.length) { trace("Collection not found!"); galleryInfo.text = "Not found"; break; } } } else { trace("Error loading XML file"); } }; gallery_xml.load("gallery.xml");}
Elements Within Elements Creating Line Break - CSS Formatted Text
Im trying to format some text using elements within elements so i can have certain sections a different style or whatever (like underline a bit) - but when a new element is inserted to do this, it creates an unwanted line break
This is the actionscript to create the text on some timeline.
ActionScript Code:
_root.cssStyle(details_txt)
details_txt = "<.main><.date>Some date:</.date>Some text<br>"
details_txt += "<.date>Some date:</.date>Some more text"
This is the actionscript on the _root level. *NB* <a href='bla bla'> hyperlinks or <b> or <u> etc, dont create linebreaks.. only custom tags
ActionScript Code:
cssStyle = function(my_txt){
var my_css = new TextField.StyleSheet();
my_css.setStyle(
"a",{
textDecoration: 'none',
color: '#09A8D7'
}
);
my_css.setStyle(
"a:hover",{
fontFamily: 'Arial',
fontSize: '10px',
textDecoration: 'none',
color: '#0C758B'
}
);
my_css.setStyle(
".main", {
fontFamily: 'Arial',
fontSize: '10px',
color: '#000000'
}
);
my_css.setStyle(
".date", {
fontFamily: 'Arial',
fontSize: '10px',
color: '#666666'
}
);
my_txt.styleSheet = my_css;
my_txt.html = true;
my_txt.autoSize = "left";
my_txt.scroll = false;
my_txt.multiline = true;
my_txt.wordWrap = true;
}
Calling Function Located On A Frame Number Inside A MC
Hi everyone,
I have a movie clip on the stage which contains 4 frames and i wanna call a function from for example frame number 4... Obviously i wanna call this function from the main timeline containing all the MC. How can i do that, i have been looking around but cannot find much...
Can anyone help me achieve this please
Thanks in advance,
Jerome
Sort Random Elements Into Ascending Elements
Dear Sir or Madam:
How do I get column A to display as Column B. Column B is just an ascending array of the same numbers in Column A.
Can't this be accomplished with a query update built-in function?
Column A ColumnB
08,24,11,21,22 08,11,21,22,24
19,18,09,22,14 09,14,18,19,22
23,22,06,21,08 06,08,21,22,23
10,06,23,12,02 02,06,10,12,23
17,10,06,20,02 02,06,10,17,20
22,18,07,01,06 01,06,07,18,22
17,16,09,11,02 02,09,11,16,17
08,12,10,19,23 08,10,12,19,23
Determine An Exact Frame Number For Use Inside A Movie Clip
Hi,
I am creating a big movie that has multiple scenes. However, I want a navigational bar on the side, so I used a single movie movie clip that I placed inside each scene. However, I can't get the root movie to go to the correct frame by using this code inside that movie clip:
Code:
_root.gotoAndPlay("Scene Name",1);
It will only take a number like this:
Code:
_root.gotoAndPlay(435);
I have been getting the exact frame number from the size report, however this is time consuming. Is there a way for my player to get calculate this exact frame number and store it to a variable that I can use inside this movie clip?
This would make my life a whole lot easier.
Jeff
Node To Node Path Finding
Can anybody help me with this one. I had been looking for a tutorial that will find the shortest path from node to node. I have attached a sample picture to illustrate the problem.
I have created a symbol(dot) and name it pt01,pt02,pt03,pt04,pt05,and pt06. All I want is to find the shortest path from pt01 to pt06 and if ever it find the shortest path, it will draw a line from pt01,pt03,pt05 then pt06.
XML: Add Child Node To Existing Node
Hello all, just trying to get straight how this works.
Say I create some XML like so:
ActionScript Code:
var sample:XML = <sample>
<items>
</items>
</sample>
How would I now add an <item/> to the items elements? I've been trying to use
ActionScript Code:
sample.items.appendChild(<item/>);
but it hasn't seemed to work.
Any ideas? Thanks for reading.
-Dane
XML Element Node Vs Text Node
I have created an application via Flash/AS2 that is basically a form that updates a graphic based on the information given. I have those options saving into an XML file on the local hard drive at the location of the users choice. The problem I'm having is reading that XML file back in from the XML file (this was suppose to the the easy part).
Where I'm getting stuck is the NodeType... all my nodes are being typed as "1 - Element" so I can grab the nodeValue... instead it give me NULL.
My question is... did I code something wrong? is there a way to declare a node type?
ActionScript Code:
//SAMPLE XML
<?xml version='1.0' encoding='UTF-8' ?>
<allflex>
<tag>
<act>12345</act>
<contact_name>Test XML</contact_name>
<tag>
</allflex>
//ACTTIONSCRIPT 2.0
loadfile.onRelease = function () {
var feed_xml:XML = new XML();
feed_xml.ignoreWhite = true;
feed_xml.onLoad = function(success:Boolean):Void {
trace("onload...");
if (success) {
trace ("success...");
var thePath_str:String = "/allflex/tag";
var titleNode_str:Array = XPathAPI.selectNodeList(this.firstChild, thePath_str);
trace(titleNode_str[0].firstChild.nodeType);
}else{
trace("error loading XML");
}
};
feed_xml.load("C://xml.xml");
}
//OUTPUT
onload...
success...
1
This tells me I need to get the NodeType to a 3 - Text Node.
Any Information will be greatly appreciated.
Indexing A Node Below A Parent Node?
My problem: Attached within my node-hierarchies are text that I want to stay behind "sibling" node-hierarchies. Only solution I've found now is to attach the text to the root node, but then they loose their positional/scalar relationship to the node-hierarchies they're part of.
Are anyone aware about a solution to this problem?
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
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]
}
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]);
}
}
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!
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);
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
TextField - Number Of Lines, Number Of Characters
Hello,
I'm trying to get some insight on the textField object in flash.
I know how to get the textfield length and number of characters. But I need to know more.
Is there a way to get the number of characters on a line in a multiline textfield?
Thank you in advance.
Decimal Number To Binary Number ?
In ActionScript, I can use parseInt to convert binary num to decimal number. But how can I convert decimal number to binary number? I try find in AS dictionary but there isn't result.
I have an input textfield to enter the decimal number, and an other to display the binary number.
Please tell me how...Thx U,
Variable Number = Frame Number#$%@&*
I have a movie Clip called “percentage bar” and a variable text box called “percentage”.
Now I get a number from VB and this number is = to the value of ”percentage” (my variable txt box).
The Movie Clip has a 100 frames… here it comes I need to have whatever the variable number (“percentage”) is to determine which frame the movie clip (“percentage bar”) is standing on.
This has to be possible, don’t it?
Help Can't Convert String To Number With Number()
I'm pulling variables from an XML file and need to convert the strings from the XML to numbers. So, I have the following actionscript:
Code:
thisPC_Price = aPrice[0].stringValue();
trace(thisPC_Price);
trace(Number(thisPC_Price));
The first trace returns 100, which is the contents of the string (it's also treated like a string by the AS and if I try and do anything to it it will return NaN, as it should). The 2nd trace action returns NaN ..... and I have no idea why.
Anyone have any ideas?
Variable Number = Frame Number ?
Here's an easy one for anyone who knows actionscript...
I have a variable text box called "percentage" and a movieClip called "progressbar" (100 frames).
I want the number in my variable txt box "percentage" to tell "progressbar" to go to the corresponding frame number.
for instance if the number in the txt box is 15 the movieclip has to go to frame 15.
Thanks
- a Designer, forced to be a programmer.
What Is The Name Of This Node?
Here is my XML code-
<cellPhoneText>
<downLoadRingToneText>TEXT</downLoadRingToneText>
<ringtoneText>RINGTONE</ringtoneText>
<youHaveSelectedText>YOU HAVE SELECTED:</youHaveSelectedText>
<previewText>PREVIEW</previewText>
<selectYourWirelessCarrierText>
<phone carriers="Carrier"></phone>
<phone carriers="Carrier"></phone>
<phone carriers="Carrier"></phone>
</selectYourWirelessCarrierText>
</cellPhoneText>
I need to know what the name of "selectYourWirelessCarrierText" is so I can call it from my flash file. I also need to know how to call it's childNodes as well.
Can anyone help? I posted this in the XML board as well but noone is on it.
XML Node Name
I attempted to find a previous forum for my problem, but I didn't find anything is explained by I sudden can't obtain the node name from my XML.
First this my XML file
Code:
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<FLVCoreCuePoints Version="1">
<CuePoint>
<Time>1932</Time>
<Type>event</Type>
<Name>Marker 02</Name>
<Parameters>
<Parameter>
<Name>bullet</Name>
<Value></Value>
</Parameter>
</Parameters>
</CuePoint>
<CuePoint>
<Time>24544</Time>
<Type>event</Type>
<Name>Marker 01</Name>
<Parameters>
<Parameter>
<Name>bullet</Name>
<Value></Value>
</Parameter>
</Parameters>
</CuePoint>
</FLVCoreCuePoints>
And I want to pull it in and store in an Object/Array. It seemed like an easy assignment when I started, but I can't get the node names and that is an important part. I can't reformat the XML file as it is published by another program, so I need to import as is. Here is my XML Loader class.
Code:
package pageComponents.soundComp
{
import flash.events.Event;
import flash.display.Loader;
import flash.net.URLLoader;
import flash.net.URLRequest;
public class CueXML
{
private var filename:String;
private var xml:XML;
private var xmlList:XMLList;
private var XMLData:Object;
private var tempArr:Array;
public function CueXML(pFilename:String)
{
filename = pFilename;
XMLData = new Object();
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest(filename));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
}
public function xmlLoaded(e:Event):void
{
xml = XML(e.target.data);
var a:int;
var b:int;
xmlList = xml.children();
tempArr = new Array();
for(a=0; a < xmlList.length(); a++)
{
tempArr.push(new Object());
var xmlcue = xmlList[a].children();
for(b=0; b < xmlcue.length(); b++)
{
var xmlChild = xmlcue[b];
trace(xmlChild.node.nodeName);
}
}
}
}
What am I missing, why can't I see the node name?
Samac
Getting An XML Node Into A Var
Hi, I have a datagrid called dg that has data populated to it thru an external XML. What I am trying to achieve is whenever someone clicks on an item in the grid it stores that items coordinates to a variable called locCoordinates. At this moment it is tracing out the coordinates for all of the items in the grid. I just dont know how to go about only getting the selected items coordinates. Any help is appreciated. I attached a sample of my XML and my AS3 code.
Thanks
XML Snippet
Code:
<?xml version="1.0" encoding="UTF-8"?>
<Document>
<Placemark>
<description>Location Name</description>
<LookAt>
<longitude>-80.08228780449664</longitude>
<latitude>26.76333909302779</latitude>
<altitude>0</altitude>
<range>800531.7783723106</range>
<tilt>0.2434603296494301</tilt>
<heading>2.751823574569335</heading>
<altitudeMode>relativeToGround</altitudeMode>
</LookAt>
<styleUrl>#msn_mechanic1</styleUrl>
<Point>
<coordinates>-80.08228780449664,26.76333909302779</coordinates>
</Point>
</Placemark>
AS3 Code
Code:
//Packages
import com.afcomponents.umap.core.UMap;
import com.afcomponents.umap.providers.google.GoogleProvider;
import com.afcomponents.umap.types.LatLng;
import com.afcomponents.umap.overlays.KMLLayer;
import com.afcomponents.umap.styles.MarkerStyle;
import com.afcomponents.umap.styles.GeometryStyle;
import com.afcomponents.umap.display.markermanager.MarkerManager;
import com.afcomponents.umap.display.markermanager.ExpandedGroupPattern;
import com.afcomponents.umap.overlays.Marker;
import com.afcomponents.umap.overlays.Layer;
import com.afcomponents.umap.interfaces.IOverlay;
import com.afcomponents.umap.events.OverlayEvent;
map.addControl(ZoomControl);
map.addControl(MapType);
map.addControl(PositionControl);
//Set Map Provider
var settings:URLRequest = new URLRequest("http://umap.s3.amazonaws.com/assets/xml/GoogleSettings.xml?rand=" + Math.random());
var language:URLRequest = new URLRequest("http://maps.google.com/maps?file=api&v=2");
var copyright:URLRequest = new URLRequest("http://www.afcomponents.com/proxy/g_map_as3/copyright.php");
map.setProvider(new GoogleProvider(false, settings, language, copyright));
//Create Layers - Load KML Points - Center/Set Map Zoom
var theKml:KMLLayer = new KMLLayer();
theKml.load("MarooneServiceCenters.kml");
theKml.addEventListener(Event.COMPLETE, theKmlComplete);
map.addOverlay(theKml);
function theKmlComplete(e:Event):void {
theKml.addEventListener(OverlayEvent.READY, ready);
function ready(event) {
// change icons for loaded markers
var style:Object = {icon:"wrenchmarker.gif"};
applyStyleToMarkers(theKml, style);
}
function applyStyleToMarkers(layer:Layer, style:Object) {
for each (var overlay:IOverlay in layer.getOverlays()) {
if (overlay is Marker) {
overlay.setStyle(style);
} else if (overlay is Layer) {
applyStyleToMarkers(Layer(overlay), style);
}
}
}
map.setCenter(new LatLng(26.210,-80.220),9);
}
var myXML:XML = new XML();
myXML.ignoreWhite = true;
var XML_URL:String = "MarooneServiceCenters.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", parseXML);
//Loads Datagrid with Locations
function parseXML(e:Event):void {
myXML = new XML(e.target.data);
for (var i:int = 0; i <myXML.*.length(); i++) {
dg.addItem({Locations:myXML.Placemark.description.text()[i]});
dg.addEventListener(MouseEvent.CLICK, locSelect);
}
//Loads Location Coordinates into Var
function locSelect(e:Event):void {
var locCoordinates = int;
locCoordinates = (myXML.Placemark.Point.coordinates);
trace(locCoordinates);
}
}
Which Node?
<Result><Item>
<Index>a</Index>
</Item> <Item>
<Index>b</Index>
</Item><Item>
<Index>c</Index>
</Item></Result>
myxml = new xml;
How to find the item b's item number. Meaning i want to get the node number 1.
Thanks
|