Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   Fullscreen + Timer = SecurityError ? (http://www.flasher.ru/forum/showthread.php?t=140494)

FlashRabbit 31.05.2010 20:46

Fullscreen + Timer = SecurityError ?
 
Добрый день,

пытаюсь поменять displayState на fullscreen после небольшой задержки с помощью Timer, но срабатывает SecurityEvent #2152.

Интересно, что если поменять displayState на fullscreen без Timer, то все работает отлично.

Код AS3:

import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
 
buttonWithTimer.addEventListener(MouseEvent.CLICK, onDelayedClick);
buttonNormal.addEventListener(MouseEvent.CLICK, onNormalClick);
 
var timer:Timer;
 
function onNormalClick(e:MouseEvent):void
{
        toogleFullscreen();
}
function onDelayedClick(e:MouseEvent):void
{
        timer = new Timer(300, 1);
        timer.addEventListener(TimerEvent.TIMER, onTimerFinish);
        timer.start();
}
function onTimerFinish(e:TimerEvent):void
{       
        toogleFullscreen();
        if(timer)
        {
                timer.removeEventListener(TimerEvent.TIMER, onTimerFinish);
                timer = null;
        }       
}
function toogleFullscreen():void
{       
        if (stage.displayState == "normal")               
        {                               
                try
                {
                        stage.displayState = "fullScreen";
                }
                catch(e:Error)
                {
                        debugTxt.appendText("\n Error: "+e.toString());
                }               
        }                                                       
        else       
        {
                stage.displayState  = "normal";       
        }               
}

Демка: http://dl.************/u/3307294/test...creenTest.html
Fla'шка: http://dl.************/u/3307294/test...screenTest.fla

Не пойму что делать, уже 3 часа убил на это.

toFlash 01.06.2010 00:37

http://www.adobe.com/livedocs/flash/...l#displayState

Full-screen mode is initiated in response to a mouse click or key press by the user; the movie cannot change Stage.displayState without user input. While Flash Player is in full-screen mode, all keyboard input is disabled (except keyboard shortcuts that take the user out of full-screen mode). A Flash Player dialog box appears over the movie when users enter full-screen mode to inform the users they are in full-screen mode and that they can press the Escape key to end full-screen mode.

gldrawworld 01.06.2010 00:46

проще говоря, создайте кнопку и нажмите ее через диспатчинг, через нужное время …*например так

Код AS3:

....
var goFullButt:Sprite;
 
goFullButt = new Sprite();
goFullButt.addEventListener(MouseEvent.CLICK,handlerGoFull);
 
....
 
 
 
function handlerGoFull(event:Event):void
{
    toogleFullscreen();
}
function onTimerFinish(e:TimerEvent):void
{       
        goFullButt.dispatchEvent(new Event(MouseEvent.CLICK,true));
        if(timer)
        {
                timer.removeEventListener(TimerEvent.TIMER, onTimerFinish);
                timer = null;
        }       
}



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

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