I upload my flex client-side swf app to some website that loads different swf's on it's site. So you see your application floating in that website. My app is Flex swf app and has onCreationComplete() that starts the flow of logic. Now I want to do cleanup state and save state in a shared object when the application unloads (or probably exiting event, or closing event..) So do we have any function that I can implement and the flash platform automatically calls that function when the swf is unloading/closing/exiting?? (just like the onCreationComplet() function)
some thing like onUnloading(), or onUnload() or onClosing()...
Thanks
You could add an event listener to your main (root) object and have your method execute on Event.REMOVED_FROM_STAGE or add the listener to root.loaderInfo and execute on Event.UNLOAD.
Related
I have embedded CefSharp Browser for WPF Application where I'm trying to load a WebPage. Also I have bound JavaScript object using
RegisterJsObject Function. This is required as JS of Webpage makes calls to Native app.
I have implemented a WatchDogTimer to switch to error page if the page load takes time/any error.
The issue is, when it tries to load Error page in case of timeout, it is killing the existing CefSharp.BrowserSubprocess.exe and creating a new one. But this is losing the JavaScript binding thereby no calls can be made from JS to Native App.
Is there any way to avoid creating new process of CefSharp.BrowserSubprocess.exe?
You can use CefSettings class to change this behavior. By default, Chromium creates a renderer process for each instance of a site the user visits, but you can change it
var settings = new CefSettings();
settings.CefCommandLineArgs.Add("renderer-process-limit", "0");
Cef.Initialize(settings);
Note, that you must do it before you create a first instance of your ChromiumWebBrowser.
Important Note: as amaitland mentioned in his comment below you should use it very carefully and
only if you are using a single browser instance should you even
consider doing this. Multiple instances hosted in a single process can
easily run out of memory, a single crash and they all stop working.
Also if the render process crashes for whatever reason, the new
instance won't have the objects bound.
If you are using legacy binding then this is expected, see http://cefsharp.github.io/api/71.0.0/html/P_CefSharp_CefSharpSettings_LegacyJavascriptBindingEnabled.htm
Using the newer binding method is the best option https://github.com/cefsharp/CefSharp/wiki/General-Usage#3-how-do-you-expose-a-net-class-to-javascript
I am working on an application which interact with a database and construct reports, I want this application to be extensible and I can in the future to integrate custom report builders to the application as plugins.
I have some question about the plugin architecture supported by Qt:
Can I load the plugins in there own processes ?
How could I send some custom QML type from the plugin to main application and hook some event handlers on it.
Another question: is there any framework to develop service based qt application ?
Can I load the plugins in there own processes ?
Not with the plugin mechanism (QPluginLoader). The plugin mechanism dynamically loads libraries (different threads are possible). However, your plugins can be a normal application, that gets started by your main application via QProcess, and exchange data via stdin/stdout (or other IPC mechanisms)
How could I send some custom QML type from the plugin to main application and hook some event handlers on it.
In case you use normal plugins, simply add method that returns the created QML object. Have a look at:https://doc.qt.io/qt-5/qtqml-cppintegration-interactqmlfromcpp.html#loading-qml-objects-from-c
In case you want to use the multi process version, it gets slightly more complicated. Pass the QML code via stdout and create it in your main application. Pass some "communicator" object to this created QML object, so that the QML type can send back data via that communicator to it's original process.
This is possible if we manually create a FileSystemWatcher and watch the 'parts' directory (here some dlls inside the folder) and track any changes, then we reflect the changes into a container which allows for recomposition.
Does MEF support auto-updating when the Container is using a DirectoryCatalog and it automatically for us ?
You need to call the Refresh method of the DirectoryCatalog for it to update with new contents. This will trigger recomposition in any containers hooked up to the catalog. You can create a FileSystemWatcher and call the Refresh method when anything changes.
we are developing an Adobe AIR app using Flex4. We are facing lot of bugs that didn't show up when we run the application inside Flash Builder (both debug mode and run mode), but when we install the app and run it, the app shows a different behaviour. Any idea ? what does it change between running the installed application in the builder and outside ?
Thanks a lot
Ok i've founded the problem using MonsterDebugger in the application running stand alone. The problem was the File.browseForDirectory(). I'm creating the File object, registering the event listener and then calling File.browseForDirectory() and that generate an exception. I switched the order, First creating a new file, then calling File.browseForDirectory() and at last register an event handler and works great.
My guess is that inside the debugger version and inside Flash Builder it takes just few more millisec and the File object is ready when i register the eventlistener but in the stand alone application AS3 code for event listener registration is executed before the File object initialization.
Once you load an actionscript page from scratch (in my case loading XML data from a file, initializing various other elements in a fairly time consuming way) if you navigate away from that page and then return to it, (via the browser 'back' key for example) is their a way to forego the previous initialization and just immediately bring up the previous Actionscript page in its fully initialized state.
Flash Player will always start up your SWF file from scratch. In most cases, navigating back will load the SWF and things like XML files from the browser's cache, and you'll be up and running faster than if you were to go there the first time. However, you're responsible for adding logic to remember the most recent state and restore it when the SWF is loaded again.
If you're using Flex, the History Manager might be useful. For AS3 without a framework, you might check out SWFAddress instead. Both of those use the browser's URL and history features to track the application state, which can allow you to navigate through the SWF as if it contains "pages" and even bookmark specific locations in the SWF. Alternatively, or maybe even simultaneously, you might also consider using Flash Player's cookie-like flash.net.SharedObject functionality to remember the the state. You lose the more granular browser navigation, but you might be able to remember more about a specific single state.