I'd like to create a MC that flips when a button is rolled over.
e.g. a square with a solid color on one side and another color on the other (or images etc). When the mouse is over the button, the MC will flip once from one side to the other.
If possible would like it to do a return flip on Mouse out.
Can anyone help with this or know a good tutorial?
Hand animate the flipping animation, and apply a script that will play your animation when rolled over and rewind when rolled off. See attachment for sample.
tnx pporksoda, problem is, I'm trying to figure out how to build a 'flip' effect...got the following code from another post, but it coninuously flips the movieclip. I'm sure there is a simple way to get the effect I'm talking about.
here's the fairly complex code I've got so far (continuously flips). I'm looking for a flip on, flip off effect.
.................
PHP Code:
Create a two frame MC,Place some graphic in frame one.... same graphic in frame two.... different color. Stop action on the first frame and frame label "front" ..... frame label "back" on frame two.
Then on the clip paste this code.....
ActionScript:
PRE {font : normal normal normal 13 "Courier New", Courier, Arial;;}
onClipEvent (load) {
rpm = 18; // number of full cycles per minute (a full cycle travels the range twice)
}
k, almost done....... Paste this into the first frame of the main timeline......
ActionScript:
PRE {font : normal normal normal 13 "Courier New", Courier, Arial;;}
// ### set range, speed and starting direction of oscillation
var minValue = -100;
var maxValue = 100;
var degree = 0;
// start angle, relative to the positive x-axis.
// degree of 0 starts at maxValue and descends
// degree of 180 starts at minValue and ascends
// ### define system globals
var delta = (maxValue-minValue)/2;
// radius of a cycle
var midPoint = minValue+delta;
// midPoint of oscillation range
var lastTimer = getTimer();
// time stamp used to measure how much to move
// ### oscillateUsingCos moves between two values using a cosine-wave pattern
function oscillateUsingCos(rpm) {
// measure how much time has passed, and set the appropriate
// amount to move
var now = getTimer();
var elapsed = (now-lastTimer)/1000;
var degIncrement = (360*rpm)*(elapsed/60);
// remember the current time for the next move
lastTimer = now;
// increment the degree
degree += degIncrement;
// keep the degree looping between -360 and 360
if (degree>360) {
degree -= 360;
} else if (degree<0) {
degree += 360;
}
// determine the new value
var degreeRad = radian(degree);
currentValue = midPoint+Math.cos(degreeRad)*delta;
}
// ### set the vertical or horizontal size of the clip
// this function is called from a clip's enterframe event,
// and relies on values set in the clip via onload
function spin(clip, axis) {
if (axis == "horizontal") {
clip._xscale = currentValue;
} else {
clip._yscale = currentValue;
}
if (currentValue<0) {
clip.gotoAndStop("back");
} else if (currentValue>0) {
clip.gotoAndStop("front");
}
}
// ### degree to radian converter (used by oscillateUsingCos)
function radian(degree) {
return (Math.PI/180)*degree;
tnx sergwiz.
nice work!
Interesting way to control the button.
Do you know how I could flip it from the diagonal?
tried adding the code for the _Yscale, strange effect.
anyway
Thanks for your help with this, very much appreciated!
G
ps can u recommend a good practical book on code?
Do you know how I could flip it from the diagonal?
Do you mean like this (take a look)?
It's shame on me, but I didn't read any book on ActionScript, I just have no opportunity.
There are lots of excellent sources in the net like flashkit.com, actionscript.org, flasher.ru and many-many other sites where I can learn something new and useful.
And I think that the best way for learning is - not to ask questions but to try answering questions by myself.
Most of the flash I've learned has been through online tutes ... time to get into a'scripting -- I'm going to get a book for reference, your rite about working out things for yourself -- good to have a helping hand here and there.
what goes around and all that!
tnx again, your help is v much appreciated.
G