A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [CS4][AS2]help!!! site in different languages wit flash header

  1. #1
    Junior Member
    Join Date
    Feb 2010
    Posts
    1

    [CS4][AS2]help!!! site in different languages wit flash header

    Hi,
    I have a question about my site...
    I have to set button for changing the default language with another one ... this button have to be in my flash header ... only the header in my site is flash ...
    How can I do this .. ?
    I want to read the current URL and change the part of it ..
    for example:
    www . myweb.com/en/about.html
    >>>> www . myweb.com/fr/about.html

    Is this possible with ActionScript 2.0???
    Sorry about the question ... but I really need the answer!!!

    Thanks a lot!!

  2. #2
    Hi,

    there is no problems to do this with AS2.

    You have to aplly actionscript to a button object, which opens 2 different urls, depending on what is current language. If it is english, when the user click the button will change the language to french. If it is french - it should change it to english.

    This can happen by using cookie file. In this cookie will be set a variable for the language. The the actionscript will read the cookie and find which is current language out.

    You have to use script like this:

    Actionscript Code:
    var here = this

    // create an object to store the variables
    varReceiver = new LoadVars();
    // load a file
    // now the target path is to the server, because it's a php file

    varReceiver.load("cookie.php?f="+Math.floor(Math.random()*1000000));

    //cookie.php is your cookie file with the variable for the languages. You can write the full path to the cookie - [url]http://yoursite.com/files/cookie.php[/url]  for example


    // when the variables finish loading
    //trigger something
    varReceiver.onLoad = function() {

    if(lang == "english") {

    button_en._visible = false;
    button_fr._visible = true;

    }

    else if (lang =="french") {

    button_fr._visible = false;
    button_en._visible = true;

    }




    }

    This script should be in the frame 1.

    You should have two buttons on one place. English button and French button. Depending on the cookie information - the actionscript will leave the button for the language different from the current language.

    For example if the current language is english - the script will leave the button with script for setting french language. This french btn will have script like this:

    Actionscript Code:
    on(release){

    getURL ("www.myweb.com/fr/about.php?l_id=2", "self"); // here the script passes the variable lang_id with value 2 for the cookie file.

    }

    And there you go.

    Your cookie.php files should contains script like this:

    <?php
    $lang = "English";
    if ($_COOKIE["lang_id"]==1) $lang="english";
    if ($_COOKIE["lang_id"]==2) $lang="french";
    // echo the variables
    echo ("&lang=$lang");
    ?>

    And in the about.php file you have to have script for setting the cookie file.

    <?

    if (isset($_GET["l_id"])) {
    setcookie("lang_id",$_GET["l_id"]);
    }

    ?>


    This how i deal with cookies in flash and php. If you don`t want to use php. You should read about JavaScript cookies.



    But the simplest way is : making two different .swf-s. In the french file embed the .swf with button for english. And in the english version embed .swf with button for french.

    Simple and useful


    Scotty does know how to Fla-make cool ads.

    http://flamake.net - this Ads will Fla-make you crazy. Find your cheap flash banners and see the best commercials around the world.

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