Translate

Home > September 2011

September 2011

Flex Pen tool (Drawing canvas)

Sunday, September 25, 2011 Category : 0

package
{
    import mx.containers.Canvas;

    public class LineCanvas extends Canvas
    {
        public var allowDrawing:Boolean=false;
        public var lineColor:uint = 0xFF0000;
        public var lineThickness:int = 2;

        public function LineCanvas()
        {
            super();
        }

    }
}
save this as LineCanvas.as


ad this your main app

private var lm:LineCanvas;

lm = new LineCanvas();
            canvas.addChild(lm);
            this.addEventListener(MouseEvent.MOUSE_DOWN,mouseDown);
            this.addEventListener(MouseEvent.MOUSE_UP,mouseUp);
            this.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoving);


private function mouseDown(e:MouseEvent):void
        {
        lm.graphics.moveTo(e.target.mouseX, e.target.mouseY);
        lm.graphics.lineStyle(lm.lineThickness, lm.lineColor, 1, false, CapsStyle.ROUND);
        lm.allowDrawing=true;
        }

        private function mouseMoving(e:MouseEvent):void
        {
            if (lm.allowDrawing)
            {
            lm.graphics.lineTo(e.target.mouseX, e.target.mouseY);
            e.updateAfterEvent();
            }
        }


        private function mouseUp(e:MouseEvent):void
        {
            lm.allowDrawing=false;
        }

Flex File Browser (FileSystemTree ,FileSystemDataGrid )

Category : 0

<mx:HDividedBox>
        <mx:FileSystemTree id="tree"
            width="200" height="100%"
            enumerationMode="directoriesOnly"
            change="dataGrid.directory = File(tree.selectedItem);"
            selectedIndex="0"/>
        <mx:FileSystemDataGrid id="dataGrid"
            width="100%" height="100%"
            directory="{new File('C:\\')}"
            extensions="[skdb,skc]"/>
        </mx:HDividedBox>

Flex change Image source dynamically by coding

Tuesday, September 20, 2011 Category : 0

private function loadImages():void
        {
           
            var source:String  = "your dynamic image path";
            var loader:Loader = new Loader();
            var request:URLRequest = new URLRequest(pageSource);
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadCompleteHandler);
            loader.load(request);
        }


private function loadCompleteHandler(e:Event):void
        {
          
            var bitmapData:BitmapData = e.target.content.bitmapData as BitmapData;
            var bitmap:Bitmap = new Bitmap(bitmapData)

            image0.source = bitmap; // where image0 is your mxml file control
            image0.validateNow();
      }

Flex get Mac Address

Monday, September 19, 2011 Category : 0

    import __AS3__.vec.Vector;

    import flash.net.NetworkInfo;
    import flash.net.NetworkInterface;


public function getMacID():ArrayCollection
        {
            var MacAddress:String;
            var ni:NetworkInfo = NetworkInfo.networkInfo;
            var interfaceVector:Vector.<NetworkInterface> = ni.findInterfaces();
            for each (var item:NetworkInterface in interfaceVector)
            {
                var child:NetworkInterface = item as NetworkInterface;
                MacAddress = child.hardwareAddress;
                break;
            }
            return MacAddress;
        }

XML Node read

Monday, September 12, 2011 Category : 0

var buttonsData:XML = XML(XmlString);


for each (var node:XML in buttonsData.children())
            {
                if (node.@id == id)
                {
                    isButtonExsits = true;
                    break;
                }
            }

Flex - You compile your flash application with debugging on

Sunday, September 11, 2011 Category : 0

I have got an error like

Failed to connect; session timed out.
Ensure that:
1. You compiled your Flash application with debugging on.
2. You are running the debugger version of Flash Player.

when i running my application with debugging mode. after expense some time i realize the problem. in my case the problem was my localhost default ip was changed it was 0.0.0.0 instead 127.0.0.1

so if you find same problem you can changed it to 127.0.0.1. this ip was modified when i apply a patch for adobe cs5.

Powered by Blogger.