/// <summary>
        /// Default constructor
        /// </summary>
        public ZIPExample1()
        {
            var BitmapsLoaded = 0;

            var Bitmaps = Enumerable.ToArray(
                from File in
                    from f in MyZipFile.ToZIPFile().Entries
                    //from f in MyZipFile.ToFiles()
                    // you can filter your images here
                    where f.FileName.EndsWith(".png")
                    select f
                select new { File, GetBitmap = File.Data.ToByteArray().LoadBytes<Bitmap>(i => BitmapsLoaded++) }
            );





            (200).AtInterval(
                (t, add) =>
                {
                    if (BitmapsLoaded != Bitmaps.Length)
                        return;


                    var Entry = Bitmaps[t.currentCount % Bitmaps.Length];
                    var Bitmap = Entry.GetBitmap();

                    Bitmap.scaleX = 4;
                    Bitmap.scaleY = 4;
                    Bitmap.AttachTo(this);

                    var text = new TextField
                    {
                        selectable = false,
                        text = Entry.File.FileName
                    }.AttachTo(this);


                    add(
                        delegate
                        {
                            text.Orphanize();
                            Bitmap.Orphanize();
                        }
                    );



                }
            );


        }
Exemple #2
0
        public Menu()
        {
            CanFire = false;

            var menumusic = Sounds.snd_birds.ToSoundAsset().play(0, 999);

            Mouse.show();

            Aim.visible = false;

            GetWarzone().filters = new[] { new BlurFilter() };

            var InfoMenu = new Sprite
            {
                x = 120,
                y = 120
            }.AttachTo(this);

            var y = 0d;

            // X:\jsc.svn\examples\actionscript\FlashTowerDefense\FlashTowerDefense\ActionScript\Menu.cs
            // public override event Action<MouseEvent> contextMenu;
            // public ContextMenu contextMenu { get; set; }
            // um the jsc rewriter should rename
            // either the field or the event.
            // or the flash natives gen should stop
            // creating events that have the same name
            // as fields.
            // carlo! :)

            // can jsc send a comment?

            //"this is a comment";
            "this is a comment".Comment();


#if FContextMenu
            // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201404/20140402



            this.contextMenu = new ContextMenu();
            this.contextMenu.hideBuiltInItems();
#endif


            foreach (var v in this.Settings.KnownActors)
            {
                AddInfo(InfoMenu, y, v);

                y += 72;
            }

            #region Play
            var PlayButton = new TextField
            {
                defaultTextFormat = new TextFormat
                {
                    size = 36
                },
                autoSize = TextFieldAutoSize.LEFT,
                htmlText = "Play!",
                selectable = false,
                textColor = ColorBlue,
                filters = new[] { new GlowFilter(ColorBlueLight) }

            }.AttachTo(this);

            PlayButton.x = DefaultWidth - PlayButton.width - 32;
            PlayButton.y = DefaultHeight - PlayButton.height - 32;

            PlayButton.OnHoverUseColor(ColorRed);



            PlayButton.click +=
                delegate
                {
                    menumusic.stop();

                    InfoMenu.mouseEnabled = false;
                    InfoMenu.mouseChildren = false;

                    InfoMenu.FadeOutAndOrphanize(1000 / 64, 0.21);


                    GetWarzone().filters = null;

                    Action PlaySound = () => Sounds.snd_click.ToSoundAsset().play();

                    PlaySound();

                    //PlaySound.InvokeAtDelays(0, 500, 800);


                    CanFire = true;
                    PlayButton.Orphanize();
                    Aim.visible = true;
                    Mouse.hide();
                };
            #endregion

        }
        //C:\util\flex_sdk_4.6\frameworks\flex-config.xml(47): Error: unable to open 'libs/player/11.1/playerglobal.swc'


        // http://www.adobe.com/devnet/flashplayer/articles/rtmfp_stratus_app_03.html

        // see this video:
        // http://tv.adobe.com/#vi+f15384v1056

        /// <summary>
        /// Default constructor
        /// </summary>
        public FlashStratusDemo()
        {

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

            var c = new NetConnection();



            Func<NetStatusEvent, string> get_Code =
                e =>
                {
                    var info = new DynamicContainer { Subject = e.info };
                    var code = (string)info["code"];

                    return code;
                };


            c.netStatus +=
                status =>
                {
                    // http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/events/NetStatusEvent.html#info


                    t.appendText("\nc.netStatus: " + get_Code(status));

                    if (get_Code(status) == "NetConnection.Connect.Success")
                    {
                        t.appendText("\n" + c.nearID);

                        #region we could be a client

                        var q = new TextField
                        {
                            background = true,
                            x = 0,
                            y = 200,
                            width = 400,
                            alwaysShowSelection = true,
                            text = "enter id here",
                            type = TextFieldType.INPUT
                        }.AttachTo(this);


                        q.change +=
                            delegate
                            {
                                if (q.text.Length != c.nearID.Length)
                                    return;

                                if (q.text == c.nearID)
                                    return;

                                t.appendText("\ntarget set");
                                q.Orphanize();

                                var r = new NetStream(c, q.text);

                                r.netStatus +=
                                    r_status =>
                                    {

                                        t.appendText("\nr.netStatus: " + get_Code(r_status));
                                    };

                                r.client = new DynamicDelegatesContainer
									{
										{"handler1", 
											(string x) =>
											{
												t.appendText("\nhandler1: " + x);
												t.setSelection( t.length, t.length);
											}
										}
									}.Subject;

                                r.play("stream1");
                            };
                        #endregion

                        // yay! we are online
                        var s = new NetStream(c, NetStream.DIRECT_CONNECTIONS);

                        s.client = new DynamicDelegatesContainer
						{
							{"onPeerConnect", 
								(NetStream x) =>
								{
									
									t.appendText("\nonPeerConnect: " + x.farID);
									t.setSelection( t.length, t.length);

									q.Orphanize();

									return true;
								}
							}
						}.Subject;

                        s.netStatus +=
                            s_status =>
                            {

                                t.appendText("\ns.netStatus: " + get_Code(s_status));
                            };









                        s.publish("stream1");

                        #region broadcast the data
                        var counter = 0;

                        5000.AtInterval(
                            delegate
                            {
                                counter++;

                                s.send("handler1", "counter = " + counter);
                            }
                        );
                        #endregion

                    }
                };




            // "Developer Key" means any license key, activation code, or similar 
            // installation, access or usage control codes, including serial numbers 
            // and electronic certificates digitally signed by Adobe, designed to 
            // uniquely identify your Developer Program and link it to you 
            // the Developer.

            // Attention: You cannot use this key in your applications.
            //c.connect("rtmfp://stratus.adobe.com/3f37a156abb67621000856d1-08d2970f1b43/");
            c.connect("rtmfp://stratus.adobe.com/3f37a156abb67621000856d1-08d2970f1b43");

            // X:\jsc.svn\examples\actionscript\MultitouchExample\MultitouchFingerTools.FlashLAN\ApplicationCanvas.Session.cs
        }
		public MyFactory()
		{
			var t = new TextField { text = "loading", autoSize = TextFieldAutoSize.LEFT, x = 400 }.AttachTo(this);



			var Ready = default(Action);

			Ready = delegate
			{
				// 1 more
				Ready = delegate
				{
					// done
					Ready = delegate
					{
						// nothing
					};

					CreateInstance().AttachTo(this);
				};
			};

			_mochiads_game_id = "test";

			this.InvokeWhenStageIsReady(
				delegate
				{
					this.showPreGameAd(() => Ready(), 400, 400);

				}
			);

			this.LoadingComplete +=
				delegate
				{
					t.Orphanize();

					Ready();
				};

			this.LoadingInProgress +=
				delegate
				{
					t.text = new { root.loaderInfo.bytesLoaded, root.loaderInfo.bytesTotal /*, framesLoaded, totalFrames */}.ToString();
				};

		}