コード例 #1
0
        public ApplicationSprite()
        {
            // https://code.google.com/p/chromium/issues/detail?id=42796
            // https://code.google.com/p/chromium/issues/detail?id=58909
            // https://code.google.com/p/chromium/issues/detail?id=42796
            // https://groups.google.com/a/chromium.org/forum/?fromgroups=#!msg/chromium-apps/BcC1N2nZuew/BqnyRlNSa0MJ

            // error: { errorID = 0, error = SecurityError: Error #2060, e = [UncaughtErrorEvent type="uncaughtError" bubbles=true cancelable=true eventPhase=2] }
            Security.allowDomain("*");
            Security.allowInsecureDomain("*");

            this.loaderInfo.uncaughtErrorEvents.uncaughtError +=
                e =>
            {
                //Console.WriteLine("error: " + new { e.errorID, e.error, e } + "\n run in flash debugger for more details!");

                // http://www.adobetutorialz.com/articles/1785/1/Local-Sandboxes
                content.t.Text = ("error: " + new { e.errorID, e.error, e });
            };

            this.InvokeWhenStageIsReady(
                () =>
            {
                content.AttachToContainer(this);
                content.AutoSizeTo(this.stage);

                HerokuFacebookLoginAppLoginExperienceForFlash.Diagnostics =
                    x => content.t.Text = x;

                content.t.Text = new { Security.sandboxType }.ToString();


                Func <string, string> yield_poll =
                    (string x) =>
                {
                    content.t.Text = x;

                    return("foo");
                };

                ExternalExtensions.TryAddCallback("yield_poll", yield_poll.ToFunction());

                content.MouseLeftButtonUp +=
                    delegate
                {
                    HerokuFacebookLoginAppLoginExperienceForFlash.Login(
                        (string id, string name, string third_party_id) =>
                    {
                        content.t.Text = new { id, name, third_party_id }.ToString();
                    }
                        );
                };
            }
                );
        }
コード例 #2
0
        public static void Initialize(Action init_done)
        {
            if (InitializeDone)
            {
                init_done();
                return;
            }

            InitializeDone = true;

            Diagnostics("Initialize...");


            // does __Login exist?

            // add a callback

            ExternalInterface.call("setTimeout", "window.__check__Login = function (e) { return '__Login' in window; };", 0);

            Diagnostics("prepared __check__Login...");

            100.AtDelay(
                delegate
            {
                Diagnostics("call __check__Login...");

                var value = (bool)ExternalInterface.call("__check__Login");

                if (value)
                {
                    // js app is ready for us!

                    var y = default(HerokuFacebookLoginAppLoginExperienceAction);

                    HerokuFacebookLoginAppLoginExperienceAction yield_to_sprite =
                        (string id, string name, string third_party_id) =>
                    {
                        if (y == null)
                        {
                            return;
                        }

                        y(id, name, third_party_id);
                        y = null;
                    };

                    ExternalExtensions.TryAddCallback("__Login_yield", yield_to_sprite.ToFunction());

                    __Login = yield =>
                    {
                        y = yield;

                        Diagnostics("context switch to js");

                        var value_Login = ExternalInterface.call("__Login");
                    };


                    init_done();
                }
                else
                {
                    Diagnostics("js app needs init");
                }
            }
                );
        }
コード例 #3
0
        public static void Initialize(Action <string> yield_to_sprite)
        {
            #region export callback

            ExternalExtensions.TryAddCallback("WhenReady", yield_to_sprite.ToFunction());

            #endregion

            #region Initialize JavaScript
            //TypeError: Cannot call method 'apply' of undefined


            //ExternalInterface.call("setTimeout", "window.function2 = function (e) { document.title = 'length: ' + e.length; document.getElementById('foo').value = e; return 0; };", 0);
            ExternalInterface.call("setTimeout",

                                   @"window.function2 = function (e) 
{  
    console.log('length: '  + e.length); 
// debugger;

var f = null;
//try
//{
    f = eval(e);

    console.log('done!'); 

//}
//catch (err)
//{
//    console.log('error! ' + err); 
//    console.log('typeof f: ' + typeof f); 
//    console.log('f: ' + f); 
//}
    return 0; 

};", 0);
            //ExternalInterface.call("setTimeout", "window.function1 = function (e) { alert(e.length); };", 0);
            //ExternalInterface.call("setTimeout", "document.title = 'flashed';", 0);


            var source = KnownEmbeddedResources.Default["assets/FlashBootstrapsSecondaryApplication/view-source"].ToStringAsset();

            //content.t.Text = new { source.Length }.ToString();

            //ExternalInterface.call("setTimeout", "document.title = 'source';", 0);


            //ExternalInterface.call("function2", "hi").ToString();
            //ExternalInterface.call("function2", "<\\&>\n\r\t<A//>").ToString();

            1.AtDelay(
                delegate
            {
                // Uncaught SyntaxError: Unexpected token ILLEGAL

                //var x = 1024 * 31 + 1;
                //var x = 1024 * 30 + 1 + 256;
                //var x = 1024 * 30 + 1 + 256 + 64 + 48 + 5;

                //for (d = 0; (d < AQQABtNdQz66ZYUODttTfw(c)); d++)
                //{
                //  e = EwQABtNdQz66ZYUODttTfw(c, d);
                //  f = CQQABtNdQz66ZYUODttTfw(c, d);
                //  i = !(EAQABtNdQz66ZYUODttTfw('\"\'\u005c\u0008\u000c\u000a\u000d\u0009', e) > -1);

                // YUODttTfw('\""\ }
                // tTfw('\""\u005c }
                var q = source;     //.Substring(x, 16);

                //q = q.Replace("\\'", "X");
                //q = q.Replace("\\\"", "\\x22");


                q = q.Replace("\\", "\\\\");
                //q = q.Replace("'", "X");


                // { x = 31041, Length = 1118850, q = 66ZYUODttTfw(c, d);
                //i = !(EAQABtNdQz66Z }
                // { x = 31089, Length = 1118850, q = YUODttTfw('\"\'\ }

                //content.t.Text = new { x, source.Length, q }.ToString();


                try
                {
                    ExternalInterface.call("function2", q);
                }
                catch (Exception ex)
                {
                    //content.t.Text = "error? " + new { ex.Message, ex.StackTrace };
                }
            }
                );



            //ExternalInterface.call("function1",
            //    // too much
            //    //"hello world".PadLeft(1024 * 1024)


            //    // too much
            //    //"hello world".PadLeft(1024 * 512)

            //    // 8K OK
            //    //"hello world".PadLeft(1024 * 8)

            //    // 131072 OK
            //    //"hello world".PadLeft(1024 * 8 * 16)

            //    // something wrong with pad?
            //    //524288
            //    // 1048576
            //    // 4194304
            //       1118850
            //    //new string('x', 1024 * 1024 * 4)
            //    source

            //    ).ToString();
            #endregion
        }