header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Shridhar
Points:0
Posts:0

12/23/2010 6:02:36 AM

Title: About WhiteBoardComponent in Flex


I want to develop a white board compnent in flex
I want some guidance on that. I am using Flex4 and FMS.

I just want to ask if I draw a shape in canvas on button click, then how to update it on FMS using
remoteSharedObject????

Please Help

Thanks for your Cooperation



1
Dave
Points: 970
Posts:1
12/25/2010 1:45:38 AM



remoteShaedObject is used to exchange data on the clients connected.
First you need to connect to FMS sever and then ceate sharedObject and attach a function to syncEvent.
Say you have to draw a shape line, in that case you should store the string containing line properties( color,thickness, x, y, startX ,endX) to shared Object. When you add it to your shared object it will trigger the sync event on all the connected users. And you will receive these properties in the attached listener function to sync event. Now you can use this data to create line on all the users connected.

2
Shridhar Kulkarni
Points: 0
Posts:0
12/25/2010 6:25:23 AM



very very thanks for your reply Dave.
now I am able to draw a single line and it will display on another shared screen.

1>But application is giving error at initlilze of null object reference as no object passed at initilize. how to overcome i??

2> whenever I draw a curve by mouse pointer a straight line again joines the 2 points, means 2 line gets drawn i> curve ii>straight line btwn 2 points

3>on the other screen the line is getting drawn bt not at same coordinates.

4> I am struggling with a multiple line objects passing to the FMS. and a for loop to retrieve it in sync it.
pls help me so that i can complete my line part and go for circle


3
Shridhar Kulkarni
Points: 0
Posts:0
12/25/2010 6:33:30 AM



I am posting my code here


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" initialize="init();">
<mx:Script>
<![CDATA[
import flash.display.CapsStyle;
import flash.display.JointStyle;
import flash.display.LineScaleMode;
import flash.display.Shape;
import flash.display.Sprite;

import mx.containers.Canvas;
import mx.controls.Alert;
import mx.core.UIComponent;
import mx.utils.ObjectUtil;

private var _canvas:Canvas;
private var allowDrawing:Boolean=false;

private var _startX:Number;
private var _startY:Number;
private var _endX:Number;
private var _endY:Number;
private var _netConnection:NetConnection;
private var _remoteSO:SharedObject;


private function init():void
{
_canvas = new Canvas();

this.addEventListener(MouseEvent.MOUSE_DOWN,mouseDownHandler);
this.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
this.addEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
this.addChild(_canvas);


_netConnection = new NetConnection();
_netConnection.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);

//--------"whiteboard" folder created at FMS in applications folder
_netConnection.connect("rtmp:/whiteboard");


}

private function netStatusHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
// Successful connection to the server
case "NetConnection.Connect.Success" :
createARemoteSO() ;
break ;
}
}

private function createARemoteSO():void
{
//
_remoteSO = SharedObject.getRemote("drawing_whiteboard",_netConnection.uri,false);
_remoteSO.connect(_netConnection);


_remoteSO.addEventListener(SyncEvent.SYNC,drawLineHandler);
}

private function drawLineHandler(event:SyncEvent):void
{
var lineObj:Object= _remoteSO.data.line as Object;
_canvas.graphics.lineTo(lineObj.startX ,lineObj.startY );
_canvas.graphics.moveTo( lineObj.endX, lineObj.endY);


//here i get stuck in getting all lines object????????????????????????/

/* for each(var slot1:String in _remoteSO.data)
{
Alert.show(ObjectUtil.toString(_remoteSO.data[slot1]) )
} */
}


private function mouseDownHandler(mEvent:MouseEvent):void
{
_startX= mEvent.target.mouseX as Number;
_startY = mEvent.target.mouseY as Number;
_canvas.graphics.moveTo(_startX,_startY);
_canvas.graphics.lineStyle(5, 0x00000,1, false,CapsStyle.ROUND);
allowDrawing=true;
}

private function mouseMoveHandler(event:MouseEvent):void
{
if(allowDrawing)
{
_endX=event.target.mouseX as Number;
_endY=event.target.mouseY as Number;
_canvas.graphics.lineTo(_endX,_endY);
event.updateAfterEvent();
}

}

private function mouseUpHandler(event:MouseEvent):void
{
allowDrawing = false;
var lineObject:Object = new Object();
lineObject.startX= _startX;
lineObject.startY= _startY;
lineObject.endX = _endX;
lineObject.endY =_endY;

//what for multiple line or drawing?????????????????????????/

_remoteSO.setProperty("line", lineObject as Object);
_canvas.clearStyle(null);


/* var slot:Object = "line_" + _startX + "-" + _startY + "X" + _endX + "-" + _endY;
_remoteSO.data[slot] = lineObject;
//sthis.removeEventListener(MouseEvent.MOUSE_MOVE,mouseMoveHandler);
*/
}



]]>
</mx:Script>
</mx:Application>

4
shrikumar
Points: 220
Posts:0
12/29/2010 2:09:16 AM



Check this link

http://www.jamesward.com/2006/08/16/flex-paint-flex-display-object-to-png/


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 0+7 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions