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); }
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); } }; }
/// <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); }
public ApplicationSprite() { // X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\ApplicationSprite.cs // jsc should return before getting here from the worker if (!Worker.current.isPrimordial) return; var t = new TextField { multiline = true, text = new { __Thread.InternalPrimordialSprite, this.loaderInfo.bytes.length, }.ToString(), autoSize = TextFieldAutoSize.LEFT }; t.AttachTo(this); t.click += delegate { var sw = Stopwatch.StartNew(); t.text = "enter click"; __Thread tt = new Thread( new ParameterizedThreadStart( data => { // can we render audio on the background thread now? // what else can AIR do on a background thread? // physics? // LAN calc? // how can we report to the UI thread? var nn = Stopwatch.StartNew(); int i = 0; // keep core2 buzy for a while to be noticed on the task manager while (nn.ElapsedMilliseconds < 10000) { SharedField = new { data, i, nn.ElapsedMilliseconds //, Thread.CurrentThread.ManagedThreadId }.ToString(); i++; } // i wonder, can we switch to UI thread via await and then back? var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker"); // or are we to capture all fields modified within worker and only update those? xfromWorker.send("message from worker " + new { SharedField }); // how do we signal our work is done? } ) ); tt.InternalBeforeStart = w => { // how are we supposed to get data back from the worker? var fromWorker = w.createMessageChannel(Worker.current); w.setSharedProperty("fromWorker", fromWorker); fromWorker.channelMessage += e => { var data = (string)fromWorker.receive(); t.appendText( "\n " + new { sw.ElapsedMilliseconds, data }.ToString() ); }; }; //Thread.AllocateNamedDataSlot(""). //Thread.SetData( tt.Start("hello world"); }; }
public ApplicationSprite() { // http://www.yeahbutisitflash.com/?p=5469 // http://forums.adobe.com/message/5745066 // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2013/201310/20131006-air //System.ArgumentException: Parameter count does not match passed in argument value count. // ReferenceError: Error #1065: Variable flash.system::WorkerDomain is not defined. //at FlashWorkerExperiment::ApplicationSprite()[S:\web\FlashWorkerExperiment\ApplicationSprite.as:31] //{ isSupported = true } // http://esdot.ca/site/2012/intro-to-as3-workers-hello-world // The swf version should be 22 and above. // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Worker.html // For mobile platforms, concurrency is supported in AIR on Android but not in AIR on iOS. // You can use the static isSupported property to check whether concurrency is supported before attempting to use it. if (Worker.current.isPrimordial) { //{ os = Windows 7, version = WIN 13,0,0,133, WorkerDomain = true, Worker = true, isPrimordial = true, length = 519498 } // before start // after start { w = [object Worker] } // main: { i = 0, isPrimordial = true, current = true } // { data = ready? // in worker: { i = 0, isPrimordial = false, current = true } // in worker: { i = 1, isPrimordial = true, current = false } }click! // { data = hi from worker { data = hi from UI } } // http://forums.adobe.com/thread/1171498 var t = new TextField { text = new { // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html Capabilities.os, Capabilities.version, WorkerDomain = WorkerDomain.isSupported, Worker = Worker.isSupported, Worker.current.isPrimordial, this.loaderInfo.bytes.length }.ToString(), autoSize = TextFieldAutoSize.LEFT }; t.AttachTo(this); //this.stage.loaderInfo.uncaughtErrorEvents.uncaughtError += this.loaderInfo.uncaughtErrorEvents.uncaughtError += e => { // http://www.adobe.com/support/flashplayer/downloads.html t.appendText( new { e.errorID, e.text, e.error }.ToString() ); }; if (WorkerDomain.isSupported) { // http://jacksondunstan.com/articles/1968 // "C:\util\flex_sdk_4.6\frameworks\libs\player\11.9\playerglobal.swc" // "C:\util\air3-9_sdk_sa_win\frameworks\libs\player\11.9\playerglobal.swc" // "C:\util\air13_sdk_win\frameworks\libs\player\13.0\playerglobal.swc" // can we create natives of it yet? // call c:\util\jsc\bin\jsc.meta.exe RewriteToActionScriptNatives /SWCFiles:"C:\util\flex_sdk_4.6\frameworks\libs\player\11.1\playerglobal.swc" /SWCFiles:"C:\util\flex_sdk_4.6\frameworks\libs\framework.swc" /SWCFiles:"C:\util\flex_sdk_4.6\frameworks\libs\mx\mx.swc" /OutputAssembly:c:\util\jsc\bin\ScriptCoreLib.ActionScript.Natives.dll /DisableResolveExternalType:true /DisableWorkerDomain // call c:\util\jsc\bin\jsc.meta.exe RewriteToActionScriptNatives /SWCFiles:"C:\util\air13_sdk_win\frameworks\libs\player\13.0\playerglobal.swc" /SWCFiles:"C:\util\flex_sdk_4.6\frameworks\libs\framework.swc" /SWCFiles:"C:\util\flex_sdk_4.6\frameworks\libs\mx\mx.swc" /OutputAssembly:c:\util\jsc\bin\ScriptCoreLib.ActionScript.AIRNatives.dll /DisableResolveExternalType:true /DisableWorkerDomain // should flash natives gen get a copy of the playerglobal and use it instead? // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/WorkerDomain.html var w = WorkerDomain.current.createWorker( this.loaderInfo.bytes ); // http://jacksondunstan.com/articles/2401 // channel1 = WorkerDomain.current.createMessageChannel(worker0); var toWorker = Worker.current.createMessageChannel(w); var fromWorker = w.createMessageChannel(Worker.current); // http://esdot.ca/site/2012/intro-to-as3-workers-hello-world w.setSharedProperty("toWorker", toWorker); w.setSharedProperty("fromWorker", fromWorker); // http://jcward.com/AIR+3.9+Workers+Beta fromWorker.channelMessage += e => { var data = (string)fromWorker.receive(); t.appendText( "\n " + new { data }.ToString() ); }; t.appendText( "\n before start" ); // { isSupported = true, isPrimordial = true, length = 485141 } w.start(); t.appendText( "\n after start " + new { w } ); var list = WorkerDomain.current.listWorkers(); for (int i = 0; i < list.length; i++) { t.appendText( "\n main: " + new { i, list[i].isPrimordial, current = list[i] == Worker.current } ); } t.click += delegate { t.appendText( "click!" ); toWorker.send("hi from UI"); }; } } else { var toWorker = (MessageChannel)Worker.current.getSharedProperty("toWorker"); // VerifyError: Error #1014: Class flash.system::Worker could not be found. //WorkerDomain = true, Worker = true, isPrimordial = true, length = 517003 } //before start //after start { w = [object Worker] }{ data = ready? }click!{ data = hi from worker { data = hi from UI } } // http://forums.adobe.com/thread/1411606?tstart=0 //Mobile Workers (concurrency) - Android //Introduced as a beta feature in AIR 3.9, we've continued to improve this feature based on your feedback for its official release in AIR 4. // what about automagic sync, jsc detects and marks such properties? var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker"); if (xfromWorker != null) { var w = new StringBuilder(); //{ WorkerDomain = true, Worker = true, isPrimordial = true, length = 519030 } // before start // after start { w = [object Worker] } // main: { i = 0, isPrimordial = true, current = true } // { data = ready? // in worker: { i = 0, isPrimordial = false, current = true } // in worker: { i = 1, isPrimordial = true, current = false } }click! // { data = hi from worker { data = hi from UI } }click! // { data = hi from worker { data = hi from UI } } var list = WorkerDomain.current.listWorkers(); for (int i = 0; i < list.length; i++) { w.Append( "\n in worker: " + new { i, list[i].isPrimordial, current = list[i] == Worker.current } ); } xfromWorker.send("ready? " + w.ToString()); } toWorker.channelMessage += e => { var data = (string)toWorker.receive(); // now what? xfromWorker.send("hi from worker " + new { data }); }; } }
private void InitializeWriteLine() { // show fps var fps = new TextField { textColor = 0xff0000, x = DefaultControlWidth / 2 }.AttachTo(this).Do(t => EgoView.FramesPerSecondChanged += () => t.text = "fps: " + EgoView.FramesPerSecond); var dumperbg = new Shape().AttachTo(this); dumperbg.graphics.beginFill(0, 0.5); dumperbg.graphics.drawRect(0, DefaultControlHeight / 4, DefaultControlWidth, DefaultControlHeight / 2); var dumper = new TextField { width = DefaultControlWidth, height = DefaultControlHeight / 2, textColor = 0xffff00, mouseEnabled = false, y = DefaultControlHeight / 4, }.AttachTo(this); WriteLineControl = dumper; var dumper_queue = new Queue<string>(); Action Update = delegate { dumper.text = ""; foreach (var v in dumper_queue) { dumper.appendText(v + Environment.NewLine); }; }; WriteLine = text => { dumper_queue.Enqueue(text); while (dumper_queue.Count > 10) dumper_queue.Dequeue(); if (dumper.visible) Update(); }; BooleanProperty CheatMode = true; CheatMode.ValueChangedTo += value => { dumperbg.visible = value; dumper.visible = value; fps.visible = value; Keyboard_Cheats.Enabled = value; }; if (global::ScriptCoreLib.ActionScript.flash.system.Capabilities.isDebugger) { var ButtonT = new KeyboardButton(stage) { Groups = new[] { MovementArrows[Keyboard.T], }, Up = CheatMode.Toggle }; this.EgoView.WriteLine = this.WriteLine; } CheatMode.Toggle(); }
public ApplicationSprite() { //__Thread.InternalWorkerInvoke_4ebbe596_06000030(this); //this.__out_Method_6d788eff_06000003(); // "X:\jsc.svn\examples\actionscript\async\AsyncWorkerTask\AsyncWorkerTask.sln" // X:\jsc.svn\examples\actionscript\async\AsyncWorkerTask\AsyncWorkerTask\ApplicationSprite.cs // X:\jsc.svn\examples\actionscript\FlashWorkerExperiment\FlashWorkerExperiment\ApplicationSprite.cs // https://forums.adobe.com/thread/1164500 // this looks like chrome context capture #region worker if (!Worker.current.isPrimordial) { var sw = Stopwatch.StartNew(); // iOS workers is still on the roadmap. I don't have a release date, but I know it'll be an extended beta type of feature. // Most of the concurrency work was gated on the new AOT compiler work, which is still being actively worked on. // Lots of bug and performance fixes were added to AIR 15 and we're not stopping there. var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker"); var FunctionToken_TypeFullName = (string)Worker.current.getSharedProperty("FunctionToken_TypeFullName"); var FunctionToken_MethodName = (string)Worker.current.getSharedProperty("FunctionToken_MethodName"); var arg0 = (string)Worker.current.getSharedProperty("arg0"); // enter click //{ { data = message from worker { { FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, FunctionToken_MethodName = Invoke_6d788eff_0600001c } }, ElapsedMilliseconds = 1713 } } IntPtr pp = __IntPtr.OfFunctionToken(null, FunctionToken_TypeFullName, FunctionToken_MethodName ); MethodInfo mm = new __MethodInfo { _Method = pp }; // t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds }; //xfromWorker.send("message from worker " + new { FunctionToken_TypeFullName, FunctionToken_MethodName }); //throw null; mm.Invoke(null, new object[] { arg0 }); // enter click //{ { ElapsedMilliseconds = 3103, data = message from worker { { ElapsedMilliseconds = 3057, SharedField = { { data = null, i = 65534, j = 3 } } } } } } // {{ ElapsedMilliseconds = 3399, data = message from worker {{ ElapsedMilliseconds = 3352, SharedField = {{ data = hello world, i = 65534, j = 3 }} }} }} xfromWorker.send("message from worker " + new { sw.ElapsedMilliseconds, TheOtherClass.SharedField }); return; } #endregion // {{ os = Windows 7, version = WIN 15,0,0,189, length = 333983, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , FunctionToken = function Function() {}, ClassToken = } } }} // start0 = new __ParameterizedThreadStart(null, __IntPtr.op_Explicit_4ebbe596_06001686(TheOtherClass.Invoke_6d788eff_0600000c)); // start0 = new __ParameterizedThreadStart(null, __IntPtr.OfFunctionToken_4ebbe596_06001687(TheOtherClass.Invoke_6d788eff_0600000c,"TestThreadStart.TheOtherClass","Invoke_6d788eff_0600000c")); ParameterizedThreadStart y = TheOtherClass.Invoke; // can we call the method // 0007 0200034c ScriptCoreLib::ScriptCoreLib.ActionScript.Extensions.ZipFileEntry + Cookie`1 //Unhandled Exception: System.AggregateException: One or more errors occurred. --->System.InvalidOperationException: internal compiler error at method // assembly: X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\bin\Debug\ScriptCoreLib.dll at // type: ScriptCoreLib.ActionScript.BCLImplementation.System.__Single, ScriptCoreLib, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null // method: CompareTo // Object reference not set to an instance of an object. // at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) // at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value) // at jsc.Script.CompilerBase. . (Type , MethodBase , LocalVariableInfo , CompilerBase ) // at jsc.Script.CompilerBase.<WriteVariableName>b__0(Type , MethodBase , LocalVariableInfo ) // Unhandled Exception: System.AggregateException: One or more errors occurred. --->System.InvalidOperationException: internal compiler error at method //assembly: X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\bin\Debug\ScriptCoreLib.dll at //type: ScriptCoreLib.ActionScript.BCLImplementation.System.__BitConverter, ScriptCoreLib, Version=4.5.0.0, Culture=neutral, PublicKeyToken=null //method: GetBytes //Object reference not set to an instance of an object. // at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) // at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value) // at jsc.Script.CompilerBase. . (Type , MethodBase , LocalVariableInfo , CompilerBase ) //{{ os = Windows 7, version = WIN 15,0,0,189, length = 334356, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , FunctionToken = function Function() {}, ClassToken = } }, z = Type { TypeDescription = // <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true"> // <extendsClass type="Class"/> // <extendsClass type="Object"/> // <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/> // <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void"> // <parameter index="1" type="Object" optional="false"/> // </method> // <factory type="TestThreadStart::TheOtherClass"> // <extendsClass type="Object"/> // </factory> //</type> } }} // {{ os = Windows 7, version = WIN 15,0,0,189, length = 334570, Target = null, Method = { _Target = , _Method = IntPtr { StringToken = , //FunctionToken = function Function() {}, ClassToken = } }, FullName = TestThreadStart::TheOtherClass, z = Type { TypeDescription = <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true"> // <extendsClass type="Class"/> // <extendsClass type="Object"/> // <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/> // <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void"> // <parameter index="1" type="Object" optional="false"/> // </method> // <factory type="TestThreadStart::TheOtherClass"> // <extendsClass type="Object"/> // </factory> //</type> }, zz = Type { TypeDescription = <type name="TestThreadStart::TheOtherClass" base="Class" isDynamic="true" isFinal="true" isStatic="true"> // <extendsClass type="Class"/> // <extendsClass type="Object"/> // <accessor name="prototype" access="readonly" type="*" declaredBy="Class"/> // <method name="Invoke_6d788eff_0600000c" declaredBy="TestThreadStart::TheOtherClass" returnType="void"> // <parameter index="1" type="Object" optional="false"/> // </method> // <factory type="TestThreadStart::TheOtherClass"> // <extendsClass type="Object"/> // </factory> //</type> } }} //var z = typeof(TheOtherClass); //var zz = Type.GetType("TestThreadStart::TheOtherClass"); //var zz = Type.GetType("TestThreadStart.TheOtherClass"); //var zMethod = z.GetMethods(); __MethodInfo p = y.Method; //{ { os = Windows 7, version = WIN 15,0,0,189, length = 335268, // FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, // FunctionToken_MethodName = Invoke_6d788eff_0600000c // } } //var pt = Type.GetType(p._Method.FunctionToken_TypeFullName); //new ParameterizedThreadStart(null, pp); //new Delegate(); var t = new TextField { multiline = true, //wordWrap = true, // {{ InternalPrimordialSprite = null, os = Windows 7, version = WIN 15,0,0,189, length = 353988, FunctionToken_TypeFullName = TestThreadStart.TheOtherClass, FunctionToken_MethodName = Invoke_6d788eff_06000016 }} text = new { // did the compiler set it yet? __Thread.InternalPrimordialSprite, // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html Capabilities.os, Capabilities.version, //WorkerDomain = WorkerDomain.isSupported, //Worker = Worker.isSupported, //Worker.current.isPrimordial, this.loaderInfo.bytes.length, // {{ os = Windows 7, version = WIN 15,0,0,189, length = 333411, Target = null, Method = { InternalFunctionPointer = function Function() {} } }} //y.Target, // first step is to call a static method on the other side of thread //y.Method, //y.Method, //y.Method.DeclaringType //z.FullName, //z, p._Method.FunctionToken_TypeFullName, p._Method.FunctionToken_MethodName, }.ToString(), autoSize = TextFieldAutoSize.LEFT }; t.AttachTo(this); t.click += delegate { var sw = Stopwatch.StartNew(); t.text = "enter click"; var w = WorkerDomain.current.createWorker( this.loaderInfo.bytes ); //p._Method.FunctionToken_TypeFullName, //p._Method.FunctionToken_MethodName w.setSharedProperty("FunctionToken_TypeFullName", p._Method.FunctionToken_TypeFullName); w.setSharedProperty("FunctionToken_MethodName", p._Method.FunctionToken_MethodName); w.setSharedProperty("arg0", "hello world"); var fromWorker = w.createMessageChannel(Worker.current); w.setSharedProperty("fromWorker", fromWorker); fromWorker.channelMessage += e => { var data = (string)fromWorker.receive(); t.appendText( "\n " + new { sw.ElapsedMilliseconds, data }.ToString() ); }; t.text = "enter click"; w.start(); //try //{ // // catch {{ err = ArgumentError: Error #1063: Argument count mismatch on TestThreadStart::TheOtherClass$/Invoke_6d788eff_06000013(). Expected 1, got 0. }} // mm.Invoke(null, new object[1]); // t.text = "after invoke " + new { TheOtherClass.SharedField, sw.ElapsedMilliseconds }; //} //catch (Exception err) //{ // t.text = "catch " + new { err }; //} }; }
// X:\util\air17_sdk_sa_win // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201409/20140911 public ApplicationSprite() { // X:\jsc.svn\examples\actionscript\air\AIRStageWebViewExperiment\AIRStageWebViewExperiment\ApplicationSprite.cs // http://stackoverflow.com/questions/3170585/get-ip-address-with-adobe-air-2 var t = new TextField { text = new { // http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/system/Capabilities.html Capabilities.os, Capabilities.version, Capabilities.playerType, //Error CS0117 'Capabilities' does not contain a definition for 'cpuArchitecture' AIRServerSocketExperiment X:\jsc.svn\examples\actionscript\air\AIRServerSocketExperiment\AIRServerSocketExperiment\ApplicationSprite.cs 29 #if FPARTIAL Capabilities.cpuArchitecture, Capabilities.touchscreenType, #endif // why is this commented out? //WorkerDomain = WorkerDomain.isSupported, // http://na5.brightidea.com/ct/ct_a_view_idea.bix?c=9D564F43-979A-4E35-AA21-85A61B6AB8DE&idea_id=F353B3CC-5F05-45E7-9A73-1093E0A1F9DD NetworkInfo = NetworkInfo.isSupported, //Worker.current.isPrimordial, this.loaderInfo.bytes.length }.ToString(), autoSize = TextFieldAutoSize.LEFT }; t.AttachTo(this); //V:\web\AIRServerSocketExperiment\ApplicationSprite.as(46): col: 127 Error: Implicit coercion of a value of type __AS3__.vec:Vector.<flash.net:NetworkInterface> to an unrelated type __AS3__.vec:Vector.<*>. // LinqExtensions.WithEach_f7a1155f_06000027(CommonExtensions.AsEnumerable_4ebbe596_06001850(NetworkInfo.networkInfo.findInterfaces()), new __Action_1(class21, __IntPtr.op_Explicit_4ebbe596_06001412("__ctor_b__1_f7a1155f_06000005"))); // ^ //{ os = Windows 7, version = WIN 13,0,0,133, playerType = Desktop, length = 489435 } // { name = {84D54A45-2ACC-42B2-A59B-E01D43897D2D}, displayName = Local Area Connection, active = false } // address { address = 169.254.45.8, broadcast = 169.254.255.255 } // { name = {978F5176-96B4-49D4-A14D-6CEA5CB3D505}, displayName = Bluetooth Network Connection, active = false } // address { address = 169.254.6.204, broadcast = 169.254.255.255 } // { name = {CE7A76DF-BCB0-4C3B-8466-D712A03F10A0}, displayName = Wireless Network Connection, active = true } // address { address = 192.168.43.252, broadcast = 192.168.43.255 } // { name = {846EE342-7039-11DE-9D20-806E6F6E6963}, displayName = Loopback Pseudo-Interface 1, active = true } // address { address = ::1, broadcast = } // address { address = 127.0.0.1, broadcast = } // { name = {A5178906-144E-433A-9103-B2EB62A4C21E}, displayName = Teredo Tunneling Pseudo-Interface, active = true } // address { address = 2001:0:9d38:6abd:28d1:36ea:3f57:d403, broadcast = } if (Capabilities.playerType == "Desktop") { // we dont want to crash flash player! // http://help.adobe.com/en_US/air/build/WS144092a96ffef7cc16ddeea2126bb46b82f-8000.html // VerifyError: Error #1014: Class flash.net::NetworkInterface could not be found. var ii = NetworkInfo.networkInfo.findInterfaces(); for (int ij = 0; ij < ii.length; ij++) { var i = ii[ij]; t.appendText("\n " + new { i.name, i.displayName, i.active }); var aa = i.addresses; for (int aj = 0; aj < aa.length; aj++) { var a = aa[aj]; t.appendText("\n address " + new { a.address, a.broadcast, a.ipVersion }); } } } //V:\web\AIRServerSocketExperiment\ApplicationSprite___c__DisplayClass3.as(28): col: 105 Error: // Implicit coercion of a value of type __AS3__.vec:Vector.<flash.net:InterfaceAddress> // to an unrelated type __AS3__.vec:Vector.<*>. // LinqExtensions.WithEach_f7a1155f_06000022(CommonExtensions.AsEnumerable_4ebbe596_06001850(i.addresses), new __Action_1(this, __IntPtr.op_Explicit_4ebbe596_06001413(this.__ctor_b__2_f7a1155f_06000006))); // ^ //i.addresses.AsEnumerable().WithEach( // a => // { // } //); ////if (Capabilities.playerType == CapabilitiesPlayerType) //var s = new ServerSocket(); //s.bind(8080); //s.connect += // e => // { // }; //s.listen(30); }
//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 }
// change: C:\util\xampplite\apache\conf\httpd.conf // http://localhost/jsc/FlashBrowserDocument/FlashBrowserDocument.htm /* Alias /jsc/FlashBrowserDocument "C:\work\jsc.svn\examples\actionscript\FlashBrowserDocument\FlashBrowserDocument\bin\Release\web" <Directory "C:\work\jsc.svn\examples\actionscript\FlashBrowserDocument\FlashBrowserDocument\bin\Release\web"> Options Indexes FollowSymLinks ExecCGI AllowOverride All Order allow,deny Allow from all </Directory> */ /// <summary> /// Default constructor /// </summary> public FlashBrowserDocument() { ConsoleFormPackageExperience.Initialize(); Console.WriteLine("ConsoleFormPackageExperience"); var t = new TextField { defaultTextFormat = new TextFormat { font = "Courier" }, backgroundColor = 0x303030, textColor = 0xffff00, text = "powered by jsc", background = true, x = 0, y = 0, alwaysShowSelection = true, width = DefaultWidth, height = DefaultHeight }.AttachTo(this); // you should be running within the browser //SecurityError: Error #2060: Security sandbox violation: ExternalInterface caller file:///C:/work/jsc.svn/examples/actionscript/FlashBrowserDocument/FlashBrowserDocument/bin/Release/web/FlashBrowserDocument.swf cannot access file:///C:/work/jsc.svn/examples/actionscript/FlashBrowserDocument/FlashBrowserDocument/bin/Release/web/FlashBrowserDocument.htm. // at flash.external::ExternalInterface$/_initJS() // at flash.external::ExternalInterface$/addCallback() // at Extensions::ExternalExtensions$/External_100668292() // at DOM::ExternalContext() // at DOM::ExternalContext$/ExternalAuthentication_100663321() // at FlashBrowserDocument.ActionScript::FlashBrowserDocument() t.text = "before ExternalAuthentication"; try { Console.WriteLine("before ExternalAuthentication"); ExternalContext.ExternalAuthentication( context => { Console.WriteLine("at ExternalAuthentication"); t.text = "after ExternalAuthentication"; context.Document.body.style.backgroundColor = "#afafff"; context.Document.body.style.color = "#000080"; t.appendText("\nflash element was found within html document"); context.Document.title = "hello world"; #region hide/show flash element var HideFlashButtonCounter = 0; var HideFlashButton = new IHTMLButton { innerHTML = "hide flash element" }; HideFlashButton.AttachTo(context); HideFlashButton.onclick += delegate { if (HideFlashButtonCounter % 2 == 0) { t.appendText("\nflash element hidden"); context.Element.width = 0; context.Element.height = 0; HideFlashButton.innerHTML = "show flash element"; } else { t.appendText("\nflash element shown"); context.Element.width = DefaultWidth; context.Element.height = DefaultHeight; HideFlashButton.innerHTML = "hide flash element"; } HideFlashButtonCounter++; }; #endregion var Content = @" <hr /> <blockqoute> <h1>This application was written in c# and was compiled to actionscript with <a href='http://jsc.sf.net'>jsc compiler</a>.</h1> <h2>Currently supported browsers:</h2> <ul> <li><img src='http://www.w3schools.com/images/compatible_firefox.gif' />Firefox</li> <li><img src='http://www.w3schools.com/images/compatible_chrome.gif' />Google Chrome</li> <li><img src='http://www.w3schools.com/images/compatible_safari.gif' />Safari</li> <li><img src='http://www.w3schools.com/images/compatible_opera.gif' />Opera</li> </ul> </blockqoute> ".AttachAsDiv(context); var DynamicChild = new IHTMLSpan { innerHTML = "hello world" }.AttachTo(Content); DynamicChild.style.color = "red"; DynamicChild.innerHTML = "click on the image to remove it!"; var DynamicChildImage = new IHTMLImage { title = "jsc diagram", src = "http://jsc.sourceforge.net/jsc.png" }.AttachTo(DynamicChild); DynamicChildImage.style.backgroundColor = "white"; DynamicChildImage.onclick += delegate { Console.WriteLine("at DynamicChildImage onclick"); DynamicChild.removeChild(DynamicChildImage); DynamicChild.innerHTML = "you have removed that image!"; var Undo = new IHTMLButton { innerHTML = "undo" }.AttachTo(DynamicChild); Undo.onclick += delegate { DynamicChildImage.AttachTo(DynamicChild); DynamicChild.removeChild(Undo); }; }; DynamicChild.onclick += delegate { Console.WriteLine("at DynamicChild onclick"); }; } ); } catch (Exception ex) { t.text = "error " + new { ex }; } }
protected void prepare() { stage.align = StageAlign.TOP_LEFT; //stage.quality = StageQuality.LOW; txtMain = new TextField(); tfNormal = new TextFormat(); tfNormal.font = "Verdana"; tfNormal.align = TextFormatAlign.LEFT; tfNormal.size = 10; tfNormal.color = 0xffffff; txtMain.defaultTextFormat = tfNormal; txtMain.autoSize = "left"; txtMain.appendText("0"); moveSpeed = 0.2; rotSpeed = 0.12; texWidth = 256; texHeight = 256; posX = 22; posY = 11.5; dirX = -1; dirY = 0; planeX = 0; planeY = 0.66; w = 320; h = 240; time = getTimer(); setWorldMap(); //floorVals = new[] { // 80,40,26.6666666666667,20,16,13.3333333333333,11.4285714285714,10,8.88888888888889,8,7.27272727272727,6.66666666666667,6.15384615384615,5.71428571428571,5.33333333333333,5,4.70588235294118,4.44444444444444,4.21052631578947,4,3.80952380952381,3.63636363636364,3.47826086956522,3.33333333333333,3.2,3.07692307692308,2.96296296296296,2.85714285714286,2.75862068965517,2.66666666666667,2.58064516129032,2.5,2.42424242424242,2.35294117647059,2.28571428571429,2.22222222222222,2.16216216216216,2.10526315789474,2.05128205128205,2, //1.95121951219512,1.9047619047619,1.86046511627907,1.81818181818182,1.77777777777778,1.73913043478261,1.70212765957447,1.66666666666667,1.63265306122449,1.6,1.56862745098039,1.53846153846154,1.50943396226415,1.48148148148148,1.45454545454545,1.42857142857143,1.40350877192982,1.37931034482759,1.35593220338983,1.33333333333333,1.31147540983607,1.29032258064516,1.26984126984127,1.25,1.23076923076923,1.21212121212121,1.19402985074627,1.17647058823529,1.15942028985507,1.14285714285714,1.12676056338028,1.11111111111111,1.0958904109589,1.08108108108108,1.06666666666667,1.05263157894737,1.03896103896104,1.02564102564103,1.0126582278481 }; time = getTimer(); counter = 0; ZBuffer = new double[0]; screen = new BitmapData(w, h, false, 0x0); screenImage = new Bitmap(); screenImage.bitmapData = screen; addChild(screenImage); addChild(txtMain); this.enterFrame += render; //addEventListener(Event.ENTER_FRAME, render); }
public ApplicationSprite() { var t = new TextField { text = "click on me to see console", autoSize = TextFieldAutoSize.LEFT }; t.MoveTo(16, 16); t.AttachTo(this); t.click += delegate { t.text += "\nclicked!"; Console.WriteLine("clicked in flash!"); }; this.AtInitializeConsoleFormWriter = ( Action<string> Console_Write, Action<string> Console_WriteLine ) => { t.appendText("\nAtInitializeConsoleFormWriter"); try { var w = new __OutWriter(); var o = Console.Out; var __reentry = false; w.AtWrite = x => { o.Write(x); if (!__reentry) { __reentry = true; Console_Write(x); __reentry = false; } }; w.AtWriteLine = x => { o.WriteLine(x); if (!__reentry) { __reentry = true; Console_WriteLine(x); __reentry = false; } }; Console.SetOut(w); Console.WriteLine("flash Console.WriteLine should now appear in JavaScript form!"); t.appendText("\nAtInitializeConsoleFormWriter done"); } catch (Exception ex) { t.appendText("\n error: " + new { ex, Console_Write, Console_WriteLine }); } }; }
public ApplicationSprite() { // see also: http://www.come2play.com/API_inner.asp?f=1&newsid=357 //AssetsLibraryInfo.ActionScriptOutput_contains_110456_bytes = 0; var log = new TextField { text = "loading...", multiline = true, autoSize = TextFieldAutoSize.LEFT }.AttachTo(this).MoveTo(8, 64); var ButtonPlayTheGame = new Sprite { useHandCursor = true, buttonMode = true, alpha = 0.6 }.AttachTo(this); ButtonPlayTheGame.graphics.beginFill(0x00ff00); ButtonPlayTheGame.graphics.drawRect(0, 0, 96, 48); var ButtonSurrender = new Sprite { useHandCursor = true, buttonMode = true, alpha = 0.6 }.AttachTo(this); ButtonSurrender.graphics.beginFill(0xff0000); ButtonSurrender.graphics.drawRect(96, 0, 96, 48); var ButtonFullscreen = new Sprite { useHandCursor = true, buttonMode = true, alpha = 0.6 }.AttachTo(this); ButtonFullscreen.graphics.beginFill(0xffff00); ButtonFullscreen.graphics.drawRect(96 * 2, 0, 96, 48); var MessageSurrender = "z.surrender"; this.InvokeWhenStageIsReady( delegate { log.appendText("\n stage ready"); var x = new XClientGameAPI(this); x.AtMatchStarted += id => { log.appendText("\n AtMatchStarted id " + id); ButtonFullscreen.click += delegate { log.appendText("\n to fullscreen"); this.stage.SetFullscreen(true); }; ButtonPlayTheGame.click += (e) => { var z = "click " + e.localX + ";" + e.localY; log.appendText("\n " + z); var u = UserEntry.create( key: "z.click", value: z ); x.doStoreState( new UserEntry[] { u } ); }; ButtonSurrender.click += (e) => { var z = "surrender " + e.localX + ";" + e.localY; log.appendText("\n " + z); var u = UserEntry.create( key: MessageSurrender, value: z ); x.doStoreState( new[] { u } ); }; x.AtMatchEnded += (e) => { log.appendText("\n AtMatchEnded e length " + e.Length); }; x.AtStateChanged += (e) => { log.appendText("\n AtStateChanged e length " + e.Length); e.WithEach( k => { var key = (string)k.key; log.appendText("\n AtStateChanged: " + new { key, k.value, k.storedByUserId }); if (key == MessageSurrender) { log.appendText("\n surrender: " + k.storedByUserId); var u = PlayerMatchOver.create(k.storedByUserId, 0, 0); x.doAllEndMatch( new[] { u } ); } } ); }; }; log.appendText("\n doRegisterOnServer"); x.doRegisterOnServer(); } ); }
private void Initialize() { var stage = this.stage; if (stage == null) throw new Exception("stage is null"); this.graphics.beginFill(0xefff80); this.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight / 2); this.graphics.beginFill(0xef8fff); this.graphics.drawRect(0, stage.stageHeight / 2, stage.stageWidth, stage.stageHeight / 2); var info = new TextField { selectable = false, multiline = true, width = stage.stageWidth, height = stage.stageHeight }.AttachTo(this); var snapcontainer = this.Attach(new Shape()); var vectorized = this.Attach(new Shape()); var delta = new Shape { alpha = 0.5 }.AttachTo(this); var ego = new Sprite { mouseEnabled = false, x = stage.stageWidth / 2, y = stage.stageHeight / 2 }.AttachTo(this); var ego_img = gtataxi.ToBitmapAsset().AttachTo(ego); ego_img.x = -ego_img.width / 2; ego_img.y = -ego_img.height / 2; Action<string, object> Write = (p, e) => { info.appendText(p + e.ToString() + Environment.NewLine); info.setSelection(info.text.Length - 1, info.text.Length - 1); }; var mouseDown_args = default(MouseEvent); var mouseUp_fadeOut = default(Timer); uint color = 0; var snap_radius = 64; stage.mouseDown += e => { color = 0; // snap to old point if (mouseDown_args != null) if (snapcontainer.alpha > 0) if ((mouseDown_args.ToStagePoint() - e.ToStagePoint()).length < snap_radius) { color = 0xff; e = mouseDown_args; } mouseDown_args = e; Write("down ", new { e.localX, e.localY, e.buttonDown }); }; Action<Shape, double, double, uint> DrawArrow = (s, x, y, c) => { s.graphics.lineStyle(2, c, 1); s.graphics.moveTo(mouseDown_args.stageX, mouseDown_args.stageY); s.graphics.lineTo(x, y); s.graphics.drawCircle(x, y, 4); }; var mouseMove_args = default(MouseEvent); var delta_pos = 0.0; stage.mouseMove += e => { if (e.buttonDown) { mouseMove_args = e; if (mouseUp_fadeOut != null) mouseUp_fadeOut.stop(); vectorized.alpha = 1; vectorized.graphics.clear(); snapcontainer.alpha = 1; snapcontainer.graphics.clear(); snapcontainer.graphics.lineStyle(2, 0xff, 1); snapcontainer.graphics.drawCircle(mouseDown_args.stageX, mouseDown_args.stageY, snap_radius); DrawArrow(vectorized, e.stageX, e.stageY, color); } else { if (delta_pos == 0) Write("move ", new { e.stageY, stage.stageHeight, stageScaleY = stage.scaleY, this.scaleY, stage.height }); //Write("move ", new { e.stageX, e.stageY, stage.stageWidth, stage.stageHeight, stage.scaleX, stage.scaleY }); } }; stage.mouseUp += e => { Write("up ", new { e.localX, e.localY, e.buttonDown }); if (mouseUp_fadeOut != null) mouseUp_fadeOut.stop(); mouseUp_fadeOut = 50.AtInterval( t => { vectorized.alpha -= 0.02; snapcontainer.alpha -= 0.04; } ); }; var delta_acc_min = 0.02; var delta_acc = delta_acc_min; var delta_acc_acc = delta_acc_min * 0.01; var delta_deacc_min = 0.03; var delta_deacc = delta_deacc_min; (1000 / 24).AtInterval( t => { if (mouseDown_args == null) return; if (mouseMove_args == null) return; delta.graphics.clear(); if (vectorized.alpha == 1) { delta_pos += delta_acc; //delta_deacc = (delta_deacc - delta_deacc_acc).Max(delta_deacc_min); delta_acc += delta_acc_acc; } else { delta_pos -= delta_deacc; delta_acc -= delta_acc_acc; if (delta_acc < delta_acc_min) delta_acc = delta_acc_min; //delta_deacc += delta_deacc_acc; } delta_pos = delta_pos.Min(1).Max(0); var u = (mouseMove_args.ToStagePoint() - mouseDown_args.ToStagePoint()) * delta_pos; var z = mouseDown_args.ToStagePoint() + u; if (delta_pos > 0) if (mouseDown_args.stageY > stage.height / 2) { // boolean Write("rot ", new { delta_pos, u.x, u.y }); ego.rotation += u.x * 0.2; var p = ego.ToPoint().MoveToArc(((int)ego.rotation).DegreesToRadians(), -u.y * 0.2); ego.x = p.x; ego.y = p.y; } else { Write("pan ", new { delta_pos, u.x, u.y }); var p = ego.ToPoint().MoveToArc(u.GetRotation() + ((int)ego.rotation + 270).DegreesToRadians(), -u.length * 0.2); ego.x = p.x; ego.y = p.y; } DrawArrow(delta, z.x, z.y, 0xff00); } ); }
public ApplicationSprite() { // X:\jsc.svn\examples\actionscript\FlashMP3PitchExperiment\FlashMP3PitchExperiment\Library\MP3Pitch.cs // X:\jsc.svn\examples\actionscript\Test\TestThreadStartInternalWorkerInvoke\TestThreadStartInternalWorkerInvoke\ApplicationSprite.cs // X:\jsc.svn\examples\actionscript\Test\TestThreadStart\TestThreadStart\ApplicationSprite.cs // jsc should return before getting here from the worker if (!Worker.current.isPrimordial) return; var t = new TextField { multiline = true, text = new { __Thread.InternalPrimordialSprite, this.loaderInfo.bytes.length, }.ToString(), autoSize = TextFieldAutoSize.LEFT }; t.AttachTo(this); t.click += delegate { var sw = Stopwatch.StartNew(); t.text = "enter click"; __Thread tt = new Thread( new ParameterizedThreadStart( data => { // can we render audio on the background thread now? // what else can AIR do on a background thread? // physics? // LAN calc? // how can we report to the UI thread? var nn = Stopwatch.StartNew(); //int i = 0; //// keep core2 buzy for a while to be noticed on the task manager //while (nn.ElapsedMilliseconds < 10000) //{ // SharedField = new // { // data, // i, // nn.ElapsedMilliseconds // //, Thread.CurrentThread.ManagedThreadId // }.ToString(); // i++; //} // http://stackoverflow.com/questions/16483863/flash-workers-sample-application-not-working // http://probertson.com/articles/2012/11/07/as3-concurrency-workers-use-cases-best-practices-links/ // i cant hear it // http://stackoverflow.com/questions/11902863/can-actionscript-workers-be-used-to-play-generate-sounds-in-a-separate-thread // http://flexmonkey.blogspot.com/2012/09/multi-threaded-sound-synthesis-in-flex.html var p = new MP3Pitch("http://visit.abstractatech.com/assets/com.abstractatech.web.design1/AbstractatechPostProductionVersion7.mp3") { //_rate = p._rate }; // i wonder, can we switch to UI thread via await and then back? var xfromWorker = (MessageChannel)Worker.current.getSharedProperty("fromWorker"); // or are we to capture all fields modified within worker and only update those? xfromWorker.send("message from worker " + new { SharedField }); // how do we signal our work is done? } ) ); tt.InternalBeforeStart = w => { // how are we supposed to get data back from the worker? var fromWorker = w.createMessageChannel(Worker.current); w.setSharedProperty("fromWorker", fromWorker); fromWorker.channelMessage += e => { var data = (string)fromWorker.receive(); t.appendText( "\n " + new { sw.ElapsedMilliseconds, data }.ToString() ); }; }; //Thread.AllocateNamedDataSlot(""). //Thread.SetData( tt.Start("hello world"); }; }