Hello,
I have a big problem and i don’t know what is wrong! This problem sounds like this:
---------------------------------A little description of the site.
I have a main movie where i have 4 movieClips (with the instance name: home_mc, club_mc, gute_mc and stuff_mc), initial they are invisible (ex: home_mc._visible = false and when i click a button the movieClip assign to that button will become visible.
I have in every movieClip some text areas(input and dynamically), datagrids and button and in action layer i have #include ".as" ( = the name of the movieClip; home has home.as, club has club.as etc)
Here are the actionscript files:
Main.as
[AS]
//Site initial property.
home_mc._visible = false;
club_mc._visible = false;
gute_mc._visible = false;
stuff_mc._visible = false;
kontakt_mc._visible = false;
news_mc._visible = false;
adver_mc._visible = false;
//Initial Animation Components
//
//Tween First View.
import mx.transitions.Tween;
import mx.transitions.easing.;
var tw:Tween = new Tween (main_headline, “_xscale”, Elastic.easeOut, 0, 100, 3, true);
var tw1:Tween = new Tween (main_headline, “_yscale”, Elastic.easeOut, 0, 100, 3, true);
//Button Texts
btn_home.button_text_mc.button_text.text = “Home”;
btn_club.button_text_mc.button_text.text = “Club”;
btn_gute.button_text_mc.button_text.text = “gute Scheiben”;
btn_stuff.button_text_mc.button_text.text = “DJ Stuff”;
btn_kontakt.button_text_mc.button_text.text = “Kontakt”;
btn_news.button_text_mc.button_text.text = “News/Specials”;
btn_adver.button_text_mc.button_text.text = “Advertising”;
//Button Actionscript
btn_home.onRelease = function () {
//Tween Home Mc
var tween_home = new Tween (home_mc, “_xscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_home1 = new Tween (home_mc, “_yscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_home2 = new Tween (home_mc, “_alpha”, Elastic, easeInOut, 0, 100, 1, true);
//
//
home_mc._visible = true;
loadMovie(home_mc);
//
club_mc._visible = false;
club_mc.unloadMovie();
gute_mc._visible = false;
gute_mc.unloadMovie()
stuff_mc._visible = false;
stuff_mc.unloadMovie()
kontakt_mc._visible = false;
kontakt_mc.unloadMovie()
news_mc._visible = false;
news_mc.unloadMovie()
adver_mc._visible = false;
adver_mc.unloadMovie()
};
btn_club.onRelease = function () {
//Tween Club Mc
var tween_club = new Tween (club_mc, “_xscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_club1 = new Tween (club_mc, “_yscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_club2 = new Tween (club_mc, “_alpha”, Elastic, easeInOut, 0, 100, 1, true);
//*
home_mc._visible = false;
home_mc.unloadMovie();
//
club_mc._visible = true;
loadMovie(club_mc);
//
home_mc._visible = false;
home_mc.unloadMovie();
stuff_mc._visible = false;
stuff_mc.unloadMovie()
kontakt_mc._visible = false;
kontakt_mc.unloadMovie()
news_mc._visible = false;
news_mc.unloadMovie()
adver_mc._visible = false;
adver_mc.unloadMovie()
};
btn_stuff.onRelease = function () {
//Tween Stuff Mc
var tween_stuff = new Tween (stuff_mc, “_xscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_stuff = new Tween (stuff_mc, “_yscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_stuff = new Tween (stuff_mc, “_alpha”, Elastic, easeInOut, 0, 100, 1, true);
//*
home_mc._visible = false;
home_mc.unloadMovie();
club_mc._visible = false;
club_mc.unloadMovie()
home_mc._visible = false;
home_mc.unloadMovie();
//
stuff_mc._visible = true;
//
kontakt_mc._visible = false;
kontakt_mc.unloadMovie()
news_mc._visible = false;
news_mc.unloadMovie()
adver_mc._visible = false;
adver_mc.unloadMovie()
};
btn_gute.onRelease = function () {
//Tween Stuff Mc
var tween_gute = new Tween (gute_mc, “_xscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_gute = new Tween (gute_mc, “_yscale”, Elastic.easeOut, 0, 100, 1, true);
var tween_gute = new Tween (gute_mc, “_alpha”, Elastic, easeInOut, 0, 100, 1, true);
//*
home_mc._visible = false;
home_mc.unloadMovie();
club_mc._visible = false;
club_mc.unloadMovie()
//
gute_mc._visible = true;
//
stuff_mc._visible = false;
stuff_mc.unloadMovie()
kontakt_mc._visible = false;
kontakt_mc.unloadMovie()
news_mc._visible = false;
news_mc.unloadMovie()
adver_mc._visible = false;
adver_mc.unloadMovie()
};
[/AS]
Home.as
[AS]
stop ();
//
save_home.button_text_mc.button_text.text = “Submit to Home”;
see_home.button_text_mc.button_text.text = “See Home site”;
//
see_home.onPress = function () {
loadText = new LoadVars ();
loadText.load (“home.txt”);
loadText.onLoad = function () {
current_home.text = this.home;
};
};
//
save_home.onRelease = function () {
getURL (“home.php”, _blank, “POST”);
};
[/AS]
Club.as
[AS]
//Show Database in the Data Grid.
club_parseXML = function () {
if (myXML.hasChildNodes) {
// we check if this xml has children just to be sure
var xmlRootNode = myXML.firstChild.childNodes;
// define the root of the xml file for easy navigation
for (var i = 0; i<xmlRootNode.length; i++) {
// now loop through the xml and fill our dataArray with objects
var thisNode = xmlRootNode*;
if (thisNode != null) {
var strid = thisNode.childNodes[0].firstChild.nodeValue;
var strpic = thisNode.childNodes[1].firstChild.nodeValue;
var strtext = thisNode.childNodes[2].firstChild.nodeValue;
var strlink = thisNode.childNodes[3].firstChild.nodeValue;
// here we go, creating an object instantly and adding it to our container
arrDataGrid.push({ID:strid, Pic:strpic, Text:strtext, Link:strlink});
}
}
}
// this is where the magic is, link the filled array to the datagrid… that’s it!
// you’ll have full control over what comes in to you grid! Great ain’t it
club_dg.dataProvider = arrDataGrid;
};
club_loadXML = function () {
arrDataGrid = new Array();
// will contain the data for the grid
myXML = new XML();
// loads the xml in memory
myXML.ignoreWhite = true;
// ignore enters and whitespace in xml file
myXML.onLoad = club_parseXML;
// reference to the function above
myXML.load(“club_db.xml”);
// the actual command which will load the xml file
};
//Finish Load Database in Data Grid.
//*
//Initial propertys.
club_dg._visible = false;
refresh_club._visible = false
//*
//Ckeck Box’es.
// create event listener object for checkbox
clubbox = new Object();
// click event handler
clubbox.click = function() {
if (club_db.selected) {
club_dg._visible = true;
refresh_club._visible = true;
club_loadXML();
} else {
club_dg._visible = false;
refresh_club._visible = false;
}
};
// register the event listener
club_db.addEventListener(“click”, clubbox);
refresh_club.onPress = function () {
club_loadXML();
}
//Finish Show Database AS.
//*
//Remove ID MC
remove_id_head._visible = false;
remove_id_head2._visible = false;
remove_id_input._visible = false;
remove_club._visible = false;
//
// Check Box
remove_club_ac = new Object();
// click event handler
remove_club_ac.click = function() {
if (remove_club_mc.selected) {
remove_id_head._visible = true;
remove_id_head2._visible = true;
remove_id_input._visible = true;
remove_club._visible = true;
} else {
remove_id_head._visible = false;
remove_id_head2._visible = false;
remove_id_input._visible = false;
remove_club._visible = false;
}
};
// register the event listener
remove_club_mc.addEventListener(“click”, remove_club_ac);
///*
//Alert
import mx.controls.Alert;
// Define action after alert confirmation.
var alertHandler:Function = function (evt_obj:Object) {
if (evt_obj.detail == Alert.YES)
{
getURL (“delete_club.php”, _blank, “POST”);
}
};
// Show alert dialog box.
remove_club.onPress = function () {
var club_alert:Alert = Alert.show ("Do you want to remove ID: " + remove_id_input.text + “?”, “Validation Alert!”, Alert.YES | Alert.NO, this, alertHandler, Alert.YES);
club_alert._x = 384.4;
club_alert._y = 334.5;
};
[/AS]
Gute.as
[AS]
//Show Database in the Data Grid.
gute_parseXML = function () {
if (myXML.hasChildNodes) {
// we check if this xml has children just to be sure
var xmlRootNode = myXML.firstChild.childNodes;
// define the root of the xml file for easy navigation
for (var i = 0; i<xmlRootNode.length; i++) {
// now loop through the xml and fill our dataArray with objects
var thisNode = xmlRootNode*;
if (thisNode != null) {
var strid = thisNode.childNodes[0].firstChild.nodeValue;
var strpic = thisNode.childNodes[1].firstChild.nodeValue;
var strtext = thisNode.childNodes[2].firstChild.nodeValue;
var strlink = thisNode.childNodes[3].firstChild.nodeValue;
// here we go, creating an object instantly and adding it to our container
arrDataGrid.push({ID:strid, Pic:strpic, Text:strtext, Link:strlink});
}
}
}
// this is where the magic is, link the filled array to the datagrid… that’s it!
// you’ll have full control over what comes in to you grid! Great ain’t it
gute_dg.dataProvider = arrDataGrid;
};
gute_loadXML = function () {
arrDataGrid = new Array();
// will contain the data for the grid
myXML = new XML();
// loads the xml in memory
myXML.ignoreWhite = true;
// ignore enters and whitespace in xml file
myXML.onLoad = gute_parseXML;
// reference to the function above
myXML.load(“gute_db.xml”);
// the actual command which will load the xml file
};
//Finish Load Database in Data Grid.
//*
//Initial propertys.
gute_dg._visible = false;
refresh_gute._visible = false
//*
//Ckeck Box’es.
// create event listener object for checkbox
gutebox = new Object();
// click event handler
gutebox.click = function() {
if (gute_db.selected) {
gute_dg._visible = true;
refresh_gute._visible = true;
gute_loadXML();
} else {
gute_dg._visible = false;
refresh_gute._visible = false;
}
};
// register the event listener
gute_db.addEventListener(“click”, gutebox);
refresh_gute.onPress = function () {
gute_loadXML();
}
//Finish Show Database AS.
//*
//Remove ID MC
remove_id_head._visible = false;
remove_id_head2._visible = false;
remove_id_input._visible = false;
remove_gute._visible = false;
//
// Check Box
remove_gute_ac = new Object();
// click event handler
remove_gute_ac.click = function() {
if (remove_gute_mc.selected) {
remove_id_head._visible = true;
remove_id_head2._visible = true;
remove_id_input._visible = true;
remove_gute._visible = true;
} else {
remove_id_head._visible = false;
remove_id_head2._visible = false;
remove_id_input._visible = false;
remove_gute._visible = false;
}
};
// register the event listener
remove_gute_mc.addEventListener(“click”, remove_gute_ac);
///*
//Alert
import mx.controls.Alert;
// Define action after alert confirmation.
var alertHandler:Function = function (evt_obj:Object) {
if (evt_obj.detail == Alert.YES)
{
getURL (“delete_gute.php”, _blank, “POST”);
}
};
// Show alert dialog box.
remove_gute.onPress = function () {
var gute_alert:Alert = Alert.show ("Do you want to remove ID: " + remove_id_input.text + “?”, “Validation Alert!”, Alert.YES | Alert.NO, this, alertHandler, Alert.YES);
gute_alert._x = 384.4;
gute_alert._y = 334.5;
};
[/AS]
Stuff.as is the same like Club and Gute, only that instead of club or gute i stuff.
Here is the PHP code for the home, and club(the gute and stuff are the same, instead of club i have gute and stuff, and the link of the text input area and variable are ok)
Home.php
<?PHP
$text = $_POST['input_home_text'];
$fol = fopen ("home.txt",w);
$sentOk = fwrite ($fol,"home=".$text);
?>
Club.php (submit_club.php)
<?php
//CLUB PHP SCRIPT//
//Variabile Flash.
$locatie = $_POST['town'];
$nume = $_POST['name'];
$url = $_POST['link'];
$id = $_POST['id_update'];
//Variabile Locale.
$username = "root";
$password = "";
$database = "electrotown";
//Connectare la Database.
$connect = mysql_connect("localhost",$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);
//Updatare Database.
$update = "UPDATE club SET oras = '$locatie', nume = '$nume', link ='$url' WHERE id = '$id'" or die(mysql_error());
mysql_query($update);
//Scriere XML.
$query = mysql_query("SELECT * FROM club ORDER BY id ASC");
$xml = "<data>
";
while ( $i = mysql_fetch_array($query)) {
$xml = $xml . " <row>
";
$xml = $xml . " <id>";
$xml = $xml . $i['id'];
$xml = $xml . "</id>
";
$xml = $xml . " <oras>";
$xml = $xml .$i['oras'];
$xml = $xml . "</oras>
";
$xml = $xml . " <nume>";
$xml = $xml .$i['nume'];
$xml = $xml . "</nume>
";
$xml = $xml . " <link>";
$xml = $xml .$i['link'];
$xml = $xml . "</link>
";
$xml = $xml . " </row>
";
}
$xml = $xml . "</data>";
$fol = fopen("club_db.xml",w);
$fold = fwrite($fol,$xml);
//Scriere mesaj.
echo "<center><font size = 3>Datele au fost updatate cu succes in:<b> ".$database."</b>.</font></center><br>";
echo "<center>Datele: <b>".$locatie." </b>, <b>".$nume."</b> , <b>".$url."</b> au fost updatate in database-ul: <b>".$database."</b>.</center>";
//Inchidere XML si Database.
fclose ($fol);
mysql_close($connect);
?>
<script language="javascript">
window.close();
</script>
Club.php (update_club.php)
<?php
//CLUB PHP SCRIPT//
//Variabile Flash.
$locatie = $_POST['town'];
$nume = $_POST['name'];
$url = $_POST['link'];
$id = $_POST['id_update'];
//Variabile Locale.
$username = "root";
$password = "";
$database = "electrotown";
//Connectare la Database.
$connect = mysql_connect("localhost",$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);
//Updatare Database.
$update = "UPDATE club SET oras = '$locatie', nume = '$nume', link ='$url' WHERE id = '$id'" or die(mysql_error());
mysql_query($update);
//Scriere XML.
$query = mysql_query("SELECT * FROM club ORDER BY id ASC");
$xml = "<data>
";
while ( $i = mysql_fetch_array($query)) {
$xml = $xml . " <row>
";
$xml = $xml . " <id>";
$xml = $xml . $i['id'];
$xml = $xml . "</id>
";
$xml = $xml . " <oras>";
$xml = $xml .$i['oras'];
$xml = $xml . "</oras>
";
$xml = $xml . " <nume>";
$xml = $xml .$i['nume'];
$xml = $xml . "</nume>
";
$xml = $xml . " <link>";
$xml = $xml .$i['link'];
$xml = $xml . "</link>
";
$xml = $xml . " </row>
";
}
$xml = $xml . "</data>";
$fol = fopen("club_db.xml",w);
$fold = fwrite($fol,$xml);
//Scriere mesaj.
echo "<center><font size = 3>Datele au fost updatate cu succes in:<b> ".$database."</b>.</font></center><br>";
echo "<center>Datele: <b>".$locatie." </b>, <b>".$nume."</b> , <b>".$url."</b> au fost updatate in database-ul: <b>".$database."</b>.</center>";
//Inchidere XML si Database.
fclose ($fol);
mysql_close($connect);
?>
<script language="javascript">
window.close();
</script>
Club.php (delete_club.php)
<?php
//CLUB PHP SCRIPT//
//Variabile Flash.
$id = $_POST['id_remove'];
//Variabile Locale.
$username = "root";
$password = "";
$database = "electrotown";
//Connectare la Database.
$connect = mysql_connect("localhost",$username,$password) or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db($database);
//Stergere ID din Database.
//"DELETE FROM gute WHERE id = '$id'" or die(mysql_error());
$delete = "DELETE FROM club WHERE id = '$id'" or die(mysql_error());
mysql_query($delete);
//Scriere XML.
$query = mysql_query("SELECT * FROM club ORDER BY id ASC");
$xml = "<data>
";
while ( $i = mysql_fetch_array($query)) {
$xml = $xml . " <row>
";
$xml = $xml . " <id>";
$xml = $xml . $i['id'];
$xml = $xml . "</id>
";
$xml = $xml . " <oras>";
$xml = $xml .$i['oras'];
$xml = $xml . "</oras>
";
$xml = $xml . " <nume>";
$xml = $xml .$i['nume'];
$xml = $xml . "</nume>
";
$xml = $xml . " <link>";
$xml = $xml .$i['link'];
$xml = $xml . "</link>
";
$xml = $xml . " </row>
";
}
$xml = $xml . "</data>";
$fol = fopen("club_db.xml",w);
$fold = fwrite($fol,$xml);
//Scriere mesaj.
echo "<center><font size = 3>ID-ul:<b> ".$id."</b> a fost sters din Database.</font></center><br>";
//Inchidere XML si Database.
fclose ($fol);
mysql_close($connect);
?>
<script language="javascript">
window.close();
</script>
When access a page (club_mc for exemple) and i write something everything goes ok, BUT when i access the second page (gute_mc) and i write something and i click SUBMIT the PHP is opened in a new window (this is ok) but nothing is writen down in the database, then the site is crashed!!!
Can you help me, you can see the exemple here:
http://www.electrotown.de/test
Thank you in advanced, Tiberiu!