FORUMS: list search recent posts

How to make a button??

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
John Willow
How to make a button??
on Aug 8, 2014 at 5:30:18 am

Can you make a wheel knob that you can turn that will control lighting?? turn down for darker turn up for lighter


Return to posts index


Sam Mattern
Re: How to make a button??
on Aug 8, 2014 at 1:32:12 pm

I take it that you mean make a flash representation of a light dimmer.

The complexity lies in the user interaction and making it look AND feel real. If you want the user to press and rotate it to the left or right, you're going to have to write something decently complex.

Is that what you're trying to accomplish?

-Sam


Return to posts index

John Willow
Re: How to make a button??
on Aug 9, 2014 at 12:43:35 am

Yes, that is exactly what I'm after. Can it be done??

Thanks!!


Return to posts index


Sam Mattern
Re: How to make a button??
on Aug 11, 2014 at 6:30:52 pm

It can be done, but it won't be easy. Making a vertical slider would be easier than a round one, since you could effectively start with a volume slider and modify it to "work the lights."

The complexity lies in the user interaction and making it look AND feel real. If you want the user to press and rotate it to the left or right, you're going to have to write something decently complex.

Maybe this could work for a round dimmer:

var dimmerPos:Number = 0; //this is dimmer position 0 meaning off.
var mousePosX:Number = 0; //this is the mouse X coordinate

dimmer_mc.addEventListener(MouseEvent.MOUSE_DOWN,dimmerPush); //listens for the dimmer to be pushed
dimmer_mc.addEventListener(MouseEvent.MOUSE_UP,dimmerRelease); //listens for the dimmer to be released
stage.addEventListener(MouseEvent.UP, onMouseReleaseOutside); //in case mouse is released outside of dimmer

function dimmerPush(E:MouseEvent){
//Start tracking mouse movement
stage.addEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
}
function dimmerRelease(E:MouseEvent){
//Stop tracking mouse movement
stage.RemoveEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
}
function onMouseReleaseOutside(E:MouseEvent){
//Stop tracking mouse movement if mouse is released outside of the dimmer.
stage.RemoveEventListener(MouseEvent.MOUSE_MOVE, mousePosition);
}
function mousePosition(E:MouseEvent){
changeLights(dimmer_mc.MouseX); //this sends the horizontal movement of the mouse in relation to the dimmer
}
function changeLights(lightVal:Number){
if(lightVal < 0){
trace("getting dimmer");
}else{
trace("getting brighter");
}
}


Create your round dimmer as a movieclip and give it an instance name of dimmer_mc. Put this code on stage on the same frame as the movieclip. Then test the movie and make sure that when you click on the dimmer and hold the mouse down, and move the mouse right and left, that you get an output saying getting brighter when you move right, getting dimmer when you move left. If not, let's figure out why before we go further.

We'll still need to figure out how "bright" and dark to let it get, and how to animate the dimmer switch so it looks realistic.

-Sam


Return to posts index

John Willow
Re: How to make a button??
on Aug 12, 2014 at 4:59:00 am

Thanks alot for your help! Ill give it a try.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]