コード例 #1
0
        public static void ToWebString(this Uri e, Action<string> handler)
        {
            var request = new URLRequest(e.ToString());
            request.method = URLRequestMethod.GET;

            var loader = new URLLoader();
            loader.complete +=
                args =>
                {
                    handler("" + loader.data);
                };

            loader.ioError +=
                args =>
                {
                    handler(null);
                };

            loader.securityError +=
                args =>
                {
                    handler(null);
                };

            loader.load(request);
        }
コード例 #2
0
        public static void ToWebBitmap(this Uri uri, string Host, Action<Bitmap> handler)
        {
            var x = uri.ToString();

            if (x.StartsWith(Host))
            {
                handler(
                    KnownEmbeddedResources.Default[x.Substring(Host.Length + 1)].ToBitmapAsset()
                );
                return;
            }

            var e = new Loader();

            var url = new URLRequest(uri.ToString());

            e.contentLoaderInfo.complete +=
                ev =>
                {
                    try
                    {
                        var v = (Bitmap)e.content;

                        handler(v);
                    }
                    catch
                    {
                    }
                };

            e.load(url, Context);
        }
コード例 #3
0
        /// <summary>
        /// Default constructor
        /// </summary>
        public Graphics_beginBitmapFillExample()
        {
            // http://livedocs.adobe.com/flex/3/langref/flash/display/Graphics.html#beginBitmapFill()

            var request = new URLRequest(url);

            loader.load(request);

            loader.contentLoaderInfo.complete += drawImage;
            loader.contentLoaderInfo.ioError += ioErrorHandler;

        }
コード例 #4
0
        public VerticalScrollerLoader()
        {
            // http://www.iheartactionscript.com/loading-an-external-swf-in-as3/
            // http://kb2.adobe.com/cps/141/tn_14190.html
            Security.allowDomain("*");
            Security.allowInsecureDomain("*");

            var myLoader = new ScriptCoreLib.ActionScript.flash.display.Loader();

            addChild(myLoader);

            var url = new URLRequest("http://zproxy.appspot.com.nyud.net/assets/Bulldog/VerticalScrollerFlash.swf");

            myLoader.load(url);
        }
