Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 12-09-2010, 05:07 PM   #1
Registered User
Join Date: Dec 2010
Posts: 1
Question [AS3] ColorPicker vs. Red5

dear AS board!
I'm working on a research project involving color-communication in a closed environment. I've been trying to develop an application for communicating between 2 computers, based on the red5 server possibilities.

I'm very novice in AS... - so there really is some basic stuff that i'm missing in this project to connect the pieces - there fore i'm really hoping for someone to help point me in the right direction.

I'm building upon two components; a colorpicker tutorial, and the basic chat component in red5.

My goal is to have 2 browser .swf's running where the participants can pick a color, output the #hexcode to change the background of a 2 sharedObject's in the browser. (so they are not interfering with the same object, but using each their picker and receiving each own color to object)

Colorpicker code:
	import flash.display.Sprite;
	import flash.display.BitmapData;
	import flash.geom.ColorTransform;
	import flash.events.MouseEvent;

	public class Main extends Sprite
		var bitmapData:BitmapData = new BitmapData(300,300);
		var colorTransform:ColorTransform = new ColorTransform();
		var hexColor:*;

		public function Main():void
			colorPicker.spectrum.addEventListener(MouseEvent.MOUSE_MOVE, updateColorPicker);
			colorPicker.spectrum.addEventListener(MouseEvent.MOUSE_UP, setValue);

		private function updateColorPicker(e:MouseEvent):void
			hexColor = "0x" + bitmapData.getPixel(colorPicker.spectrum.mouseX,colorPicker.spectrum.mouseY).toString(16);
			colorTransform.color = hexColor;

			colorPicker.color.transform.colorTransform = colorTransform;
			colorPicker.colorHex.text = "#" + bitmapData.getPixel(colorPicker.spectrum.mouseX,colorPicker.spectrum.mouseY).toString(16).toUpperCase();

		private function setValue(e:MouseEvent):void
			txt.textColor = hexColor;
			colorPicker.selectedColor.transform.colorTransform = colorTransform;
			colorPicker.sColor.text = colorPicker.colorHex.text;
			colorPicker.selectedColor.alpha = 100;

The colorpicker works and outputs as it should. The issue is basically around mounting the hexcode string through a button to change the background of the remote object using the red5 .fla.

import mx.utils.Delegate;

var nc:NetConnection = new NetConnection();



var so:SharedObject = SharedObject.getRemote("simpleChatDemo", nc.uri, false); 

so.onSync = Delegate.create(this, newMessageHandler);


//need to do a hexcode import to the messagehandler, to change the color of an object

send.addEventListener("click", Delegate.create(this, sendColor));


function sendColor():Void
	so.data.ColorMessage = message.text;
	message.text = "";

Maybe this should really be posted in the newbie section
could any of you show me in the right direction?

Best regards
stilledansker is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

All times are GMT. The time now is 08:15 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.