Flex 2 Example (admin for news ticker) - Editing XML and saving it back to the server
In this example we pull some XML data into Flex and keep it as an XML object. We then edit the data with a Flex GUI and save it back to the server. To make things more interesting I created a simple “News Ticker” in Flash 8 that is built from the same XML. You get a semi-automatic preview of the ticker directly within the GUI.
I can see a real use for these simple Flex apps to easily allow people to manage all sorts of configurations settings without having to actually look at the XML (or other underlining data).
The ticker (4kb) is shown at the end of this post. Everyone can modify the data using the admin control… so I don’t know how the ticker will look when you view it at this point in time.
There is nothing “fancy” in the Flex code just a lot of semi-manual binding of various data elements to the nodes and attributes in the XML file. The source code is commented and it shouldn’t be hard to understand what is happening. If you have any questions post them below and I’ll answer them.
Files:
Admin For Ticker (requires Flash 8.5 player)
Project File
MXML File
Linked Actionscript in MXML
Current XML
Ticker:
Comments
I was wondering how long it would take for someone to delete most of the items.
24 hours isn't bad. :)
Posted by: Adam Schroeder | December 15, 2005 05:04 PM
For me works fine, but i try to join a mx:image and dont work, error in loader the example was interesting if he can join a image, but i dont know how.
import mx.controls.Loader;
and I missing someting
thanks
Posted by: josé Sal | December 18, 2005 09:00 AM
I'm not sure exactly what you are trying to do.
You will get an error if you try to run my example locally on your computer (like from c:).
In order to get around the sandbox issues you will need to run it on a server (or localhost) with the crossdomain.xml in the root.
I just set mine to * to make it as easy as possible for testing.
You can see the one on evilfree.com at http://www.evilfree.com/crossdomain.xml
If thats not the problem then make sure the path to your mx:image is correct. If you are using a relative path it will be different from what you get if your browser for the file within the IDE. This is because the published swf will be in the "Bin" directory (by default) and the path flex creates is using the folder where the mxml source file is.
Posted by: Adam Schroeder | December 18, 2005 09:24 AM
Thaks for your replay.
I dont explain very well what I`am trying to make.
I have in XML file a node with a paht to a folder with images, I use your ex. only a data grid and the text filds, not complete with a ticker.swf and the others atributes of color and etc.
But and I try to use {newsItemData.image
or
{configData.image
image is the name of the node in xml.
I get a error.
the way that XML {buildArray come in is not write to load a image i think.
I use your ex. of xml node or atribute, atribute win to make a catalog an now i try to make a admin of that catalog to write with php script that xml, its ok i can write the file run on localhost, the only problem is and i try to join a mx:image using the xml buildArray i have so many things to learn.
Thanks
ps. For the people that follow your blog and learn a lot its good ideia that the ex. using the same files for ex the XML file and he can work and learn on another step.
sorry the bad international web inglis.
Posted by: Anonymous | December 20, 2005 10:55 AM
I'm glad you have found the example helpful. Feel free to post an link to your catalog.
I think the problem is that in most case Flex is automatically converting the type of the data it needs when you bind it {}.
However in the case of an image I think it is possible to directly send an image object to an image instead of just sending it a path so Flex is not automatically converting the path to a string.
I think if you used
{String(configData.image)} or {String(configData.@image)}
it would work for you.
Posted by: Adam Schroeder | December 20, 2005 11:48 AM
Thanks Adam for the replay.
Now with the adjust
source="{String(newsItemData.image)}"
Works great thanks now i can add the path of images and show that images that i have in a folder that i up load with a php html script.
To upload with php and flex I dont know if is possible.
Thanks for your work to learn that people on world wild web
Posted by: josé Sal | December 20, 2005 09:33 PM