コード例 #5
0
		/// <summary>
		/// Default constructor
		/// </summary>
		public URLRequestHeaderExample()
		{
			// http://livedocs.adobe.com/flex/3/langref/flash/net/URLRequestHeader.html#includeExamplesSummary
			// http://www.judahfrangipane.com/blog/?p=87

			var t = new TextField
			{
				multiline = true,
				text = "powered by jsc",
				background = true,
				width = 400,
				x = 8,
				y = 8,
				alwaysShowSelection = true,
			}.AttachTo(this);

			var loader = new URLLoader();

			var header = new URLRequestHeader("XMyHeader", "got milk?");

			t.appendText("\n" + this.loaderInfo.url);
			t.appendText("\nUsing relative path...");

			var request = new URLRequest("../WebForm1.aspx");
			var data = new DynamicContainer { Subject = new URLVariables("name=John+Doe") };
			data["age"] = 23;

			request.data = data.Subject;
			request.method = URLRequestMethod.POST;
			request.requestHeaders.push(header);

			loader.complete +=
				args =>
				{
					t.appendText("\n" + loader.data);
				};

			loader.load(request);



			KnownEmbeddedResources.Default[KnownAssets.Path.Assets + "/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200);
		}
コード例 #6
0
        public MySprite1()
        {
            // http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/display/Loader.html


            InternalLoadTargetContent = TargetContent =>
            {
                this.OrphanizeChildren();

                // read more: http://www.senocular.com/flash/tutorials/contentdomains/
                Security.allowDomain("*");
                Security.allowInsecureDomain("*");
                //Security.loadPolicyFile("http://www.youtube.com/crossdomain.xml");

                // http://code.google.com/apis/youtube/flash_api_reference.html
                // http://code.google.com/p/gdata-samples/source/browse/trunk/ytplayer/actionscript3/com/google/youtube/examples/AS3Player.as

                var ldr = new Loader();
                var urlReq = new URLRequest(TargetContent);

                var ctx_app = ApplicationDomain.currentDomain;
                var ctx_sec = SecurityDomain.currentDomain;

                if (TargetContent.StartsWith("http://www.youtube.com/"))
                {
                    // http://www.youtube.com/crossdomain.xml
                    ctx_app = null;
                    ctx_sec = null;

                    // http://www.zedia.net/2010/using-the-actionscript-3-youtube-api/

                    DoplayVideo = delegate
                    {
                        ldr.content.playVideo();
                    };


                    DoloadVideoById = (id, s, q) =>
                    {
                        ldr.content.loadVideoById(id, s, q);
                    };

                    Action<Event> onReady = e =>
                    {
                        if (VideoPlayerReady != null)
                            VideoPlayerReady();

#if JSC_FEATURE_dynamic
                        dynamic player = ldr.content;

                        player.setSize(160, 120);
#endif
                        ldr.content.setSize(160, 120);
                    };

                    ldr.contentLoaderInfo.init +=
                        delegate
                        {
                            ldr.content.addEventListener("onReady", onReady.ToFunction(), false, 0, false);
                        };
                }



                ldr.contentLoaderInfo.complete +=
                    delegate
                    {
                        if (Ready != null)
                            Ready();
                    };

                //ldr.mouseChildren = false;

                var ctx = new LoaderContext(true, ctx_app, ctx_sec);
                ldr.load(urlReq, ctx);

                var sprite2 = new Sprite
                {
                    z = 0.001
                }.AttachTo(this);


                sprite2.graphics.drawRect(0, 0, 100, 100);

                var t = new Timer(1000 / 60);

                t.timer +=
                    delegate
                    {
                        var x = sprite2.x;
                        var y = sprite2.y;

                        sprite2.transform.matrix3D.appendTranslation(-x, -y, 0);
                        sprite2.transform.matrix3D.appendRotation(0.01, Vector3D.Y_AXIS);
                        sprite2.transform.matrix3D.appendRotation(0.02, Vector3D.X_AXIS);
                        sprite2.transform.matrix3D.appendTranslation(x, y, 0);

                    };

                t.start();

                DoClean =
                    delegate
                    {

                        ldr.content.GetChildren().Where(k => k.GetType().Name == "InfoPanel").ToArray().WithEach(
                            k => k.Orphanize()
                        );

                    };

                ldr.AttachTo(sprite2);

                var Inspect = default(Action<DisplayObject, XElement>);

                Inspect = (Target, Journal) =>
                {

                    var SourceType = Target.GetType();

                    var n = new XElement(SourceType.Name);

                    n.Add(new XAttribute("Namespace", SourceType.Namespace));

                    SourceType.BaseType.With(
                        BaseType =>
                            n.Add(new XAttribute("BaseType", BaseType.FullName))
                    );


                    Journal.Add(n);

                    (Target as DisplayObjectContainer).With(
                        Container =>
                        {
                            for (int i = 0; i < Container.numChildren; i++)
                            {
                                Inspect(Container.getChildAt(i), n);
                            }
                        }
                    );

                };

                DoInspect =
                    delegate
                    {
                        var doc = new XElement("Inspection");

                        // SecurityError: Error #2121: Security sandbox violation: Loader.content: http://localhost:26925/assets/LoadExternalFlashComponent.Application/LoadExternalFlashComponent.Components.MySprite1.swf cannot access http://sketch.odopod.com/flash/OdoSketch.swf?sketchURL=/sketches/231498.xml&userURL=/users/21416&bgURL=/images/bigbg.jpg&mode=embed. This may be worked around by calling Security.allowDomain.
                        //	at flash.display::Loader/get content()

                        try
                        {
                            Inspect(ldr.content, doc);
                        }
                        catch (Exception exc)
                        {
                            var n = new XElement("error", exc.Message);

                            doc.Add(n);
                        }

                        if (Inspecting != null)
                            Inspecting(doc);
                    };

            };

            LoadTargetContent();
        }
コード例 #7
0
        public void DownloadStringAsync(Uri address)
        {
            // testedby
            // X:\jsc.svn\examples\actionscript\Test\TestWebClient\TestWebClient\ApplicationSprite.cs

            var request = new URLRequest(address.ToString())
            {
                method = URLRequestMethod.GET
            };

            var loader = new URLLoader();
            loader.complete +=
                args =>
                {
                    var e = new __DownloadStringCompletedEventArgs { Result = "" + loader.data };

                    DownloadStringCompleted(this, (DownloadStringCompletedEventArgs)(object)e);
                };

            loader.ioError +=
                args =>
                {
                    var e = new __DownloadStringCompletedEventArgs { Error = new Exception("ioError") };
                    DownloadStringCompleted(this, (DownloadStringCompletedEventArgs)(object)e);
                };


            loader.securityError +=
                args =>
                {
                    var e = new __DownloadStringCompletedEventArgs
                    {
                        Error = new Exception(
                            "securityError " + new { args.errorID, args.text }
                            )
                    };
                    DownloadStringCompleted(this, (DownloadStringCompletedEventArgs)(object)e);
                };

            loader.load(request);
        }
コード例 #8
0
 /// <summary>
 /// Creates a URLLoader object.
 /// </summary>
 public URLLoader(URLRequest request)
 {
 }
コード例 #9
0
		/// <summary>
		/// Opens a dialog box that lets the user download a file from a remote server.
		/// </summary>
		public void download(URLRequest request, string defaultFileName)
		{
		}
コード例 #10
0
 /// <summary>
 /// Starts the upload of a file selected by a user to a remote server.
 /// </summary>
 public void upload(URLRequest request, string uploadDataFieldName, bool testUpload)
 {
 }
コード例 #11
0
 /// <summary>
 /// Loads a SWF, JPEG, progressive JPEG, unanimated GIF, or PNG file into an object that is a child of this Loader object.
 /// </summary>
 public void load(URLRequest request, LoaderContext context)
 {
 }
コード例 #12
0
ファイル: Sound.cs プロジェクト: exaphaser/JSC-Cross-Compiler
 /// <summary>
 /// Creates a new Sound object.
 /// </summary>
 public Sound(URLRequest stream)
 {
 }
コード例 #13
0
ファイル: Sound.cs プロジェクト: exaphaser/JSC-Cross-Compiler
 /// <summary>
 /// Creates a new Sound object.
 /// </summary>
 public Sound(URLRequest stream, SoundLoaderContext context)
 {
 }
コード例 #14
0
ファイル: Sound.cs プロジェクト: exaphaser/JSC-Cross-Compiler
 /// <summary>
 /// Initiates loading of an external MP3 file from the specified URL.
 /// </summary>
 public void load(URLRequest stream)
 {
 }
コード例 #15
0
        public Task<byte[]> UploadValuesTaskAsync(Uri address, NameValueCollection data)
        {
            // X:\jsc.svn\examples\actionscript\Test\TestWorkerUploadValuesTaskAsync\TestWorkerUploadValuesTaskAsync\ApplicationSprite.cs
            // https://forums.adobe.com/thread/1189679

            var xx = new TaskCompletionSource<byte[]>();

            // X:\jsc.svn\examples\actionscript\Test\TestUploadValuesTaskAsync\TestUploadValuesTaskAsync\ApplicationSprite.cs

            var request = new URLRequest(address.ToString())
            {
                method = URLRequestMethod.POST
            };

            // should we use dynamic instead?
            var x = new DynamicContainer { Subject = new URLVariables() };

            foreach (var item in data.AllKeys)
            {
                x[item] = data[item];
            }

            // http://stackoverflow.com/questions/12774611/urlrequest-urlloader-auto-converting-post-request-to-get
            // !!!!
            request.data = (object)x.Subject;
            //request.contentType = ""

            var loader = new URLLoader();
            // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoaderDataFormat.html
            //loader.dataFormat = URLLoaderDataFormat.Binary;
            loader.dataFormat = "binary";
            // http://stackoverflow.com/questions/7816231/how-to-use-as3-to-load-binary-data-from-web-server

            loader.complete +=
                args =>
                {
                    // If the dataFormat property is URLLoaderDataFormat.BINARY, the received data is a ByteArray object 
                    // containing the raw binary data.

                    //                TypeError: Error #1034: Type Coercion failed: cannot convert ScriptCoreLib.Shared.BCLImplementation.System.Net::__DownloadStringCompletedEventArgs@5422ad9 to ScriptCoreLib.Shared.BCLImplementation.System.Net.__UploadValuesCompletedEventArgs.
                    //at ScriptCoreLib.ActionScript.BCLImplementation.System.Net::__WebClient/_UploadValuesAsync_b__7_4ebbe596_06000fb2()[V:\web\ScriptCoreLib\ActionScript\BCLImplementation\System\Net\__WebClient.as:143]
                    //at flash.events::EventDispatcher/dispatchEventFunction()
                    //at flash.events::EventDispatcher/dispatchEvent()
                    //at flash.net::URLLoader/redirectEvent()

                    // TypeError: Error #1034: Type Coercion failed: cannot convert ScriptCoreLib.Shared.BCLImplementation.System.Net::__DownloadStringCompletedEventArgs@53686e9 to ScriptCoreLib.Shared.BCLImplementation.System.Net.__UploadValuesCompletedEventArgs.

                    //throw new Exception(
                    //    new { loader.data, loader.dataFormat, t = loader.data.GetType() }.ToString()
                    //);

                    var bytes = (ByteArray)loader.data;
                    var Result = (byte[])bytes.ToArray();

                    //if (UploadValuesCompleted != null)
                    //    UploadValuesCompleted(this, (UploadValuesCompletedEventArgs)(object)e);

                    xx.SetResult(Result);
                };

            loader.ioError +=
                args =>
                {
                    var e = new __UploadValuesCompletedEventArgs { Error = new Exception("ioError") };
                    //if (UploadValuesCompleted != null)
                    //    UploadValuesCompleted(this, (UploadValuesCompletedEventArgs)(object)e);

                    throw e.Error;
                };


            loader.securityError +=
                args =>
                {
                    var e = new __UploadValuesCompletedEventArgs
                    {
                        Error = new Exception(
                            "securityError " + new { args.errorID, args.text }
                            )
                    };

                    //if (UploadValuesCompleted != null)
                    //    UploadValuesCompleted(this, (UploadValuesCompletedEventArgs)(object)e);

                    throw e.Error;
                };

            loader.load(request);

            return xx.Task;
        }
コード例 #16
0
		/// <summary>
		/// Starts the upload of a file selected by a user to a remote server.
		/// </summary>
		public void upload(URLRequest request, string uploadDataFieldName, bool testUpload)
		{
		}
コード例 #17
0
		/// <summary>
		/// Starts the upload of a file selected by a user to a remote server.
		/// </summary>
		public void upload(URLRequest request, string uploadDataFieldName)
		{
		}
コード例 #18
0
 /// <summary>
 /// Starts the upload of a file selected by a user to a remote server.
 /// </summary>
 public void upload(URLRequest request, string uploadDataFieldName)
 {
 }
コード例 #19
0
		/// <summary>
		/// Opens a dialog box that lets the user download a file from a remote server.
		/// </summary>
		public void download(URLRequest request)
		{
		}
コード例 #20
0
 /// <summary>
 /// Opens a dialog box that lets the user download a file from a remote server.
 /// </summary>
 public void download(URLRequest request, string defaultFileName)
 {
 }
コード例 #21
0
 /// <summary>
 /// Sends and loads data from the specified URL.
 /// </summary>
 public void load(URLRequest request)
 {
 }
コード例 #22
0
 /// <summary>
 /// Opens a dialog box that lets the user download a file from a remote server.
 /// </summary>
 public void download(URLRequest request)
 {
 }
コード例 #23
0
        public YouTubePlayer(
            string TargetContent = "http://www.youtube.com/apiplayer?version=3",
            int DefaultWidth = 1280,
            int DefaultHeight = 720,
            string DefaultVideo = "Z__-3BbPq6g",

            string suggestedQuality = "hd720",


            Action yield_init = null
            )
        {
            var ldr = new Loader();
            this.Loader = ldr;
            var urlReq = new URLRequest(TargetContent);

            var ctx_app = ApplicationDomain.currentDomain;
            var ctx_sec = SecurityDomain.currentDomain;

            // http://www.youtube.com/crossdomain.xml
            ctx_app = null;
            ctx_sec = null;

            // http://www.zedia.net/2010/using-the-actionscript-3-youtube-api/

            bool once = false;

            #region onReady
            Action<Event> onReady = e =>
            {
                if (once)
                    return;

                once = true;


#if JSC_FEATURE_dynamic
                        dynamic player = ldr.content;

                        player.setSize(160, 120);
#endif
                ldr.content.setSize(DefaultWidth, DefaultHeight);

                pauseVideo = delegate
                {
                    ldr.content.pauseVideo();
                };

                loadVideoById = x =>
                {
                    CurrentVideoId = x;

                    ldr.content.loadVideoById(x, suggestedQuality: suggestedQuality);
                };

                loadVideoById(DefaultVideo);

                if (yield_init != null)
                {
                    yield_init();
                    yield_init = null;
                }


            };
            #endregion


            var PreviousCurrentState = YouTubePlayerState.unknown;
            var CurrentState = YouTubePlayerState.unknown;

            DefaultScene = this["default", 0, 1000];
            var CurrentScene = DefaultScene;
            Action CurrentSceneDone = delegate { };

            #region onStateChange
            Action<Event> onStateChange = e =>
            {
                PreviousCurrentState = CurrentState;
                CurrentState = e.get_data_as_YouTubePlayerState();

                if (PreviousCurrentState != CurrentState)
                {
                    if (CurrentState == YouTubePlayerState.playing)
                    {
                        // notify other scenes of delinking?

                        if (this.Playing != null)
                            this.Playing(SceneTranslate(CurrentScene));

                        this.ReferencedScenes.WithEach(
                            k =>
                            {
                                k.RaiseLinkDenotification();
                            }
                        );
                    }
                    else
                    {
                        if (this.NotPlaying != null)
                            this.NotPlaying(SceneTranslate(CurrentScene));
                    }

                    if (CurrentState == YouTubePlayerState.paused)
                    {
                        if (this.Paused != null)
                            this.Paused(SceneTranslate(CurrentScene));

                    }
                }
            };
            #endregion


            var TimeToPause = 0.4;

            var t = new Timer(1000 / 100);

            var PlaySceneCounter = 0;

            t.timer +=
                delegate
                {
                    if (ldr.content == null)
                        return;

                    if (CurrentState == YouTubePlayerState.playing)
                    {
                        var time = ldr.content.getCurrentTime();

                        var time_index = (int)time;

                        var duration = ldr.content.getDuration();

                        var playall = CurrentScene.end > duration;

                        // flag4 = ((double0 < (double2 - 500)) == 0);
                        // 1 second is 1.0!! :)
                        var notending = time < (duration - 0.500);
                        //var xending = time >= (duration - 500);
                        var ending = !notending;

                        // ReferenceError: Error #1069: Property getDuration not found on flash.display.Loader and there is no default value.
                        var m = new { PlaySceneCounter, time, time_index, CurrentScene.end, duration, playall, ending }.ToString();

                        if (StatusToClients != null)
                            StatusToClients(m);

                        // phone activated

                        if (playall)
                        {
                            if (ending)
                            {
                                ldr.content.pauseVideo();
                                CurrentSceneDone();
                            }
                        }
                        else if (time >= (TimeToPause))
                        {
                            ldr.content.pauseVideo();
                            CurrentSceneDone();
                        }
                    }
                };

            t.start();

            #region PlayScene
            this.PlayScene =
                (e, Done) =>
                {
                    PlaySceneCounter++;

                    //if (e.end == 0)
                    //    e.end = ldr.content.getDuration() - 1000;

                    CurrentScene = e;
                    CurrentSceneDone = Done;

                    TimeToPause = e.end;

                    ldr.content.seekTo(e.start);
                    ldr.content.playVideo();
                };
            #endregion



            ldr.contentLoaderInfo.ioError +=
                delegate
                {

                };

            ldr.contentLoaderInfo.init +=
                delegate
                {
                    ldr.content.addEventListener("onReady", onReady.ToFunction(), false, 0, false);
                    ldr.content.addEventListener("onStateChange", onStateChange.ToFunction(), false, 0, false);

                };

            var ctx = new LoaderContext(true, ctx_app, ctx_sec);
            ldr.load(urlReq, ctx);


            this.Scenes = new SceneSequenzer { Owner = this };
        }
コード例 #24
0
 /// <summary>
 /// Sends and loads data from the specified URL.
 /// </summary>
 public void load(URLRequest request)
 {
 }
コード例 #25
0
 /// <summary>
 /// Creates a URLLoader object.
 /// </summary>
 public URLLoader(URLRequest request)
 {
 }
コード例 #26
0
        public MySprite1()
        {
            // http://apiwiki.justin.tv/mediawiki/index.php/Live_Video_SWF_Documentation
            Security.allowDomain("*");
            Security.allowInsecureDomain("*");

            // http://apiwiki.justin.tv/mediawiki/index.php/Live_Video_SWF_Documentation

            //var TargetContent = "http://www.justin.tv/widgets/live_api_player.swf?video_height=480&video_width=640&consumer_key=YOUR_API_KEY";

            var TargetContent = "http://www.justin.tv/widgets/live_api_player.swf?video_height=480&video_width=640";

            var ldr = new Loader();
            var urlReq = new URLRequest(TargetContent);

            var ctx_app = ApplicationDomain.currentDomain;
            var ctx_sec = SecurityDomain.currentDomain;

            ctx_sec = null;
            ctx_app = null;

            __api_play_live = delegate
            {
            };

            ldr.contentLoaderInfo.complete +=
                delegate
                {
                    __api_play_live =
                        channel =>
                        {
                            ldr.content.api_play_live(channel);
                        };

                    __api_play_live("nitro301");
                    //(ldr.content as dynamic).api.play_live("apidemo");
                };

            var ctx = new LoaderContext(true, ctx_app, ctx_sec);
            sprite2 = new Sprite { z = 0.02 }.AttachTo(this);

            sprite2.mouseChildren = false;

            ldr.AttachTo(sprite2);

            var t = new Timer(1000 / 60);

            t.timer +=
                delegate
                {
                    var x = sprite2.x;
                    var y = sprite2.y;

                    sprite2.transform.matrix3D.appendTranslation(-x, -y, 0);
                    sprite2.transform.matrix3D.appendRotation(0.01, Vector3D.Y_AXIS);
                    sprite2.transform.matrix3D.appendRotation(0.02, Vector3D.X_AXIS);
                    sprite2.transform.matrix3D.appendTranslation(x, y, 0);

                };

            t.start();

            try
            {
                ldr.load(urlReq, ctx);

            }
            catch
            {
            }
        }