loadVariables() and LoadVars - actionscript

I am currently developing an Flash Movie which sends a simple POST request with a few parameters to a PHP URL. The only problem is that I am not sure which of two (loadVariables & LoadVars) methods I should use. What are the pros and cons?

LoadVars Class:
The LoadVars class is an alternative to the loadVariables() function for transferring variables between a Flash Lite and a web server over HTTP. Use the LoadVars class to obtain verification of successful data loading and to monitor download progress.
The LoadVars class lets you send all the variables in an object to a specified URL and load all the variables at a specified URL into an object. It also lets you send specific variables, rather than all the variables, which can make your application more efficient. Use the LoadVars.onLoad handler to ensure that your application runs when data is loaded, and not before.
The LoadVars class works much like the XML class; it uses the methods load(), send(), and sendAndLoad() to communicate with a server. The main difference between the LoadVars class and the XML class is that LoadVars transfers ActionScript name and value pairs, rather than an XML DOM tree stored in the XML object. The LoadVars class follows the same security restrictions as the XML class.
- Copied verbatim from Adobe Flash Platform - LoadVars
loadVariables Function:
Reads data from an external file, such as a text file or text generated by ColdFusion, a CGI script, Active Server Pages (ASP), PHP, or Perl script, and sets the values for variables in a target movie clip. This action can also be used to update variables in the active SWF file with new values.
The text at the specified URL must be in the standard MIME format application/x-www-form-urlencoded (a standard format used by CGI scripts). Any number of variables can be specified. For example, the following phrase defines several variables:
company=Macromedia&address=600+Townsend&city=San+Francisco&zip=94103
- Copied verbatim from Adobe Flash Platform - loadVariables Function

Related

Why Assets is in different name space depending of main activity or a class?

If I am in the main activity, if I want to open a file that there is in the assets, I use this code:
using (Stream miFicheroOrigen = Assets.Open("configuration.xml"))
{}
I can see that the namespace is Android.Context.Res.AssetManager.
However, I would like to have a class with the methods to manage the configuration, so I have create this class:
internal class ConfigurationManager
{
}
But it this case I have to use Android.Content.Resoruces.System.Assets, i can't use the Assets in the same namespace than in the main activity.
It works, but I would like to know if really it is the same Assets or different.
Perhaps it is because the first one is an Activity and in the second one it is a normal class, but I don't understand well why in the second case I can't access to the same namespace.
Thanks.
I can see that the namespace is Android.Context.Res.AssetManager.
But it this case I have to use Android.Content.Resoruces.System.Assets
It may seem that you have mistyped the wrong letter in your question. Maybe you want to know the difference between them as bellow:
Android.Content.Res.AssetManager Class VS Android.Content.Res.Resources Class
Different:
Android.Content.Res.AssetManager : Provides access to an application's raw asset files; see Resources for the way most applications will want to retrieve their resource data. This class presents a lower-level API that allows you to open and read raw files that have been bundled with the application as a simple stream of bytes.
Android.Content.Res.Resources : Class for accessing an application's resources. This sits on top of the asset manager of the application (accessible through Resources.Assets) and provides a high-level API for getting typed data from the assets.Using application resources makes it easy to update various characteristics of your application without modifying code, and—by providing sets of alternative resources—enables you to optimize your application for a variety of device configurations (such as for different languages and screen sizes). This is an important aspect of developing Android applications that are compatible on different types of devices.
Android.Content.Res.Resources.System Property : Return a global shared Resources object that provides access to only system resources (no application resources), and is not configured for the current screen (can not use dimension units, does not change based on orientation, etc).
Same:
They all can get the Android.Content.Res.AssetManager.
Android.Content.Res.AssetManager assetManager = Android.Content.Res.Resources.System.Assets;
Result :So you can see Android.Content.Res.Resources.System is a global shared resources object,so you can get from a normal class.However , it does not mean that Android.Content.Res.AssetManager can not be getted from normal class.According to the documentation, they are only the high and low points of the api, and the document recommends using such methods(Android.Content.Res.Resources.System) to obtain resources.

