View Full Version : to www or not to www
sooon
07-26-2007, 06:12 PM
hi guys,
I m using amfphp for a while and recently I found out some issue.
i working on a site that with the beginning of the page will have some info stream to my index page.
the interesting part is:
everything works fine if i put in: http://www.mydomain.com
but,
the data did not come back if I put: http://mydomain.com
any idea how I can resolve this?/
thanks!
by the way, if I use amfphp with flash8, which version of html setting should I use when I publish?? is there any different??
thanks!
J_Miller
07-30-2007, 03:57 AM
Well, as a simple way I have always gone about this by letting my page (ASP, PHP, CF, HTML, etc.) embed the current URL in the Flash vars of the embed tag. When my Flash file loads it grabs that URL out of the _root and appends the rest of the path to it. This way it will just make the connection based on the current domain, and not be hard coded to any certain way.
Hope that helps!
-Jason
sooon
07-30-2007, 05:15 AM
hmm...,
can you elaborate mre?? not sure if I am getting what you are saying here.
anyway, my case is:
imagine you have 2 swf, main.swf and external.swf, so what i do is my index.html is embed with the main.swf. When loaded, the main.swf will make a call via amfphp to grab some data from the database (mysql in my case) and get back to main.swf, then main.swf will loadmovie("external.swf",10) and pass the data to external.swf.
the funny thing is, it will not have problem if i put http://www.domain.com. but if I am lazy and put http://domain.com (which normally work for normal website) will still call main.swf, but due to the data from database is not back, I cannot see my external.swf.
is that clear enough of my problem?? thanks!
Please help.:) and thanks in advance.
J_Miller
07-30-2007, 06:17 AM
Correct, and the reason why it is doing this is because when you load the site minus the "www", your remoting call is still pointing to your domain with the "www". In Flash's mind, this is a cross domain violation and it will not permit the call to to happen. It thinks you are trying to make a remoting call to a domain you are not in, so it blocks it.
The solution I am purposing allows the host page to inject the current domain into your flash file (main.swf) on load. This way your Flash file doesnt care where it is loaded, it will just make the remoting connection based on the URL it was given.
For example, if you are using swfObject to embed your Flash files on the page, it may look something like this:
<div id="flashcontent">
"NO FLASH" content goes here.
</div>
<script type="text/javascript">
var theFlash = new FlashObject("yourMovie.swf", "YourMovieName", "800", "600", "8");
theFlash.addVariable("currentURL",location.href);
theFlash.write("flashcontent");
</script>
//
Once your Flash file loads, that variable can be accessed at the following location: _root.currentURL
So when you go to make your remoting call you would just use that variable to dynamically generate the URL to connect to. May look something like this:
this._Service = new Service(_root.currentURL + "/gateway.aspx", null, servicePath, null, null);
//
Hope that cleared it up a little. Let me know, I can probably provide some working examples if you need them. I use a similar process on all my projects.
-Jason
sooon
08-14-2007, 07:06 PM
Hi Jason,
ok, I don't think my method is that complex.
I just publish swf and html together from flash8 IDE.
as for your method, can you give a better example like where am I going to put your code? between HTML?? or another php file?? or the same file as my php remoting class? sorry that I m just the beginner for Flash remoting. so a bit of unclear on the server side. :P
anyway, I realise that sometimes the remoting doesn't work at all. and only after republish the swf and html, it work again. any idea what happen??
anyway thanks for replying and that does help a lot.
sooon
08-14-2007, 07:13 PM
ok,
I just checked and I did not use swfobject. it is just a plain flash8 IDE publish html and swf.
sooon
08-14-2007, 08:33 PM
ok,
now i know what you mean. that location.href will take whatever in URL textfield to send to flash. so your flash have to use _root.currentURL to dynamicaly detect what user type in.
hmm... what a smart solution.
thanks Jason.
by the way, for some reason i cannot get swfobject to work. i mean it always turn out off center for don't know why.
sooon
08-16-2007, 05:57 AM
ha! I manage to solve this with externalInterface :D
import flash.external.*;
var myUrl = ExternalInterface.call('function(){return location.href}');
so just use the myUrl for any dynamic purposes.
with this, you no need to script javascript and html.
but thanks for pointing a right direction :D
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.