hi,
my_mc is embeded in mysite1.com/index.html
my text file in mysite2.com/my.txt
in the text file i have a variable.
if (variable>=1){
i want my_mc to play //which is in other site
}else {
stop play my_mc
}
any help?
Printable View
What exactly is the problem?
Code:if(varible >= 1){
_root.my_mc.play();
else{
_root.my_mc.stop();
}
}
if your getting your var from a text file then when as reads the value its going to be a string. so try something like this
Hope this helpsCode:if(varible >= "1"){
_root.my_mc.play();
}else{
_root.my_mc.stop();
}
Thanks to "garbage","wattsup" and "human idiot".
My problem is not checking a condition.But to access a text file which is in other domain.
can i use
load variable(http://www.mysite2.com/my.txt)
(i know this is not the way)
or atleast is there any way that i can check this text file is exist in the server?
so i can code like
if(file is present){
play my_mc
}else{
stop
}
please remember that my_mc is in www.site1.com
and my.txt file is in www.site2.com
I repeat,its not 2 different files in the same website,
entirely 2 different websites.
swf in site1 and txt in site2
hope you guys can help me..
.
for checking the existence you probably have to use PHP. and maybe even for loading the variable from the other server you can use PHP to get it for you then use it in Flash. or even if you save the file as an XML file, then accessing to it is very easier since Flash can directly interact with XML!
So... are you sure that we canot access a txt file or xml file from other server using only flash actionscript????
you can access XML files from anywhere with AS. I dont use text files much myself since Flash has better integration with XML and its easier to control. But you will need PHP to check the existance of a file. Even though Flash will generate an error if the XML file its trying to load is not existed, so maybe you can catch this error and use it to display an error message to the user.
If this is what you want, I can provide you with some AS.
thanks Ameretat,
even if i am using xml,still need php?
mine is simple html +flash site.
anyway can you provide code or some guideline?
especially the code to access the xml
thanks,.....
no you dont need PHP if you use XML.
here is a sample of loading an XML file for you to work on:
Method 1, if you are loading multiple data from XML file:Code:function LoadData(){
dataXML = new XML();
dataXML.ignoreWhite = true;
dataXML.load("data.xml");
dataXML.onLoad = function(success){
if(success){
var root = this.firstChild;
nodes = root.childNodes;
//CHECK THE ALTERNATIVE METHODS
}else{
trace("ERROR");
}
}
}
Method 2, if you are loading only one single data:Code:
for(var i=0; i<nodes.length; i++) {
data1[i] = nodes[i].attributes.q;
subdata1[i] = nodes[i].attributes.a;
subdata2[i] = nodes[i].attributes.b;
subdata3[i] = nodes[i].attributes.c;
this is the AS for loading the XML file. I dont know if you know much about XML, but I could try and explain it a bit if you want!Code:data[0] = nodes[0].attributes.q;
Great....
thanks you soo much..
I think it ll really work..let me try..
Tell me what else can you share with..Once I used XML(of course with the help of flash kit)but dont know much about it..
Please explain me as I am a Stupid Idiot..
:)
thanks again
If I am not mistaken, I believe flash has a security function that prevents from getting data off other websites unless authorized.
Quote:
Originally Posted by Cesspenar
in my case,Both site is mine,so it wont be a problem..(?)
I am experimenting something.
thanks for the comment.
Cesspenar is right about the Flash security, but there is a way round it as Adobe itself has suggested and it is to use an XML file called crossdomain.xml in this file you can list the URL of the sites you want to allow to access your Flash file, which in your case would be the URL of your second website!
crossdomain.xml:
hope this helps!Code:<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.macromedia.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
<allow-access-from domain="www.site2.com" />
</cross-domain-policy>