How to trigger an action on completion/change of a type's property?

I have the following type in my grammar:
TestSuite:
'TestSuite:' name = ID
'Type:' type = SuiteType;
enum SuiteType:
INTERNAL='1' | EXTERNAL='2';
I would like to read an xml file whenever the property gets a (new) value since I use the contents of that xml file for validation and content completion. Depending on the value of the property, the xml that will be read will be different.
How would you trigger an action that would read the value of a property of a type from the runtime environment's DSL instance?
You could maybe try adding an EMF Adapter to all TestSuite instances such that upon a Notification that changes your 'type' feature to a particular value, the XML file of your choice is read and acted upon.
this blog post seems to do the trick: at the end of the linking phase, an Adapter (this is EMF vocabulary, basically a Listener) can be registered for your TestSuite instances.
Then in your Adapter implementation, you can filter whether you need to react using the methods of Notification such as getFeature().
Since you mention you want to do this for content completion and validation, you may need to do all of this in the scoping / validation phases of Xtext. You will probably have a bit of "lag" upon hitting ctrl+space for auto-completion if your IDE needs to find and parse your XML file, but that's to be expected I guess...

What is the different between ClassMapAutoLoader and onBootstrap?

What is the difference between ClassMapAutoLoader and onBootstrap?
Class Map Autoloader
A web application consists of many PHP classes, and each class typically resides in a separate file. This introduces the need of including the files.
As your application grows in size, it may be difficult to include
each needed file. Zend Framework 2 itself consists of hundreds of files,
and it can be very difficult to load the entire library and all its
dependencies this way. Moreover, when executing the resulting code, PHP interpreter will
take CPU time to process each included file, even if you don't create an
instance of its class.
To fix this problem, in PHP 5.1, the class autoloading feature has been introduced.
The PHP function spl_autoload_register() allows you to register
an autoloader function. For complex web sites, you even can create
several autoloader functions, which are chained in a stack.
During script execution, if PHP interpreter encounters a class name
which has not been defined yet, it calls all the registered autoloader functions
in turn, until either the autoloader function includes the class or "not found" error is
raised. This allows for "lazy" loading, when PHP interpreter processes the class
definition only at the moment of class invocation, when it is really needed.
To give you an idea of how an autoloader function looks like, below we provide a
simplified implementation of an autoloader function:
<?php
// Autoloader function.
function autoloadFunc($className) {
// Class map static array.
static $classMap = array(
'Zend\\Mvc\\Application' => '/path/to/zend/dir/Zend/Mvc/Application.php',
'Application\\Module' => '/path/to/app/dir/Application/Module.php',
//...
);
// Check if such a class name presents in the class map.
if(isset(static::$classMap[$className])) {
$fileName = static::$classMap[$className];
// Check if file exists and is readable.
if (is_readable($filename)) {
// Include the file.
require $filename;
}
}
}
// Register our autoloader function.
spl_autoload_register("autoloadFunc");
In the above example, we define the autoloadFunc() autoloader function,
which we will further refer to as the class map autoloader.
The class map autoloader uses the class map for mapping between class name and
absolute path to PHP file containing that class. The class map is just a usual PHP
array containing keys and values. To determine the file path by class name, the
class map autoloader just needs to fetch the value from the class map array.
It is obvious, that the class map autoloader works very fast. However, the disadvantage
of it is that you have to maintain the class map and update it each time you add a new
class to your program.
onBootstrap
On every HTTP request, the Zend\Mvc\Application
object is created. The application's "life" consists of several stages.
Zend Framework 2 uses the concept of event. One class can trigger an event,
and other classes may listen to events. Technically, triggering an event means just calling another class' "callback" method. The event management is implemented inside of
the Zend\Mvc\EventManager component.
Each application life stage is initiated by the application by triggering an event. Other
classes (either belonging to Zend Framework or specific to your application) may listen
to events and react accordingly.
Below, the four main events (life stages) are presented:
Bootstrap. When this event is triggered by the application, a module has a chance to
register itself as a listener of further application events in its onBootstrap()
callback method.
Route. When this event is triggered, the request's URL is analyzed using a router class (typically, with
Zend\Mvc\Router\Http\TreeRouteStack class. If an exact match between the URL and a route
is found, the request is passed to the site-specific controller class assigned to the route.
Dispatch. The controller class "dispatches" the request using the corresponding action method
and produces the data that can be displayed on the web page.
Render. On this event, the data produced by the controller's action method are passed for rendering to
Zend\View\Renderer\PhpRenderer class. The renderer class uses a
view template file for producing an HTML page.
For a beginner to better understand the above mentioned concepts, I would recommend the Zend Framework 2.0 by Example: Beginner’s Guide book or the Using Zend Framework 2 e-book. You may choose the book on your own.

