custom check box

  • dferraro40
  • Beginner
  • Beginner
  • dferraro40
  • Posts: 52
  • Loc: Massachusetts

Post 3+ Months Ago

I built a custom check box consisting of two frames. Frame 1 is unchecked frame 2 is checked. What i want to happen is when the check box is clicked and thus selected i want it to store the word "sometext" in a variable called "text", then send it with the rest of my info. the check box i have is in a MC called InfoForm_mc. The form already has input boxes and all the information is sent to a PHP file and works fine. Also if there is a better way to do this i am open for suggestions.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

2 frames is ok.
so u create another layer inside your checkbox, name it AS, and
in the first frame u do:
Code: [ Select ]
isChecked = false;
this.onPress = function()
{
    isChecked = !isChecked;
    if (isChecked)
    {
        text = "sometext";
        gotoAndStop(2);
    }
    else
       gotoAndStop(1);
}
  1. isChecked = false;
  2. this.onPress = function()
  3. {
  4.     isChecked = !isChecked;
  5.     if (isChecked)
  6.     {
  7.         text = "sometext";
  8.         gotoAndStop(2);
  9.     }
  10.     else
  11.        gotoAndStop(1);
  12. }

then, when u need to send the info to the php file, just get the InfoForm_mc.text variable and store it in your loadVars object ... or whatever u use to send.
  • dferraro40
  • Beginner
  • Beginner
  • dferraro40
  • Posts: 52
  • Loc: Massachusetts

Post 3+ Months Ago

I did that but it does not sent the varible with the rest of the varibles in the form. If i put a Dyn text box with the varible name "text" in the second frame of the check box then the word "sometext" apears in it after i check the box. But if i go to the form and put in a dyn text box named "text" in the confermation frame(frame 2 of the form) then the text "sometext" does not show up.


The checkbox_mc is inside the form. Not sure how to send the varible "text" to the form so that it gets sent with the rest of the information in the form.
  • dferraro40
  • Beginner
  • Beginner
  • dferraro40
  • Posts: 52
  • Loc: Massachusetts

Post 3+ Months Ago

any ideas?
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

it`s about the relative path to your variable.
anyway, dont name your variables or mc-s as "text" since it is a reserved word, used for the dynamic text, and might create confusion to the coder.
i.e.: text.text = "something", where first text is the name of the dyn text and the second one is the text from the dyn text.
  • dferraro40
  • Beginner
  • Beginner
  • dferraro40
  • Posts: 52
  • Loc: Massachusetts

Post 3+ Months Ago

I think the issue is that i am using LoadVarNum. I made a post about this issue and found a workaround at the time [url]http://www.ozzu.com/flash-forum/flah-mailform-php-t62226.html[url] but the more and more i am using flash the more i need to figure this out. I read that LoadVarNum("mailform.php",0,"POST") will only send the vars on that timeline. When i read that it all made sense. I have been battling with this issue for months now.

I also noticed that when i put a Form_MC in the root timeline and inside that form_MC the submit button has LoadVarNum("mailform.php",0,"POST") it sends the information but any information that is coming back from the PHP file does not get sent. I have a status = "thank you" in the mailform.php, and a dyn text box called status in the form_MC, the vars get sent but the "thank you" never gets sent back to the form_MC.

I am real confused about LoadVarNum and LoadVars, and the correct way to use them. I know that this is a very simple procedure but i cannot figure it out. I have been ripping my hair out for months and have been using work arounds.

this is an example of what i am doing:
this is the code from the submit button that is inside the form_MC



Code: [ Select ]
on (release, keyPress "<Enter>") {
    if (user != "" && pass != "") {
        
        status = "Begin Login Process - Wait...";
        loadVariablesNum("newlogin.php", 0, "POST");
    }
}
  1. on (release, keyPress "<Enter>") {
  2.     if (user != "" && pass != "") {
  3.         
  4.         status = "Begin Login Process - Wait...";
  5.         loadVariablesNum("newlogin.php", 0, "POST");
  6.     }
  7. }

this is my PHP file

PHP Code: [ Select ]
 
<?
 
 
 
$user=$_POST['user'];
 
$pass=$_POST['pass']; $pass = sha1($pass);
 
 
 
 
 
 
 
// Database Connectivity
 
   $DBhost = "localhost";   // Database Server
 
   $DBuser = "user";            // Database User
 
   $DBpass = "pass";            // Database Pass
 
   $DBName = "database";            // Database Name
 
   $table = "table";             // Database Table
 
 
 
   
 
   // Connect to mySQL Server
 
   $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error : " . mysql_error());
 
   // Select mySQL Database
 
   mysql_select_db($DBName, $DBConn) or die("Error in Application: " . mysql_error());
 
 
 
//make query
 
$query = "SELECT * FROM $table WHERE username = '$user' AND userpassword = '$pass'";
 
$result = mysql_query( $query ) or die ("didn't query");
 
 
 
//see if there's an EXACT match
 
$num = mysql_num_rows( $result );
 
if ($num == 1){
 
   print "status=You're in&checklog=1";
 
   } else {
 
   print "status=Sorry, but your user name and password did not match a user name/password combination in our database.   Please Try Again&checklog=2";
 
}
 
?>
 
 
  1.  
  2. <?
  3.  
  4.  
  5.  
  6. $user=$_POST['user'];
  7.  
  8. $pass=$_POST['pass']; $pass = sha1($pass);
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16. // Database Connectivity
  17.  
  18.    $DBhost = "localhost";   // Database Server
  19.  
  20.    $DBuser = "user";            // Database User
  21.  
  22.    $DBpass = "pass";            // Database Pass
  23.  
  24.    $DBName = "database";            // Database Name
  25.  
  26.    $table = "table";             // Database Table
  27.  
  28.  
  29.  
  30.    
  31.  
  32.    // Connect to mySQL Server
  33.  
  34.    $DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error : " . mysql_error());
  35.  
  36.    // Select mySQL Database
  37.  
  38.    mysql_select_db($DBName, $DBConn) or die("Error in Application: " . mysql_error());
  39.  
  40.  
  41.  
  42. //make query
  43.  
  44. $query = "SELECT * FROM $table WHERE username = '$user' AND userpassword = '$pass'";
  45.  
  46. $result = mysql_query( $query ) or die ("didn't query");
  47.  
  48.  
  49.  
  50. //see if there's an EXACT match
  51.  
  52. $num = mysql_num_rows( $result );
  53.  
  54. if ($num == 1){
  55.  
  56.    print "status=You're in&checklog=1";
  57.  
  58.    } else {
  59.  
  60.    print "status=Sorry, but your user name and password did not match a user name/password combination in our database.   Please Try Again&checklog=2";
  61.  
  62. }
  63.  
  64. ?>
  65.  
  66.  


Everything works ok but the status in the flash file dosent get updated. If i do the same think but have everything on the main timeline(not in a MC) then everything works fine. How can i re write the flash script to work with the MC. I apologize if this is repetitive but i haven't got a clear cut explanation on haw to make it work the way it should.
  • IceCold
  • Guru
  • Guru
  • User avatar
  • Posts: 1254
  • Loc: Ro

Post 3+ Months Ago

oh man, there should be a sticky post about LoadVars, i answered to so many posts about LoadVars that now i dream only LoadVars flying and changing it`s color :D :
load vars example
and i always say: start from simple to complex, from easy to hard ... not the other way around.
To understand the principle, try to reproduce the example that i gave there, add then more things, see how it works, and after the principle is well understood you cand do what you want with it.

Post Information

  • Total Posts in this topic: 7 posts
  • Users browsing this forum: No registered users and 8 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.