public __TextBlock() { InternalTextField = new TextField { autoSize = TextFieldAutoSize.LEFT, type = TextFieldType.DYNAMIC, selectable = false, //background = true, //backgroundColor = 0xffffffff, //alwaysShowSelection = true, //border = true, //borderColor = 0x808080 // http://code.hellokeita.in/public/trunk/as3/br/hellokeita/utils/TextFieldColor.as }; //InternalTextField.y = InternalOffsetY; InternalTextFieldContainer = new Sprite(); InternalTextFieldContainer.addChild(InternalTextField); // http://www.typetester.org/ //InternalTextField.defaultTextFormat.font = "Verdana"; LocalInternalSetFonFamily(new FontFamily("Verdana")); }
public ApplicationSprite() { // X:\jsc.svn\examples\actionscript\Test\TestWebClient\TestWebClient\ApplicationSprite.cs // X:\jsc.svn\examples\actionscript\Test\TestWorkerUploadValuesTaskAsync\TestWorkerUploadValuesTaskAsync\ApplicationSprite.cs // X:\jsc.svn\examples\actionscript\Test\TestUploadValuesTaskAsync\TestUploadValuesTaskAsync\ApplicationSprite.cs var t = new TextField { autoSize = TextFieldAutoSize.LEFT, text = "click me", multiline = true }.AttachTo(this); t.click += async delegate { // can we do it on the worker? var _06000010_username = ""; var w = new WebClient(); //w.UploadValuesCompleted += (sender, args) => //{ // if (args.Error != null) // { // t.text = "UploadValuesCompleted error " + new { args.Error }.ToString(); // return; // } // // DownloadStringAsync { Length = 2822 } // var data = Encoding.UTF8.GetString(args.Result); // // // t.text = "UploadValuesCompleted " + new { args.Result.Length } + "\n\n" + data; //}; // can we use client credentials? var Result = await w.UploadValuesTaskAsync( //new Uri("/xml?WebMethod=06000002&n=WebMethod2", UriKind.Relative), new Uri("/xml/WebMethod2", UriKind.Relative), data: new System.Collections.Specialized.NameValueCollection { { "_06000002_username", _06000010_username}, { "_06000002_psw", ""}, // the token keeps chaning! { "WebMethodMetadataToken", "06000007"}, { "WebMethodMetadataName", "WebMethod2"} } ); var data = Encoding.UTF8.GetString(Result); // t.text = "UploadValuesCompleted " + new { Result.Length } + "\n\n" + data; }; }
public __PasswordBox() { // X:\jsc.svn\examples\actionscript\air\AIRAvalonPasswordField\AIRAvalonPasswordField\ApplicationCanvas.cs InternalTextFieldContainer = new Sprite(); InternalTextField = new TextField { autoSize = TextFieldAutoSize.LEFT, type = TextFieldType.INPUT, displayAsPassword = true, background = true, backgroundColor = 0xffffffff, alwaysShowSelection = true, border = true, borderColor = 0x808080 // http://code.hellokeita.in/public/trunk/as3/br/hellokeita/utils/TextFieldColor.as }; InternalTextField.y = InternalOffsetY; InternalTextFieldContainer = new Sprite(); InternalTextFieldContainer.addChild(InternalTextField); // http://www.typetester.org/ //InternalTextField.defaultTextFormat.font = "Verdana"; //LocalInternalSetFonFamily(new FontFamily("Verdana")); }
private void InitializeWriteLine() { var dumper = new TextField { width = DefaultControlWidth, height = DefaultControlHeight, textColor = 0xffff00, mouseEnabled = false }.AttachTo(this); var dumper_queue = new Queue<string>(); WriteLine = text => { dumper_queue.Enqueue(text); while (dumper_queue.Count > 10) dumper_queue.Dequeue(); dumper.text = ""; foreach (var v in dumper_queue) { dumper.appendText(v + Environment.NewLine); } }; }
public StopwatchExample() { var t = new TextField { text = "powered by jsc", background = true, width = 400, x = 20, y = 40, alwaysShowSelection = true, }.AttachTo(this); var w = new Stopwatch(); w.Start(); var timer = new Timer(3000, 1); timer.timer += delegate { w.Stop(); t.appendText(" work done in " + w.Elapsed.TotalMilliseconds); }; timer.start(); KnownEmbeddedResources.Default["assets/StopwatchExample/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200); }
/// <summary> /// Default constructor /// </summary> public FlashAlchemyEcho() { var c = new cmodule.FlashAlchemyEcho.CLibInit(); var x = new DynamicContainer.Delegates { Subject = c.init() }; var t = new TextField { multiline = true, text = "powered by jsc", background = true, x = 20, y = 40, width = 300, alwaysShowSelection = true, }.AttachTo(this); t.text = x.ToConverter<string, string>("echo")("goo"); //var echo = x["echo"] as Function; //var a = new ScriptCoreLib.ActionScript.Array(); //a.push("yo"); //t.text = (string)echo.apply(x.Subject, a); //t.text = echo.GetType().ToString(); //t.text = x.Invoke<string, string>("echo", "foo"); KnownEmbeddedResources.Default[KnownAssets.Path.Assets + "/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200); }
/// <summary> /// Default constructor /// </summary> public Application() { // http://curtismorley.com/2007/08/31/flash-cs3-flex-2-as3-error-2148/ Security.allowDomain("*"); Security.allowInsecureDomain("*"); Security.loadPolicyFile(Host + "/crossdomain.xml"); var t = new TextField { multiline = true, wordWrap = false, text = "powered by jsc!!!!", background = true, width = 400, height = 400, x = 8, y = 8, alwaysShowSelection = true, }.AttachTo(this); // This game shall know less games than the server var games = GameReferenceExtensions.Partial; var gi = 0; new Uri(Host + "/promotion").ToWebString( data => { if (data != null) games = games.FromYAML(data); // http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/text/TextField.html // Error #2044: Unhandled IOErrorEvent:. text=Error #2124: Loaded file is an unknown type. // Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found. var w = new StringBuilder(); foreach (var g in games) { new Uri(g.Image).ToWebBitmap( Host, img => { img.AttachTo(this).MoveTo(200, 95 * gi + 5); gi++; } ); w.Append( "<br><a href='" + g.Link + "'><u>" + g.Title + "</u></a><br>Link: " + g.Link + "<br>Image: " + g.Image + "<br>" ); } t.htmlText = w.ToString(); } ); }
public ApplicationSprite() { //X:\jsc.svn\examples\actionscript\air\AIRThreadedSoundAsyncLoop\AIRThreadedSoundAsyncLoop\ApplicationSprite.cs var t = new TextField { multiline = true, //backgroundColor = 0xff000000u, //textColor = 0xffffffffu, autoSize = TextFieldAutoSize.LEFT, text = "..." // X:\jsc.svn\examples\actionscript\Test\TestWorkerConsole\TestWorkerConsole\ApplicationSprite.cs }.AttachToSprite().AsConsole(); Console.WriteLine(new { Thread.CurrentThread.ManagedThreadId }); t.click += async delegate { // X:\jsc.svn\examples\actionscript\Test\TestWorkerConsole\TestWorkerConsole\ApplicationSprite.cs var sw = Stopwatch.StartNew(); Console.WriteLine("enter click " + new { Thread.CurrentThread.ManagedThreadId, sw.ElapsedMilliseconds }); // http://blogs.msdn.com/b/dotnet/archive/2012/06/06/async-in-4-5-enabling-progress-and-cancellation-in-async-apis.aspx // Progress // Task of Click? // Dispatcher var x = await Task.Run( async delegate { Console.WriteLine("threaded click " + new { Thread.CurrentThread.ManagedThreadId }); // if we were to run physic in worker, // how would we update gpu? await Task.Delay(500); return "done"; } ); Console.WriteLine("exit click " + new { x, Thread.CurrentThread.ManagedThreadId, sw.ElapsedMilliseconds }); }; }
public ApplicationSprite() { // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2015/201505/20150502 // public var InternalOffsetMilliseconds:Number; // hello { InternalStart = 02.05.2015 11:54:23, diff = 00:00:00.0, InternalOffsetMilliseconds = NaN, offset = 00:00:00.NaN, Elapsed = 00:00:00.NaN, IsRunning = true, ElapsedMilliseconds = NaN } // didnt we fix it already? // jsc needs to init long fields! //InternalOffsetMilliseconds = 0 // ; var sw = Stopwatch.StartNew(); // hello {{ now = 14.04.2015 14:19:36, ElapsedMilliseconds = NaN }} // hello {{ now = 14.04.2015 14:20:26, IsRunning = true, ElapsedMilliseconds = NaN }} var InternalStart = DateTime.Now; var InternalStop = DateTime.Now; // public var InternalOffsetMilliseconds:Number; var diff = (InternalStop - InternalStart); // hello {{ InternalStart = 14.04.2015 14:22:16, diff = 00:00:00.0, IsRunning = true, ElapsedMilliseconds = NaN }} var offset = TimeSpan.FromMilliseconds(InternalOffsetMilliseconds); // hello {{ InternalStart = 14.04.2015 14:28:56, diff = 00:00:00.0, InternalOffsetMilliseconds = NaN, offset = 00:00:00.NaN, Elapsed = 00:00:00.NaN, IsRunning = true, ElapsedMilliseconds = NaN }} // hello {{ InternalStart = 14.04.2015 14:24:20, diff = 00:00:00.0, offset = 00:00:00.NaN, Elapsed = 00:00:00.NaN, IsRunning = true, ElapsedMilliseconds = NaN }} var Elapsed = diff + offset; // hello {{ ElapsedMilliseconds = NaN }} var t = new TextField { multiline = true, autoSize = TextFieldAutoSize.LEFT, text = "hello " + new { InternalStart, diff, InternalOffsetMilliseconds, offset, Elapsed, sw.IsRunning, sw.ElapsedMilliseconds } }; t.AttachToSprite(); }
/// <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(); } ); } ); }
public Application() { var cloud = new TheCloudEffect(0); cloud.AttachTo(this); var cloud2 = new TheCloudEffect(1); cloud2.AttachTo(this); var t = new TextField { width = 600, height = 400, x = 20, y = 20, defaultTextFormat = new TextFormat { size = 60, color = 0xff, font = "Verdana" }, text = "powered by jsc", filters = new BitmapFilter[] { new DropShadowFilter() }, }.AttachTo(this); var r = new Sprite { alpha = 0.5}.AttachTo(this); r.graphics.beginFill(0); r.graphics.drawRect(97, 0, 122 - 97, 500); this.mouseMove += e => { var x = Convert.ToInt32(e.stageX); t.text = "x: " + x; if (InRange(x)) { cloud.visible = false; cloud2.visible = true; } else { cloud2.visible = false; cloud.visible = true; } }; //KnownEmbeddedResources.Default["assets/ConditionalBranch/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200); }
// import TestFlashAnonymousType.ApplicationSprite.__f__AnonymousType_44_0_1; // X:\jsc.svn\examples\actionscript\Test\TestAnonymousType\TestAnonymousType\Class1.cs // V:\web\TestFlashAnonymousType\ApplicationSprite.as(38): col: 31 Error: Call to a possibly undefined method __f__AnonymousType_44_0_1. // field1.text = new __f__AnonymousType_44_0_1("hello there").toString(); // ^ //V:\web\TestFlashAnonymousType\ApplicationSprite.as(15): col: 52 Error: Definition TestFlashAnonymousType.ApplicationSprite:__f__AnonymousType_44_0_1 could not be found. // import TestFlashAnonymousType.ApplicationSprite.__f__AnonymousType_44_0_1; // ^ public ApplicationSprite() { var x = new TextField { // if i change one line, // could we let the running apps know of the change? text = new { foo = "hello there" }.ToString() }; // would the new know which sprite is creating it? x.AttachToSprite(); }
/// <summary> /// Default constructor /// </summary> public FlashVideo() { this.InvokeWhenStageIsReady( delegate { var flv = new FLVPlayback(); flv.width = 320; flv.height = 240; this.addChild(flv); // this should work: // http://www.flashcomguru.com/apps/flex/flvplayback/flvpb.html // http://www.flashcomguru.com/apps/flex/flvplayback/srcview/ //flv.skin = "assets/FlashVideo/steel.swf"; // http://theflashblog.com/?p=129 // http://blogs.adobe.com/accessibility/2006/10/captionskins.html // http://flashdevelop.org/community/viewtopic.php?t=1779 // C:\work\jsc.svn\examples\actionscript\FlashVideo\FlashVideo\bin\Release\web\FlashVideo\ActionScript\FlashVideo.as(21): // col: 30 Error: Type was not found or was not a compile-time constant: FLVPlayback. // var flv:fl.video.FLVPlayback; // http://www.flashcomguru.com/index.cfm/2007/4/17/Flex-Builder-2-to-write-AS3-code-for-Flash // http://www.kirupa.com/forum/showthread.php?p=2450954 // ...this doesnt seem to be supported yet // http://yourpalmark.com/2008/04/30/flvplayback-directly-in-flex/ // http://blog.flexexamples.com/2008/12/11/using-the-flash-flvplayback-control-in-flex/ // download here: // http://kb2.adobe.com/cps/406/kb406018.html //flv.AttachTo(this); flv.play("http://v9.lscache3.googlevideo.com/videoplayback?ip=0.0.0.0&sparams=id%2Cexpire%2Cip%2Cipbits%2Citag%2Cburst%2Cfactor&itag=5&ipbits=0&signature=52263C98A206203E7A6ADD4D2100DE1150EF9C09.9840C4F946309D368AB946AB0371D8455743E2E2&sver=3&expire=1247853600&key=yt1&factor=1.25&burst=40&id=6be88f6d5fff3db0"); var t = new TextField { text = "powered by jsc", background = true, x = 20, y = 40, alwaysShowSelection = true, }.AttachTo(this); KnownEmbeddedResources.Default[KnownAssets.Path.Assets + "/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200); } ); }
/// <summary> /// Default constructor /// </summary> public RuntimeSharedLibraryForAssets() { //for (var j = 0.0; j < 1; j += 0.1) //{ // this.graphics.beginFill(0xff0000, j); // this.graphics.drawCircle(40, 40, 40 * (1.0 - j)); // this.graphics.endFill(); //} //var step = 100; //for (int i = 0; i < 4; i++) //{ // addChild( // new TextField // { // text = "hello world", // x = step * i, // y = 20, // textColor = 0x00ff00, // sharpness = 400 // }); //} var t = new TextField { text = "powered by jsc", x = 20, y = 40, selectable = false, sharpness = -400, textColor = 0xffffff }.AttachTo(this); //var a = ((Class)getDefinitionByName("SomeGenericAssets.ActionScript.Assets")).CreateType(); // http://books.google.ee/books?id=r4Xl06bwKyAC&pg=PA21&lpg=PA21&dq=flex+file-specs&source=web&ots=9ELbZmqKep&sig=1uUN7L-T-xzqW8PHI6Hv1ImhxCU&hl=et&sa=X&oi=book_result&resnum=1&ct=result#PPA32,M1 // http://www.nabble.com/Bizarre-link-report-and-load-externs-problems-in-FB3-plugin-td15904495.html // http://livedocs.adobe.com/flex/3/html/help.html?content=rsl_02.html#220679 t.click += delegate { var a = new SomeGenericAssets.ActionScript.Assets(); a[SomeGenericAssets.ActionScript.Assets.Path + "/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200); }; }
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(); }; }
public UltraSprite() { this.graphics.beginFill(0xffffff); this.graphics.drawRect(0, 0, DefaultWidth, DefaultHeight); this.graphics.lineStyle(2, 0xa0, 1); this.graphics.beginFill(0xffffff, 0); this.graphics.drawRect(0, 0, DefaultWidth, DefaultHeight); t = new TextField { width = DefaultWidth, height = DefaultHeight }; t.AttachTo(this); this.AppendLine("This is flash.display.Sprite (version 101)"); var Button1 = new Sprite(); Button1.graphics.beginFill(0xff00); Button1.graphics.drawRect(0, 0, 64, 24); Button1.useHandCursor = true; Button1.buttonMode = true; Button1.AttachTo(this).MoveTo(DefaultWidth - 64 - 8, 8); Button1.click += delegate { // jsc.meta should use Convert type for us if (Convert.ToBoolean(this.WebServiceEnabled.IsEnabled)) { this.WebService.GetTime("[flash client time]: " + DateTime.Now + " [server time]", x => { this.AppendLine(x); } ); } else { this.AppendLine("WebService is disabled!"); } }; }
// X:\jsc.svn\examples\actionscript\FlashWorkerExperiment\FlashWorkerExperiment\ApplicationSprite.cs // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201403/20140301 public ApplicationSprite() { // when can we do this? //BCL needs another method, please define it. //Cannot call type without script attribute : //System.Threading.Tasks.Task for System.Threading.Tasks.TaskFactory get_Factory() used at //AsyncWorkerTask.ApplicationSprite..ctor at offset 0010. var a = Task.Factory.StartNew( state: new { goo = "foo " }, function: scope => { // notice that jsc might need to inject serialization logic here return "hello " + new { scope.goo }; } ); a.ContinueWithResult( r => { var t = new TextField { text = new { r, WorkerDomain = WorkerDomain.isSupported, Worker = Worker.isSupported, Worker.current.isPrimordial, this.loaderInfo.bytes.length }.ToString(), autoSize = TextFieldAutoSize.LEFT }; t.AttachTo(this); } ); }
public UltraSprite() { this.graphics.beginFill(0xffffff); this.graphics.drawRect(0, 0, DefaultWidth, DefaultHeight); this.graphics.lineStyle(2, 0xa0, 1); this.graphics.beginFill(0xffffff, 0); this.graphics.drawRect(0, 0, DefaultWidth, DefaultHeight); t = new TextField { width = DefaultWidth, height = DefaultHeight }; t.AttachTo(this); this.AppendLine("This is flash.display.Sprite (version 101)"); }
/// <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); }
// this is also IElement ! public ApplicationSprite() { // X:\jsc.svn\core\ScriptCoreLib.Avalon\ScriptCoreLib.Avalon\ActionScript\BCLImplementation\System\Windows\Controls\TextBox.cs //var x = new TextField { text = "hello world" }.AttachTo(this); var x = new TextField { type = TextFieldType.INPUT, text = "hello world" }.AttachTo(this); x.change += delegate { // time to let the DOM know if (xChanged != null) xChanged(x.text); }; }
public ApplicationSprite() { // see also: http://zproxy.wordpress.com/2009/05/29/using-flint-particle-system-from-jsc/ bitmap = new ActionScript.Images._184098(); renderer = new DisplayObjectRenderer(); renderer.camera.dolly(-400); renderer.camera.projectionDistance = 400; //renderer.y = 175; renderer.y = 0; renderer.x = 250; addChild(renderer); emitter = new Emitter3D(); emitter.addAction(new Move()); emitter.addAction(new DeathZone(new FrustrumZone(renderer.camera, new ScriptCoreLib.ActionScript.flash.geom.Rectangle(-2900, -2150, 5800, 4300)), true)); emitter.position = new Vector3D(0, 0, 0, 1); var __JSC_should_detect_element_type_for_Vector_of_Particle = default(Particle); var particles = Particle3DUtils.createRectangleParticlesFromBitmapData( bitmap.bitmapData, 20, emitter.particleFactory, new Vector3D(-192, 127, 0) ); emitter.addParticles(particles, false); renderer.addEmitter(emitter); emitter.start(); stage.click += explode; var txt = new TextField(); txt.text = "Click on the image"; addChild(txt); }
/// <summary> /// Default constructor /// </summary> public CRCExample() { var t = new TextField { text = "powered by jsc", background = true, x = 20, y = 40, alwaysShowSelection = true, }.AttachTo(this); var crc = new Crc32Helper(); crc.ComputeCrc32(new byte[] { 1, 2, 0xfe, 0xff }); // Crc32Value = 1027690409 t.text = "" + crc.Crc32Value + " vs 1027690409"; }
// https://sites.google.com/a/jsc-solutions.net/work/knowledge-base/15-dualvr/20151115/audio /// <summary> /// Default constructor /// </summary> public MP3PitchExample() { // http://blog.andre-michelle.com/upload/mp3pitch/MP3Pitch.as // http://blog.andre-michelle.com/2009/pitch-mp3/ var Rate = new TextField { text = "1.0" }.AttachTo(this); var p = new MP3Pitch("http://visit.abstractatech.com/assets/com.abstractatech.web.design1/AbstractatechPostProductionVersion7.mp3"); var o = new Sprite { }.AttachTo(this); o.click += delegate { p = new MP3Pitch("http://visit.abstractatech.com/assets/com.abstractatech.web.design1/AbstractatechPostProductionVersion7.mp3") { _rate = p._rate }; }; o.graphics.beginFill(0x0, 0.5); o.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight); o.mouseMove += e => { var rate = (e.stageX / this.stage.stageWidth) * 2; p._rate = rate; Rate.text = "" + rate; }; //KnownEmbeddedResources.Default["assets/MP3PitchExample/Preview.png"].ToBitmapAsset().AttachTo(this).MoveTo(100, 200); }
public void TestMethod1() { var a = YAMLDocument.WriteMappingsSequence( typeof(TestMethod1_Type), new TestMethod1_Type { Field1 = "1", Field2 = "2" }, new TestMethod1_Type { Field1 = "3", Field2 = "4" } ); var t = new TextField { multiline = true, text = a, width = 400, height = 400 }.AttachTo(this); var n = (TestMethod1_Type[]) YAMLDocument.FromMappingsSequence( typeof(TestMethod1_Type), a ); Trace.Assert(n[0].Field1 == "1"); Trace.Assert(n[0].Field2 == "2"); Trace.Assert(n[1].Field1 == "3"); Trace.Assert(n[1].Field2 == "4"); }
/// <summary> /// Default constructor /// </summary> public Sudoku() { var t = new SudokuFile(Assets.Level1.ToStringAsset()); t.Mappings.Randomize(); const int padding = 2; const int w = 28; const int h = 28; for (int y = 1; y < 10; y++) for (int x = 1; x < 10; x++) { var s = new Sprite(); var text = new TextField { text = t[x, y].ToString(), mouseEnabled = false }.AttachTo(s); text.autoSize = TextFieldAutoSize.LEFT; text.x = -text.width / 2; text.y = -text.height / 2; s.graphics.lineStyle(3, 0xff5300, 1); s.graphics.drawRect(-w / 2, -h / 2, w, h); // s.filters = new[] { new BevelFilter() }; s.x = (w + padding) * x; s.y = (h + padding) * y; s.AttachTo(this); } }
public ApplicationSprite() { this.InvokeWhenStageIsReady( () => { var t = new TextField { multiline = true, //backgroundColor = 0xff000000u, //textColor = 0xffffffffu, autoSize = TextFieldAutoSize.LEFT, text = "..." // X:\jsc.svn\examples\actionscript\Test\TestWorkerConsole\TestWorkerConsole\ApplicationSprite.cs }.AttachToSprite().AsConsole(); content.AttachToContainer(this); content.AutoSizeTo(this.stage); } ); }
public ApplicationSprite() { // http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7e15.html //this.stage.opaqueBackground = 0xff; //this.opaqueBackground = 0xff; // X:\jsc.svn\examples\actionscript\async\Test\TestAsyncTaskRun\TestAsyncTaskRun\ApplicationSprite.cs var t = new TextField { text = "before" }.AttachTo(this); Console.SetOut( new __OutWriter { AtWriteLine = x => { //t.text = x; if (AtWriteLine == null) { __pending += x + "\n\r"; } else { AtWriteLine(__pending + x); __pending = ""; } } } ); // C:\Windows\system32\Macromed\Flash\NPSWF64_15_0_0_189.dll Console.WriteLine(@"hello!"); new { t }.With( async scope => { // X:\jsc.svn\examples\actionscript\test\TestResolveNativeImplementationExtension\TestResolveNativeImplementationExtension\Class1.cs while (true) { await t.async.onclick; Console.WriteLine("after t.async.onclick"); t.text = "enter async"; // do we have timers in bg thread? await Task.Delay(500); t.text = "in async"; await Task.Delay(500); t.text = "exit async"; } } ); //t.click += async delegate //{ // Console.WriteLine(@"see C:\Users\arvo\AppData\Roaming\Macromedia\Flash Player\Logs"); // //Console.WriteLine("enter async"); // t.text = "enter async"; // await Task.Delay(500); // t.text = "in async"; // await Task.Delay(500); // t.text = "exit async"; //}; }
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 }
//[Script(IsDebugCode = true)] private static void AddInfo(Sprite InfoMenu, double y, Actor v) { v.CanMakeFootsteps = false; var h = new Sprite(); Action<uint> Draw = color => { h.graphics.clear(); h.graphics.beginFill(color, 0.5); h.graphics.drawRect(-32, -32, 64, 64); h.graphics.endFill(); //h.graphics.lineStyle(1, 0x808080, 0.8); //h.graphics.drawRect(-32, -32, 64, 64); h.graphics.beginFill(color, 0.5); h.graphics.drawRect(48, -32, 180, 64); h.graphics.endFill(); //h.graphics.lineStyle(1, 0x808080, 0.8); //h.graphics.drawRect(48, -32, 180, 64); }; Draw(ColorBlueLight); h.click += delegate { if (0.5.ByChance()) { if (v.PlayHelloSound != null) v.PlayHelloSound(); } else { if (v.PlayDeathSound != null) v.PlayDeathSound(); } }; h.mouseChildren = false; //h.filters = new[] { new GlowFilter(0x808080) }; h.mouseOver += e => Draw(ColorBlue); h.mouseOut += e => Draw(ColorBlueLight); var t = new TextField { x = 64, text = v.ActorName + "\n" + v.ScoreValue + " points\n" + v.Description, autoSize = TextFieldAutoSize.LEFT, }.AttachTo(h); t.y -= t.height / 2; v.AttachTo(h); h.AttachTo(InfoMenu).MoveTo(0, y); }
internal void Initialize() { var c = NonobaAPI.MakeMultiplayer(stage //, "192.168.3.102" //, "192.168.1.119" ); #region Messages var ActiveMessages = new List<TextField>(); var ShowMessageNow = default(Action<string, Action>); ShowMessageNow = (MessageText, Done) => { var p = new TextField { textColor = ColorWhite, background = true, backgroundColor = ColorBlack, filters = new[] { new GlowFilter(ColorBlack) }, autoSize = TextFieldAutoSize.LEFT, text = MessageText, mouseEnabled = false }; var y = DefaultControlHeight - p.height - 32; p.AddTo(ActiveMessages).AttachTo(this).MoveTo((DefaultControlWidth - p.width) / 2, DefaultControlHeight); Sounds.snd_message.ToSoundAsset().play(); var MessagesToBeMoved = (from TheMessage in ActiveMessages select new { TheMessage, y = TheMessage.y - TheMessage.height }).ToArray(); (1000 / 24).AtInterval( t => { foreach (var i in MessagesToBeMoved) { if (i.TheMessage.y > i.y) i.TheMessage.y -= 4; } p.y -= 4; if (p.y < y) { t.stop(); if (Done != null) Done(); 500.AtDelayDo( delegate { p.alpha = 0.5; } ); 9000.AtDelayDo( () => p.RemoveFrom(ActiveMessages).FadeOutAndOrphanize(1000 / 24, 0.21) ); } } ); }; var QueuedMessages = new Queue<string>(); this.ShowMessage = Text => { if (QueuedMessages.Count > 0) { QueuedMessages.Enqueue(Text); return; } // not busy QueuedMessages.Enqueue(Text); var NextQueuedMessages = default(Action); NextQueuedMessages = () => ShowMessageNow(QueuedMessages.Peek(), delegate { QueuedMessages.Dequeue(); if (QueuedMessages.Count > 0) NextQueuedMessages(); } ); NextQueuedMessages(); }; #endregion var MyEvents = new SharedClass1.RemoteEvents(); Events = MyEvents; Messages = new SharedClass1.RemoteMessages { Send = e => SendMessage(c, e.i, e.args) }; this.InitializeEvents(); #region Dispatch Func<Message, bool> Dispatch = e => { var type = (SharedClass1.Messages)int.Parse(e.Type); if (MyEvents.Dispatch(type, new SharedClass1.RemoteEvents.DispatchHelper { GetLength = i => e.length, GetInt32 = e.GetInt, GetDouble = e.GetNumber, GetString = e.GetString, } )) return true; return false; }; #endregion #region message c.Message += e => { InitializeMap(); var Dispatched = false; try { Dispatched = Dispatch(e.message); } catch (Exception ex) { System.Console.WriteLine("error at dispatch " + e.message.Type); throw ex; } if (Dispatched) return; System.Console.WriteLine("not on dispatch: " + e.message.Type); }; #endregion c.Disconnect += delegate { ShowMessage("Disconnected!"); }; c.Init += delegate { InitializeMap(); }; }