Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   API приложений и сред (http://www.flasher.ru/forum/forumdisplay.php?f=61)
-   -   Подключение flash-приложения как iFrame (http://www.flasher.ru/forum/showthread.php?t=155573)

mikhailk 06.05.2011 16:43

Подключение flash-приложения как iFrame
 
Используем JavaScript API, инициализируемся, если успешно - грузим флешку и дальше работаем из нее с функциями FAPI.UI.showInvite и пр. FAPI.UI.* через ExternalInterface.

Я ничего не перепутал?

Добавлено через 1 час 15 минут
Что-то непонятно как это все работает.

Вот подключил АПИ и свою флешку:

Код:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
        <title>Distribution</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="language" content="en" />
        <meta name="description" content="" />
        <meta name="keywords" content="" />
       
        <script src="js/swfobject.js" type="text/javascript"></script>
        <script type="text/javascript">
                var flashvars = {
                };
                var params = {
                        menu: "false",
                        scale: "noScale",
                        allowFullscreen: "true",
                        allowScriptAccess: "always",
                        bgcolor: "#FFFFFF"
                };
                var attributes = {
                        id:"Distribution"
                };
                swfobject.embedSWF("Distribution.swf", "altContent", "730", "660", "10.0.0", "expressInstall.swf", flashvars, params, attributes);
        </script>
       
</head>
<body onload="ODKL.init();">
        <script src="http://api.odnoklassniki.ru/js/fapi.js" type="text/javascript"></script>
        <script type="text/javascript">
        var FAPI_Params = Object(FAPI.Util.getRequestParameters());
        FAPI.init(FAPI_Params['api_server'], FAPI_Params['apiconnection'], function()

        {
                alert ("init\!");
                FAPI.UI.setWindowSize(730, 660); 
        }
        , function()

        { }
        );
       
        function API_callback(method, result, data){
                alert("Method "+method+" finished with result "+result+", "+data);
        }
       
       
        </script>
       
        <input type="button" onclick="FAPI.UI.showInvite('Default text', 'customAttr=customValue');" value="Invite">
       
        <div id="altContent">
                <h1>Distribution</h1>
                <p>Alternative content</p>
                <p><a href="http://www.adobe.com/go/getflashplayer"><img
                        src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif"
                        alt="Get Adobe Flash player" /></a></p>
        </div>
       
</body>
</html>

При загрузке алерт "инит" отрабатывает. И нажатие хтмл-кнопки с функцией FAPI.UI.showInvite также отрабатывает штатно (алерт "ShowInvite function called" выскакивает и по кнопке ОК убирается)

Однако, при попытке использовать функцию изнутри флешки алерт "ShowInvite function called" выскакивает, но при этом намертво вешает окно браузера.

Вызываю так:

Код AS3:

public function inviteFriend() : void
{
        if (ExternalInterface.available)
        {
                Debugger.dTrace("ExternalInterface.calling inviteFriend...");
                try
                {
                        ExternalInterface.call('FAPI.UI.showInvite','Default text', 'customAttr=customValue');
                }
                catch (e:Error)
                {
                        Debugger.dTrace("ExternalInterface.call: Error " + e.message);
                }       
        }
}



Часовой пояс GMT +4, время: 14:57.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.