I kind of gave up with the color picker component for the time being and decided to work on a more simple change; to change the line style and filter which is activated by a 'hot' movieclip.
I went back to the work done by Dan Zen, because he has an example of a static button that is changed by touching it. see the link below for a demonstration, I have not included the video here because I already posted it on an earlier entry.
http://ostrichflash.wordpress.com/video/
Through Dan Zen's work, I gained 'proof of concept', but I was fairly sure that instead of using his classes which replace usual mouse events such as mouseOver, mouseOut etc, I can use hitTest, since I no longer have a 'mouse'. My reasoning here is that since I am only starting to learn AS3 it is easier to use a function that I am already familiar with and the code is basically the same for AS2 and AS3.
As I mentioned before, I have attached the drawing api (graphics.lineTo and moveTo) to a movie clip called myDrawing.
I therefore built another movie clip called myButton and did a hitTest between the two. Since I want the hitTest to remain 'true' I did not include an 'else' statement. I then made another movie clip called redDrawing and assigned a different filter and line style to it. The function that calls the hitTest then attaches the child of redDrawing if the hitTest is true.
Also just a quick note to say that I put a round white circle on the cursor to make it easier to see where it is, it will be removed in the final application
The code follows:
myDrawing.addEventListener(Event.ENTER_FRAME, changeStroke);
function changeStroke(e:Event):void{
if (myDrawing.hitTestObject(myButton)){
trace("hit");
var redDrawing:MovieClip = new MovieClip();
redDrawing.graphics.lineStyle(30, 0xff6347, 50);
redDrawing.graphics.moveTo(myFairy.x+2, myFairy.y+2);
redDrawing.graphics.lineTo(myFairy.x, myFairy.y);
var dropShadow:DropShadowFilter = new DropShadowFilter();
dropShadow.color = 0x000000;
dropShadow.blurX = 10;
dropShadow.blurY = 10;
dropShadow.angle = 0;
dropShadow.alpha = 0.5;
dropShadow.distance = 10;
var filtersArray:Array = new Array(dropShadow);
redDrawing.filters = filtersArray;
addChild(redDrawing);
And here is the result:
As you can see the hitTest works, but there are a few problems still to resolve. Firstly it seems like the myDrawing movie clip is still there even though it is barely visible. Secondly and more frighteningly it is now clear that the movie clip that holds the api is creating a new api every time it enters a frame, so that the drawing is contained only within the movie clip. Since I need the drawing to be a continuous line this will not suffice. I am going to look back thru my previous api files and see what i can come up with. I am however happy with the strange effects that are produced with this current method, and am wondering if there is a way of increasing and decreasing the size of the blobs as the go away or get nearer to the center of the drawing environment so that they will become like 3d objects. Given that there is now a z co-ordinate available in flash it might be worth a little time experimenting....
Wednesday, 28 October 2009
Sunday, 25 October 2009
color picker
Today I have been trying to integrate a color picker into the application so that the line can change color. I am now committed to using AS3, which offers a color picker component. I managed to figure out how to include it in the application and to target the drawing api movie clip (called myDrawing) as the beneficiary of the color changes.
Here is the code:
//remember to import the class!!
cpColor.addEventListener(ColorPickerEvent.CHANGE,changeColor);
function changeColor(evt:ColorPickerEvent):void {
var newColorTransform:ColorTransform = myDrawing.transform.colorTransform;
newColorTransform.color = evt.color;
myDrawing.transform.colorTransform = newColorTransform;
}
Unfortunately it doesnt quite work because in order to activate the color picker, it has to be 'clicked' which is not possible for a cursor that is being controlled by motion detection. So although I know that in theory it will work, I need to figure out how to make it activate using a MouseOver event instead. Progress hopefully will follow soon.
Here is the code:
//remember to import the class!!
cpColor.addEventListener(ColorPickerEvent.CHANGE,changeColor);
function changeColor(evt:ColorPickerEvent):void {
var newColorTransform:ColorTransform = myDrawing.transform.colorTransform;
newColorTransform.color = evt.color;
myDrawing.transform.colorTransform = newColorTransform;
}
Unfortunately it doesnt quite work because in order to activate the color picker, it has to be 'clicked' which is not possible for a cursor that is being controlled by motion detection. So although I know that in theory it will work, I need to figure out how to make it activate using a MouseOver event instead. Progress hopefully will follow soon.
Friday, 23 October 2009
Myron Krueger
One of the earliest examples of motion detection is the work of Myron Krueger. He graduated in the sixties and remarkably was working with 'responsive environments' (his term) that responded to peoples movements without the use of any special gadgetry (no gloves or headgear). He used a computer, video camera and projector in exactly the way that artists and game designers are doing now. However what he didn't have was a programming language and so he worked on the machine level language without an operating system 'in the way', as he puts it. In 'Video Place'(1988) he is using techniques and conceptual frameworks that artists today are mirroring.
Kruegers work dates back almost forty years and is credited as the pioneering start of virtual reality. It is not surprising that responsive environments would lead to complete virtual environments, but perhaps it is the play between the so called 'real' and 'virtual', that of 'natural commuting' that has seen a renewed interest in Kruegers work. The idea that we will one day live in Virtual reality has lost some of its charm, partly as a result of the actualisation of virtuality being assimilated into our 'real' world.
Here is Kruegers description of 'Video Place':
'In the installation, the visitor faces a video-projection screen. A screen behind him is backlit in order to produce a high contrast image for the camera and allow the computer to distinguish the visitor from the background.
Interesting that he back lights the video projection,,,, I will experiment with this!! The other project I did I back projected onto a touch screen. It was alright but the image was de-saturated. I would like to find a way of front projecting where the image does not get interrupted by a person moving in front of it. Ideas anyone??
The visitor’s image is then digitized to create a silhouette and processors can then analyze its posture and movement, and its relationship to other graphic elements in the system. The processors can then react to the movement of the visitor and create a series of reactions, either visual or auditory. Two or more environments can also be linked to the system'. (Andrew Hieronymi, ND) http://classes.design.ucla.edu/Winter04/256/projects/andrew/report.html
Kruegers work dates back almost forty years and is credited as the pioneering start of virtual reality. It is not surprising that responsive environments would lead to complete virtual environments, but perhaps it is the play between the so called 'real' and 'virtual', that of 'natural commuting' that has seen a renewed interest in Kruegers work. The idea that we will one day live in Virtual reality has lost some of its charm, partly as a result of the actualisation of virtuality being assimilated into our 'real' world.
Here is Kruegers description of 'Video Place':
'In the installation, the visitor faces a video-projection screen. A screen behind him is backlit in order to produce a high contrast image for the camera and allow the computer to distinguish the visitor from the background.
Interesting that he back lights the video projection,,,, I will experiment with this!! The other project I did I back projected onto a touch screen. It was alright but the image was de-saturated. I would like to find a way of front projecting where the image does not get interrupted by a person moving in front of it. Ideas anyone??
The visitor’s image is then digitized to create a silhouette and processors can then analyze its posture and movement, and its relationship to other graphic elements in the system. The processors can then react to the movement of the visitor and create a series of reactions, either visual or auditory. Two or more environments can also be linked to the system'. (Andrew Hieronymi, ND) http://classes.design.ucla.edu/Winter04/256/projects/andrew/report.html
Subscribe to:
Posts (Atom)
