A Flash Developer Resource Site

Results 1 to 14 of 14

Thread: if (variable>=1){

  1. #1
    Member
    Join Date
    Aug 2006
    Posts
    63

    if (variable>=1){

    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?

  2. #2
    Senior Member
    Join Date
    Apr 2000
    Location
    Northern Ireland
    Posts
    2,146
    What exactly is the problem?
    ----------
    "Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life." TERRY PRATCHETT

  3. #3
    God
    Join Date
    Apr 2007
    Posts
    36
    Code:
    if(varible >= 1){
    _root.my_mc.play();
    else{
    _root.my_mc.stop();
           }
    }

  4. #4
    Senior Member
    Join Date
    Oct 2004
    Posts
    2,049
    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

    Code:
    if(varible >= "1"){
      _root.my_mc.play();
    }else{
      _root.my_mc.stop();
    }
    Hope this helps

  5. #5
    Member
    Join Date
    Aug 2006
    Posts
    63

    hmm....sorry not exactly..

    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..

    .
    Last edited by skam_55555; 07-19-2007 at 10:24 PM. Reason: make text bold

  6. #6
    Senior Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    132
    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!
    Adobe Certified Associate in Rich Media Communication Flash CS3

    My Company: Helix Creative My Main Project: CreativeChain

  7. #7
    Member
    Join Date
    Aug 2006
    Posts
    63
    So... are you sure that we canot access a txt file or xml file from other server using only flash actionscript????

  8. #8
    Senior Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    132
    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.
    Adobe Certified Associate in Rich Media Communication Flash CS3

    My Company: Helix Creative My Main Project: CreativeChain

  9. #9
    Member
    Join Date
    Aug 2006
    Posts
    63
    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,.....

  10. #10
    Senior Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    132
    no you dont need PHP if you use XML.
    here is a sample of loading an XML file for you to work on:

    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 1, if you are loading multiple data from XML file:
    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;
    Method 2, if you are loading only one single data:
    Code:
                data[0] = nodes[0].attributes.q;
    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!
    Adobe Certified Associate in Rich Media Communication Flash CS3

    My Company: Helix Creative My Main Project: CreativeChain

  11. #11
    Member
    Join Date
    Aug 2006
    Posts
    63
    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

  12. #12
    Member
    Join Date
    May 2003
    Location
    Florida
    Posts
    90
    If I am not mistaken, I believe flash has a security function that prevents from getting data off other websites unless authorized.
    visit my portfolio and sign my guestbook!!

  13. #13
    Member
    Join Date
    Aug 2006
    Posts
    63
    Quote Originally Posted by Cesspenar
    If I am not mistaken, I believe flash has a security function that prevents from getting data off other websites unless authorized.

    in my case,Both site is mine,so it wont be a problem..(?)

    I am experimenting something.

    thanks for the comment.

  14. #14
    Senior Member
    Join Date
    Sep 2006
    Location
    London, UK
    Posts
    132
    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:

    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>
    hope this helps!
    Adobe Certified Associate in Rich Media Communication Flash CS3

    My Company: Helix Creative My Main Project: CreativeChain

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center