OpenRasta - Pass parameters to custom Codec

I've created a new custom JSON codec for OpenRasta which works fine.
I need to pass arguments to the codec's write method when the handler is executed but cannot find any documentation on how to do it.
I notice in the implemented WriteTo method, there is a string[] codecParameters parameter, however no idea how to pass them in.
Anyone come accross this problem before? Thanks
the codec parameters are per-request. They're intended to be used together with (for example) the PathSegmentAsParameterUriDecorator.
For example, if you enable that decorator, the path /resource;segment will be treated as /resource by openrasta, and a parameter will be created with the "segment" value, and passed to the codec.
If you wish to pass information to the codec from the handler, there's nothing there, as architecturally it goes against the design of OpenRasta, which specifically prevents handlers and codecs from talking to each others.
If you wish to pass configuration data to your codec, you use the Configuration property from the ICodec interface, which will be filled with whatever object you have provided at configuration time.
You provide the configuration object either through the paramter in the .TranscodedBy(object configuration) method, or if you do custom registration using the configuration metamodel, bu adding the configuration to your Configuration property on CodecModel (which incidently is used in the ResourceModel object created by the fluent API).
Do you have a specific scenario I can help with?

Best way to use an IoC container for retrieving runtime settings

I have an C# dll project for which I have to store the runtime settings in an external XML file, and this dll will be used in an ASP.NET/ASP.NET MVC application for which I also have to store the runtime settings in a external file.
Which IoC container can be used to create an object with the runtime settings loaded from a specific external file (or app.config/web.config), and also works for web applications running in medium trust? Any howto/tutorial would be greatly appreciated.
So far I've found only this articles:
Use Castle Windsor to Read Your Config Files Automatically
Getting rid of strings (3): take your app settings to the next level
Update
I'm sending mails from my dll to a variable number of SMTP servers, based on the current record type. For type A I'm using a given SMTP server+port, for type B I'm using an alternate set of server+port values. Of course, I want to be able to modify those values after deployment, so I store them in a XML file.
If I'm storing the SMTP settings as a SMTPConfiguration class with 2 properties (SMTPServer as String and SMTPPort as Int32), is it possible to return from an IoC container the required object based on the given record type, and what is the best way to read the runtime settings in order to build the returning object?
Update2
Let's say I'm storing in the configuration file the following parameters: ASMTPServer, BSMTPServer, ASMTPPort, BSMTPPort.
I can use Castle DictionaryAdapter to read all those settings as properties of an AppConfiguration class.
What is the recommended method to specify that the required SMTPConfiguration class should use ASMTPServer and ASMTPPort values if I'm using a type A record as a parameter (and should use BSMTPServer and BSMTPPort values if I'm using a type B record as a parameter) ? Also, how can I specify that the AppConfiguration is required in this process?
Is there a pattern for initializing objects created wth a DI container
Windsor Config Parameters With Non-Primitive Types

Resources