What part of processing the xml do you not understand? What code do you have so far that is not working for you?
Based on the apparent structure of the data and the image you provide, you will want to parse the data based on processing each servis node entirely one at a time. For each servis node you first want to extract the BolumAdi node, followed by extracting the DoktorAdi nodes within the doktor node.
First step is to import the XML, you can use the URLLoader class to do that, set for text. An example of URLLoader reading XML:
After you load the XML you need to traverse it. Here's an example of accessing elements in the XML you just loaded:
Checking the length() method of each node is a good way to determine existence so that can help you with drawing gray boxes and spawning a MovieClip.
I see your picture on how you expect it to look but are you being literal when you show that picture? If so you need to code it so it stacks the results like you have it and it probably won't look at neat and clean unless you have exactly the same number of rows and columns like in that picture (11 rows, 3 columns).
To make the names with the boxes around them you can either switch the design to a datagrid component (I'm assuming you don't want to) or just draw it like you did using sprites and the graphics class with drawRect:
There's an example there on how to draw a rectangle and color it. You'd just be applying your lineStyle as like a 1 pixel wide black line. Aside that it's just inserting a TextField inside it:
var fieldCount:XML = XML(loader.data);
var bolumLength:int = xml.servis.BolumAdi.length();
var i:int = 0;
var doktorInfo:Array=new Array();
var bolumInfo:Array=new Array();
for (i; i < bolumLength; i++)
if (i < 36)
var bolumler:String = xml.servis[i].BolumAdi;
movies[i+1].alan1.text = bolumInfo;
var k:int = 0;
for (k; k<xml.servis[i].doktor.DoktorAdi.length() ; k++)
var doktorlar:String = xml.servis[i].doktor.DoktorAdi[k].child(0);
trace("ikinci sayfaya artık");
I read xml another frame. I want parse xml and add array. the read . if tag name bolum adi make background grey,else white.
Here's a quick re-write of your code, condensing it down as much as possible.
Obviously in your original you reference a lot of movieclips that are not in the library I see. It's up to you to hook up the bottom function which fires off when you click one of the clips with the blue background.
I re-wrote it to use loops instead of all the hard coded references. I don't know what references you actually wanted to keep around but I'm using the clips name to store the index of the XML element so that should be enough (0-36) so you can program it to load the correct movie. I can't tell you what movie is correct, only you know that.
Saved down to CS4, I don't know what you're working with:
I used the mc you had in the library. I'm assuming you wanted to use that.
thanks sinious. I have another questions. İf i want to add tween this code how to make this. And if info bigger than 36 , i want saw 37-72 in second page in a timer.
You have to jump in somewhere and take over. You can see my code very simply adding in a bunch of your "mc" clips with a name in each of them. A good idea is to make a container (if I didn't, I don't recall) and add all the numbers added to that container. Then use a Timer and when the timer hits, remove all the numbers from the container and add in 37-72, etc. Here's a link to the Timer class with simple examples:
I put in some hard coded logic to display the first 36 items as well as which column and row (x and y position) the next item goes in. You'll need to adjust that code to be more flexible. For example to keep it running just how it does now you can just keep track of a starting position in the XML via a variable like _currentXMLIndex:int = 37;.. Then create a new XMLList that only contains the items you want and feed that into the loop that creates the numbers so it can still start at.
Take what I've done already and experiment. It shouldn't be too hard to figure these things out and you won't get it right off the first try but that's how you grow as a coder. Feel free to post back any specific questions.
If you're done please mark the thread answered and good luck!
Hi Sinious, i try to make but i didn't make this project. I change xml index to 72.
Can you help me?
I can only give you some tips.
Your document only supports 66 as it was originally created. To increase it to 72 simply means you need more vertical document space, 2 more rows with 3 columns. You know the height of each row is 42 so you know you need to add 84px more height to your document.
You have some shared object code I never understood what you were doing with but it still points to 66, so I guess that should be 72:
var so:SharedObject = SharedObject.getLocal("Medipol");
var index:int = so.data.Sayı + 66;
so.data.Sayı = index;
Lastly in the _createTextClip() function you can see hard-coded values. It is checking the "currentTextFieldIndex" and if it's past a certain point it knows to go to the next column. You will need to adjust those to suit. They should be checking instead for "< 23" and "< 45" to "< 25" and "< 49".
I would like to do something else. Currently working as a field 66. If you have more information in the xml show on the second page. I tried to write a timer function, but I could not. For example, a screen renew 10 seconds. Send finished as the first page. If I do it'll take two days off. Need a lot of help, you see.
The help you need is in my above post. Saying someone else should do it because it would take you longer just points out you really need to learn to do things yourself. Come here for questions, not to get your projects completed for you.
Your timer idea is a good idea to keep 66 spots and rotate them. Typically people would offer a < Previous and Next > button to go between pages but I realize that might get complicated for you. To implement your idea of changing pages, all you need to do is keep track of which XML element to start with. If you save a variable on which element to start with and only read elements beyond that it should work fine. You'll need to clear all your clips as well.
Because I rapidly rewrote some of your old code I'll show you 2 simple bits but you need to do this for yourself.
I didn't put your "mc" clips in a container so you'll need to iterate the display list looking for clips with "txt_bilgi-" in their name to remove. To clear out all existing clips so you can "re-create" them would be a function like this:
for (var diIndex:int = 0; diIndex < this.numChildren; diIndex++)
var obj:Object = getChildAt(diIndex);
if (obj.name.toString().indexOf('txt_bilgi-') != -1)
trace("Found: " + obj.name);
Run that to get rid of the "mc" clips that are made. Next make a variable to keep track of your starting point in the XML.
Second, where you loop through the XML with the "for (var k:int = 0; k < xml.servis[i].doktor.DoktorAdi.length(); k++)" is where you want to use the variable. Set the value of k to that number so it either starts at 0 or at another number down the XML so the loop will only iterate on the items you want.
I'm sorry but you'll either need to re-think how static and non-dynamic you're making this. Your approach should be to learn the DisplayObject's graphics class so you can learn to dynamically draw these clips and remove them at will. I've already pasted a line of code and told you how to change the offset you start at. With both of those tools you can make your clips with a TextField dynamically starting and ending at any position you like. There's also some code there to remove the clips before rebuilding them at a new offset. The rest is up to you to implement.