button_mc.stop();
button_mc.dir = 1;
button_mc.animate = function()
{
this.gotoAndStop(this._currentframe + this.dir);
if (this._currentframe == 1 || this._currentframe == this._totalframes)
{
delete this.onEnterFrame;
}
}
button_mc.onRollOver = function()
{
this.dir = 1;
this.onEnterFrame = this.animate;
}
button_mc.onRollOut = function()
{
this.dir = -1;
this.onEnterFrame = this.animate;
}
Okay, I just wrote that off the top of my head and in the forum post text field. I can't guarantee accuracy of syntax and target references (ie: I don't know that this will work as is if you were to drop it into Flash). Anyway, what voodoo is at work here?
1) Give the timeline a direction property.
MovieClips are dynamic class objects, meaning that they accept having custom properties assigned to them. So, we added a "dir=1" that will tell the timeline which way to move (1 = forward, -1 = backward).
2) Write an animation function.
You'll notice that we're keeping this timeline permanently stopped. That's by design. We'll manually increment the current frame by running this script on it. So, this script is making the timeline go to it's current frame plus whatever direction that the timeline is set to play (1 / -1). Then, we have a crucial optimizing point... we're checking to see if the timeline has reached either the beginning or the end. If so, we're disabling the onEnterFrame handler that will be calling this script. onEnterFrame handlers gobbl up system resource. They're fine to use when you need something to update based on frame count, but you always want to get rid of them when you no longer need them.
3) Add rollover and rollout scripts
These are really simple. All they're doing is specifying the timeline's direction, then telling the clip to call it's animate function on every enterframe. And remember, the animate function is set up to automatically disable that enterFrame when it is no longer needed.
Hope that illustrates the concept. I leave it to you to expand that logic to your specific scenario.
var com:LoadVars = new LoadVars();
com.email = email_txt.text;
com.subject = subject_txt.text;
com.message = message_txt.text;
com.onLoad = function()
{
feedback_txt.text = "Your message was sent successfully!";
}
com.sendAndLoad("url/of/email.php");
I take it I put it in the parent frame of the contact form movie? Also, how do I make it send when I press the send button (send_btn)?button_mc.onRollOver = function()
{
this.dir = 1;
this.onEnterFrame = this.animate;
}
button_mc.onRollOut = function()
{
this.dir = -1;
this.onEnterFrame = this.animate;
}
to
txt_dwn.onRollOver = function()
{
this.dir = 1;
this.onEnterFrame = this.animate;
}
txt_up.onRollOut = function()
{
this.dir = -1;
this.onEnterFrame = this.animate;
}
Which didnt work... possibly because the buttons are within the text scrolling movie clip (txt_mc) and so its absorbing any commands, and none are getting through to the buttons?stop();
dir = 1;
animate = function()
{
gotoAndStop(_currentframe + dir);
if (_currentframe == 1 || _currentframe == _totalframes)
{
delete onEnterFrame;
}
}
txt_dwn.onRollOver = function()
{
dir = 1;
onEnterFrame = animate;
}
txt_up.onRollOver = function()
{
dir = -1;
onEnterFrame = this.animate;
}
As far as I can see it, the code is controlling the current timeline, so it shouldnt need this. or txt_mc in front of it, but im obviously wrong because it isnt working! However it doesnt work WITH this. and txt_mc in it either... stop me if im babbling :p
txt_mc.dir = 1;
txt_mc.animate = function()
{
//blah, blah, blah... code.
}
Now, here's a big problem in your code example:
txt_dwn.onRollOver = function()
{
THIS.dir = 1;
THIS.onEnterFrame = THIS.animate;
}
Notice what I capitalized? The "this" reference. "this" is a script reference to whatever object the script is attached to. The above script is attached to a button... so what does "this" reference? The button. You're applying the animation properties of the text clip onto the scroll button, which means that the text clip is blissfully ignorant of any need to scroll. What would need to happed is this:
txt_dwn.onRollOver = function()
{
txt_mc.dir = 1;
txt_mc.onEnterFrame = txt_mc.animate;
}
Now the button is targeting the object in question with the information needed to access it. This a very good example of the OOP (object oriented programming) concept of "Scope". All scripts exist within the scope of an object, and must target inside and outside of the scope accordingly.
Now, to make text scroll, you're going to kick yourself when you find out how unbelievably simple it is. Go into Flash help and look up the "TextField.scroll" property. Come back with your findings and we'll discuss how to use it. It's insultingly simple.var com:LoadVars = new LoadVars();
com.email = email_txt.text;
com.subject = subject_txt.text;
com.message = message_txt.text;
When the LoadVars object, com, loads (i.e. at the same time as it sends the information to the server) it causes feedback_txt to display the message... presumably I could replace this function with one that sends the user to another page or frame?
com.onLoad = function()
{
feedback_txt.text = "Your message was sent successfully!";
}
Takes the variables and sends it to the email.php file, (which arranges the information into an email and sends it)
com.sendAndLoad("url/of/email.php");send_btn.onRelease = function()
{
//code... blah blah blah
}
to make all that happen when I press the button?
Im looking into that textfield.scroll thing now...
function sendEmailForm(): Void
{
// blah, blah, blah... code.
}
send_mc.onPress = function()
{
sendEmailForm();
}
The way you'd described would work too. However this method adds some flexibility and is a better programming approach... keep jobs of objects isolated. IE: it's the job of the whole form to submit its self. The job of the send button is just to TELL the form to submit its self. So, code it best written to reflect that.txt.text = "my paragraph of text.";
txt_dwn.onRelease = function() {
txt.scroll--;
};
But the text isn't visible... so I must be doing something wrong