View Full Version : 2 swfs in 1 html page = 1 bug
mmm84
04-21-2008, 05:30 PM
On the same html page, I have two swfs:
- one is my homepage;
- one is a newsletter module, allowing visitors to join my newsletter.
I'm having a problem with the newsletter swf. When I try it in its own separated html page, it all works fine and I can register/delete my name without any bug.
However, when it is inserted in the html homepage, it does not go through completely. To me, it seems it cannot reach the php script, but I'm not sure.
This newsletter swf is located in its own folder... Could that be the problem?
You guys have any idea about whatever I might be missing here?
THANK YOU!!!
mmm84
04-21-2008, 07:33 PM
I thought I'd try and slip in a lil more info about the html page...
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html><head><title></title>
<style type="text/css">
html, body {
background-color: #000000;
height: 100%;
padding: 0;
margin: 0;
}
table {
text-align: center;
height: 100%;
width: 100%;
border: 0;
}
</style>
<script language="javascript">AC_FL_RunContent = 0;</script><script src="AC_RunActiveContent.js" language="javascript"></script>
</head>
<body>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="185" height="150" id="main" align="right">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="http://www.mysite.com/newsletter/main.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#000000" />
<embed src="htp://www.mysite.com/newsletter/main.swf" align="right" quality="high" bgcolor="#000000" width="185" height="150" name="main" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
<table>
<tr>
<td>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase=http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0
width="1024" height="768" id="Accueil" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="Accueil.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<PARAM NAME="WMODE" VALUE="transparent">
<embed src="Accueil.swf" quality="high" WMODE="transparent" bgcolor="#000000" width="85%" height="85%" name="Accueil" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td>
</tr>
</table>
</body>
</html>
And here's how my newsletter folder is organized:
main.swf (newsletter module)
Main.as (as file for main.swf)
newsletter.php
EmailChecker.as
confirm.php
include folder (config.php, function.php)
And because at this point, I'm clueless... Here's the code from Main.as :
package
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.utils.Timer;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.events.IEventDispatcher;
import flash.net.URLLoader;
import flash.net.URLVariables;
import flash.net.URLRequest;
import flash.net.URLRequestMethod;
import flash.net.URLLoaderDataFormat;
import flash.events.SecurityErrorEvent;
import flash.events.IOErrorEvent;
public class Main extends MovieClip
{
private var angle:Number=Math.PI/2;
private var timer:Timer;
private var loader:URLLoader;
private const url:String='http://www.mysite.com/newsletter/newsletter.php';
private var _Name:String;
private var _EMail:String;
private var action:String;
public function Main()
{
init();
}
public function init():void
{
stage.frameRate=31;
letter_mc.alpha=.7;
letter_mc.addEventListener(Event.ENTER_FRAME,turnL etter);
email_mc.field_txt.background=name_mc.field_txt.ba ckground=false;
email_mc.field_txt.backgroundColor=name_mc.field_t xt.backgroundColor=0x999999;
email_mc.field_txt.border=name_mc.field_txt.border =true;
email_mc.field_txt.borderColor=name_mc.field_txt.b orderColor=0x333;
join_btn.label='JOIN';
join_btn.addEventListener(MouseEvent.MOUSE_DOWN,go );
delete_btn.label='DELETE';
delete_btn.addEventListener(MouseEvent.MOUSE_DOWN, go);
}
private function go(evt:MouseEvent):void
{
_EMail=email_mc.field_txt.text;
_Name=name_mc.field_txt.text;
if(EmailChecker.checkEMail(_EMail))
{
if(_Name!="")
{
if(_Name.length>=4)
{
switch(evt.target.name)
{
case 'join_btn':
action='registra';
cool(action);
break;
case 'delete_btn':
action='elimina';
cool(action);
break;
}
}
else
{
notCool('name too short');
}
}
else
{
notCool('insert a name');
}
}
else
{
notCool('invalid e-mail address');
}
}
private function turnLetter(evt:Event):void
{
var sine:Number=Math.sin(angle);
var cosine:Number=Math.cos(angle);
evt.target.scaleX=sine;
angle+=.1;
}
private function notCool(s:String):void
{
letter_mc.alpha=.2;
error_txt.text=s;
timer=new Timer(1500,1);
timer.addEventListener(TimerEvent.TIMER,done);
timer.start();
}
private function cool(s:String):void
{
var variables:URLVariables=new URLVariables();
variables.azione=s;
variables.nome=_Name;
variables.eMail=_EMail;
var richiesta:URLRequest=new URLRequest();
richiesta.url=url;
richiesta.method=URLRequestMethod.POST;
richiesta.data=variables;
loader=new URLLoader();
loader.dataFormat=URLLoaderDataFormat.VARIABLES;
addListeners(loader);
try
{
loader.load(richiesta);
}
catch (error:Error)
{
trace('Unable to load requested document.');
}
}
private function done(evt:TimerEvent):void
{
letter_mc.alpha=.7;
error_txt.text="";
}
private function addListeners(d:IEventDispatcher):void
{
d.addEventListener(Event.OPEN,inizio);
d.addEventListener(Event.COMPLETE,completato);
d.addEventListener(SecurityErrorEvent.SECURITY_ERR OR,securityError);
d.addEventListener(IOErrorEvent.IO_ERROR,ioError);
}
private function inizio(e:Event):void
{
letter_mc.alpha=.2;
email_mc.visible=false;
name_mc.visible=false;
join_btn.visible=false;
delete_btn.visible=false;
info_mc.visible=false;
}
private function completato(e:Event):void
{
var vars:URLVariables=new URLVariables(e.target.data);
trace(vars.answer);
switch(vars.answer)
{
case 'done':
writeDone();
break;
case 'not done':
writeNotDone();
break;
}
}
private function securityError(e:SecurityErrorEvent):void
{
trace('security error: '+e+'\n');
}
private function ioError(e:IOErrorEvent):void
{
trace('send/load error: '+e+'\n');
}
private function writeDone():void
{
if(action=='registra')
final_txt.text=" You have been added to our Newsletter.\n"+
"A confirmation link has been sent to your e-mail address";
else
final_txt.text=" You have been deleted from our Newsletter.\n"+
"A confirmation link has been sent to your e-mail address";
reset();
}
private function writeNotDone():void
{
if(action=='registra')
final_txt.text=" You already are a member of our Newsletter.\n"
else
final_txt.text=" You are not a member of our Newsletter.\n"+
"therefore cannot be deleted !"
reset();
}
private function reset():void
{
timer=new Timer(4000,1);
timer.addEventListener(TimerEvent.TIMER,resetAll);
timer.start();
}
private function resetAll(evt:TimerEvent):void
{
final_txt.text="";
email_mc.field_txt.text="";
name_mc.field_txt.text="";
letter_mc.alpha=.7;
email_mc.visible=true;
name_mc.visible=true;
join_btn.visible=true;
delete_btn.visible=true;
info_mc.visible=true;
}
}
}
mmm84
04-22-2008, 01:15 PM
any idea anyone ???
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.