-
Problem with flash movieclips as buttons
go a problem with targeting a form button within a movieclip
have on frame 1 _root.
==============
_root.contactForm.mcSubmit.onRollOver = function()
{
_root.contactForm.mcSubmit.gotoAndPlay("RollOver") ;
}
_root.contactForm.mcSubmit.onRollOut = function()
{
_root.contactForm.mcSubmit.gotoAndPlay("RollOut");
}
_root.contactForm.mcSubmit.onRelease = function()
{
checkForm();
}
====== button initially works fine ====
however as part form validation have a go to error frame within the movieclip
still on frame 1 _root (command to send frame within mc contactForm)
_root.contactForm.gotoAndStop("fail");
=====================
On the contactForm timeline I Have a return button to go back to form section (on contactForm timeline)
on (release) {
gotoAndStop("form");
}
This returns me back to my form however the submit button as if its lost its targetting --- any help with this would be appreciated
-
The Flashman
That's because (i would like to think) when the contactform changed frames, the submit button was "left behind" in the previos frame and thus "unloaded" from memory; erasing all scripts attached to it. So when you returned to the form, and the submit button is loaded... no scripts. what you gotta do is assign the onRollOvers and onReleases again.
i eat actionscripts for breakfast
-
thanks for help on this
what i can't understand is that _root consists as single frame so the action should be applied to the movieclip all the time
Here the full code (frame1 - root time line)
=================
stop();
var gatherForm:LoadVars = new LoadVars();
function sendForm() {
gatherForm.email_to = "simon@proctors.co.uk";
gatherForm.userList = _root.contactForm.userList.getValue();
gatherForm.vistorName = _root.contactForm.userName.text;
gatherForm.visitorTel = _root.contactForm.userTel.text;
gatherForm.vistorEmail = _root.contactForm.userEmail.text;
gatherForm.vistorComments = _root.contactForm.userComments.text;
gather.send("form.aspx","_blank", "POST");
}// function end
function checkForm() {
varuserList = _root.contactForm.userList.getValue(); // getValue for Combo List
varvistorName = _root.contactForm.userName.text;
varvisitorTel = _root.contactForm.userTel.text;
varEmail = _root.contactForm.userEmail.text;
gatherForm.vistorComments = _root.contactForm.userComments.text;
// check what the default values are =============
trace(varuserList);
trace(_root.contactForm.userName.text);
trace(_root.contactForm.userTel.text);
trace(_root.contactForm.userEmail.text);
trace(_root.contactForm.userComments.text);
if (varuserList !=0 && varvistorName !="" && varEmail !="" ) {
// success
trace("success");
sendForm();
_root.contactForm.gotoAndStop("success");
}
else
_root.contactForm.gotoAndStop("fail");
{
// fail
trace("fail");
}// if end
}// function end
_root.contactForm.mcSubmit.onRollOver = function()
{
_root.contactForm.mcSubmit.gotoAndPlay("RollOver") ;
}
_root.contactForm.mcSubmit.onRollOut = function()
{
_root.contactForm.mcSubmit.gotoAndPlay("RollOut");
}
_root.contactForm.mcSubmit.onRelease = function()
{
checkForm();
}
movieclip timeline ==========================
movieclip has three labels
success
error
form
====================
on error section sent the movieclip to the form section
=================
Should i APPLY MY CODE AS onclipevent(enterframe) so it applies to the clip all the time
-
The Flashman
frame scripts are only executed once; when the playhead enters the frame. Since you only have 1 frame (in the main timeline), the script is executed... and that's it. When you move from frame to frame within the form... the main timeline still remains at frame 1. So after the submit button reloads after going back to the contact frame, the codes are not "re-assigned" because, the main movie never left (or re-entered) frame 1.
you could put the script that assigns button actions in a function:
Code:
function putButtonCodes() {
_root.contactForm.mcSubmit.onRollOver = function() {
_root.contactForm.mcSubmit.gotoAndPlay("RollOver");
}
_root.contactForm.mcSubmit.onRollOut = function() {
_root.contactForm.mcSubmit.gotoAndPlay("RollOut");
}
_root.contactForm.mcSubmit.onRelease = function() {
checkForm();
}
}
Inside the contactForm movieclip, on frame 1, put the code:
Code:
_parent.putButtonCodes();
i eat actionscripts for breakfast
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|