XML to TextField

HOLY SHIZNIT!!!

Ironically I was just about to start learning XML in Flash tonight, and you posted this…LOL.

Way awesome. Thanks Sen. It cleared up a lot. Still got a lot ahead of me, but ■■■■… great start.

Hey Sen… If it isn’t too much trouble can you go over dynamically loading XML in for dynamic menus and such?

Only if it isn’t too much trouble, I am going to look around online for tutorials on this anyway.

*Originally posted by lostinbeta *
**Hey Sen… If it isn’t too much trouble can you go over dynamically loading XML in for dynamic menus and such?

Only if it isn’t too much trouble, I am going to look around online for tutorials on this anyway. **

did you see the zip in the first page? That might help a little. If you dont find anything, let me know and I can whip something up… not tonight though :wink: [size=1](why havent I left yet? lol)[/size]

Yeah, I tried the .zip file on the first page, it gave me a 404 file not found error.

try this

http://userpages.umbc.edu/~tmccau1/swap/combo_box.zip

'night

:beam:

Goodnight Sen. Thanks again.

And the file worked.

Ok… I didn’t look for any tutorials yet, but I created something like what I was going for just with your tutorial.

Yep, I just did what I had to do while following your excellent explanation sen. Check the .zip file to see what I came up with.

(NOTE: The font on the menu is hooge_05_53 from www.miniml.com , if you don’t have it, it will look funky)

Now all I need to figure out is how to add submenus in there.

Like when it is clicked have the other stuff go down and have sublinks displayed under the main clip. Oye… I think that might be advanced for me right now, but I will try.

Wow Sen…thank you for this brief overview…j/k:). This helps alot the only thing I don’t understand is how to send data to an external XML file. Would I just use…

myXML.send(http://www.kirupaforum.com/senocular.xml)

That would make sense but I just want to make sure I get it.

Thanks again for taking the time to do all this as well it’s helped a ton .

Thanks,
Michael

*Originally posted by lostinbeta *
**Ok… I didn’t look for any tutorials yet, but I created something like what I was going for just with your tutorial.

Yep, I just did what I had to do while following your excellent explanation sen. Check the .zip file to see what I came up with.

(NOTE: The font on the menu is hooge_05_53 from www.miniml.com , if you don’t have it, it will look funky)

Now all I need to figure out is how to add submenus in there.

Like when it is clicked have the other stuff go down and have sublinks displayed under the main clip. Oye… I think that might be advanced for me right now, but I will try. **

Well the hardest part there is just the handling of the menu, the information is easily translated into XML through childNodes ie:


<**?xml version="1.0"?>
<**MENU>		
	<**ITEM NAME="Lostinbeta">
		<**SUBITEM NAME="Lostinbeta" URL="http://www.lostinbeta.com/" />
		<**SUBITEM NAME="Lostinbeta" URL="http://www.lostinbeta.com/" />
	<**/ITEM>
	<**ITEM NAME="BWBM" URL="http://www.bwbmtransformers.com" />		
	<**ITEM NAME="Kirupa" URL="http://www.kirupa.com/" />
	<**ITEM NAME="Kirupa Forum" URL="http://www.kirupaforum.com/" />
	<**ITEM NAME="Edwin Rosero" URL="http://www.edwinrosero.com/" />
	<**ITEM NAME="Donna Lopez" URL="http://www.donnalopez.com/" />
	<**ITEM NAME="Bit 101" URL="http://www.bit-101.com/" />
	<**ITEM NAME="Deviant Art" URL="http://www.deviantart.com/" />
<**/MENU>

getting that information is just a matter of referencing the childNodes of that main button node, just like getting the attributes, but instead getting the node, then almost repeating the process with newly created submenu buttons (the process of getting the NAME and URL at least)… Ill work on converting your example in my spare time and post it when done…

*Originally posted by Caligldnbears *
**Wow Sen…thank you for this brief overview…j/k:). This helps alot the only thing I don’t understand is how to send data to an external XML file. Would I just use…

myXML.send(http://www.kirupaforum.com/senocular.xml)

That would make sense but I just want to make sure I get it.

Thanks again for taking the time to do all this as well it’s helped a ton .

Thanks,
Michael **

what exactly are you trying to do? XML.send sends the xml object to a URL, usually a serverside script, as a XML document. Thats where you would most likely have a script take and save the xml to a textfile (xml file ;)) on the server or something.

If you are trying to edit an XML file on your server, then youd first load the XML into Flash, edit however you want, then send it back to a script which would replace it.

make sense?

I am trying to send the data to an XML files on the server and bypass the serverside (jsp,php,asp etc.). The reason for this is that I don’t what backend this will eventually be sitting on.

Is this even possible? Sounds like it’s not. I was just trying to find a work around for this so I could get this part working before I find out what backend I will be using.

Make sense?

Thanks,
Michael

if your changing anything permanently on the backend side, yes you need at least SOME, though probably minimal, serverside scripting. All which was explained gives you a way to minupulate and edit the XML in the Flash side of things meaning you wont have to edit it at all server-side. All youd need to do is replace the old XML with the newly (Flash-) edited XML. Typically this would only be a couple lines serverside… open/create, write, close… done.

*Originally posted by senocular *
**Well the hardest part there is just the handling of the menu, the information is easily translated into XML through childNodes ie:


<**?xml version="1.0"?>
<**MENU>		
	<**ITEM NAME="Lostinbeta">
		<**SUBITEM NAME="Lostinbeta" URL="http://www.lostinbeta.com/" />
		<**SUBITEM NAME="Lostinbeta" URL="http://www.lostinbeta.com/" />
	<**/ITEM>
	<**ITEM NAME="BWBM" URL="http://www.bwbmtransformers.com" />		
	<**ITEM NAME="Kirupa" URL="http://www.kirupa.com/" />
	<**ITEM NAME="Kirupa Forum" URL="http://www.kirupaforum.com/" />
	<**ITEM NAME="Edwin Rosero" URL="http://www.edwinrosero.com/" />
	<**ITEM NAME="Donna Lopez" URL="http://www.donnalopez.com/" />
	<**ITEM NAME="Bit 101" URL="http://www.bit-101.com/" />
	<**ITEM NAME="Deviant Art" URL="http://www.deviantart.com/" />
<**/MENU>

getting that information is just a matter of referencing the childNodes of that main button node, just like getting the attributes, but instead getting the node, then almost repeating the process with newly created submenu buttons (the process of getting the NAME and URL at least)… Ill work on converting your example in my spare time and post it when done… **

Yeah, I already knew how to set up the XML to do that, I just am not sure how to get that working in Flash so that when a button is clicked, the ones below it slide down to reveal the sub menu buttons, then when you click another one the buttons slide back up to hide the old buttons, then the new buttons slide down.

As I said though, this might be too advanced for me right now, I might just do a typical hierachial menu.

An example file would be excellent though :beam:

Now as for writing XML to an XML file, wouldn’t that require PHP?

I gotcha senocular :)…This is very straight forward. I just hacked together a quick jsp file and it works…yay!!!

Thanks Again for your help,
Michael

*Originally posted by lostinbeta *
**
Now as for writing XML to an XML file, wouldn’t that require PHP? **

yeah, or some other form of server-side scripting.

here is an exmaple of your file menu-ized. This particular type of menu folds collapses each previously opened submenu before opening a new one… I guess thats what you more or less wanted? Anywho, the code is… hmm maybe not the easiest code in the world but it uses a type of ‘onComplete’ method which is good to know and understand. Its actually onClosed in the script. Its a method which poses as an onComplete method for when a certain action has finished. In this case its the method which is run when the menu closes (hense onClosed). What happens is when the menu has a submenu already open, it needs to close before it can open the new submenu (in this style of menus), so the new submenu kind of ‘waits’ in this onClosed function which finally gets run when the old submenu closes up. Then the new submenu is initiated and the buttons below drop to reveal it.

Well take a look anyway and see if you cant mush through it. If you have any questions, let me know… As it exists now, it operates on one submenu, but conceivebly, you could create a recursive methid of adding submenus onto submenus for whatever heirarchy your XML contains.

This was exactly what I was looking for. You are the best Sen. Thank you so much!!!

I scoped the code quickly it makes sense to me, I would have never been able to come up with it on my own honestly, but reading it I know what everything individual does, I just have to associate how it all works together. Study it and all :slight_smile:

I really appreciate this man. Thanks :slight_smile:

cool… I didnt FULLY comment it because I think it gets messy and unreadable with too many comments, but I did do some basic outlining comments and tried to keep each section fairly seperated without stretching out the code too much. If you want I can go through it piece by piece and explain whats going on if you cant quite put your finger on it all.

study well

Well a full explanation would definitely be helpful if you want to type it. I am pretty good with learning code on my own so if you aren’t up for it then don’t worry about it.

One main thing I am not sure is the onClosed. You use it the same way as onEnterFrame or onRollOver, etc. Is this an undocumented feature of AS?

nope, on closed is just a normal function. I used ‘on’ to kind of cohear to that kind of coding style, resembling onEnterFrame, onRollOver etc. Its defined in the menu button release (myButton.onRelease) and called in the enterframe.

Basically you have your menu. Its just sitting there minding its own business. Then you click on a menu button with a submenu. This button defines the onClosed function for the mainMenu clip (which controlls all the menu movement in its onEnterFrame) and sets the offset of mainMenu to be 0. offset is the movement value. It determines the offset that the lower buttons - those below this currently opening submenu - need to travel to. Thats why its set to be relative to the number of submenus (submenu buttons), all controlled by the mainMenu onEnterFrame. With the offset at 0, this tells the menu to essentially close the menu since there is no offset there is no gap for any menu to exist. mainMenu onEnterFrame, as it moves the low menu buttons up to reach their normal position checks to see when its done (obviously). When it has finished, it calls its onClosed function. This onClosed function, as specified by the menu button, resets the offset to be the new offset for the new menu. This is the ‘waiting’ I was talking about before. That new offset value had to wait in the onClosed function until the menu could close. Only then could it be set to properly reveal the new menu appropriately with the new offset. After the onClosed runs, setting those new values, it then gets deleted. This is because if it still existed, it would run again when it reached the new Offset (acting like an onOpened).

so laying it out you have

click menu button.

  • save new submenu offset in onClosed function
  • set current offset to close menu
  • when menu is closed run onClosed
  • onClosed sets saved offset to open menu for new submenu
  • delete onClosed
  • open menu to new offset
  • rince… repeat…

AH ok, so offset sort of acts like a trigger variable that tells the menu whether to close or open?

And the reason I asked about onClose is because the only documentation I can find on it is the xmlSocketServer.onClose() and it doesn’t turn blue in Flash as a documented function would.