Hardik Patel
Hardik Patel

Reputation: 937

modify xml generated by flash?

I am new to flash and actionscript.

I want to modify the xml file of flash once it generated.

You can see this tutorial http://www.webwasp.co.uk/tutorials/A_IntAct-02-drag-drop/index.php here when i change the position i want new xml file with update.

Any Help is greatly Appriciated. Thanks,

Upvotes: 1

Views: 643

Answers (2)

recursivity
recursivity

Reputation: 144

The examples given in the website refers to mx 2004. You can see a more up to date example here.

Upvotes: 0

Taurayi
Taurayi

Reputation: 3207

Not having mostly any idea what exactly your asking for, I created an example with a square that can be dragged and dropped. When its dropped it writes xml to an xml file with the x and y co-ordinates of the dropped square:

package 
{
    import flash.display.*;
    import flash.events.*;
    import flash.filesystem.*;
    import flash.utils.*;

    public class Main extends Sprite 
    {
        private var _square:Square;

        public function Main():void 
        {
            _square = new Square();
            _square.addEventListener(MouseEvent.MOUSE_DOWN, onSquareMouseDown);
            addChild(_square);

        }// end function

        private function onSquareMouseDown(e:Event):void
        {
            _square.startDrag();

            stage.addEventListener(MouseEvent.MOUSE_UP, onStageMouseUp);

        }// end function

        private function onStageMouseUp(e:Event):void
        {
            stage.removeEventListener(MouseEvent.MOUSE_UP, onStageMouseUp);
            _square.stopDrag();

            var xml:XML = <dragAndDrop>
                              <x>{_square.x}</x>
                              <y>{_square.y}</y>
                          </dragAndDrop>;

            var file:File = File.desktopDirectory.resolvePath("xml/dragAndDrop.xml");
            var fileStream:FileStream = new FileStream();
            fileStream.open(file, FileMode.WRITE);
            fileStream.writeMultiByte(String(xml), "iso-8859-01");
            fileStream.close();

        }// end function

    }// end class

}// end package

import flash.display.Sprite;

internal class Square extends Sprite
{
    public function Square()
    {
        graphics.beginFill(0xFF0000);
        graphics.drawRect(0, 0, 100, 100);
        graphics.endFill();

    }// end function

}// end class

Upvotes: 2

Related Questions