Tips to search and replace from Paul Barry.
perl -pi -e ‘s/foo/bar/g’ *.txt
ruby -pi -e “gsub(/foo/, ‘bar’)” *.txt
Tips to search and replace from Paul Barry.
perl -pi -e ‘s/foo/bar/g’ *.txt
ruby -pi -e “gsub(/foo/, ‘bar’)” *.txt
I took the time last night to research how to customize my mac. Fortunately, it’s very easy to do and I ended up doing at least three things:
NOTE: You’ll need system administrator rights to perform the changes to you login styles!
/System/Library/CoreServices
Changing the image on my login apple icon
/System/Library/CoreServices/SecurityAgentPlugins/loginwindow.bundle/Contents/Resources
Changing the image on my desktop harddrive icon (or any other icon you’d like)
Changing the dock style
Highlight stacks item
Transparent hidden dock for apps that are hidden
You can revert the changes for the login styles overwriting your changes with the backup. For the icon changes, all you have to do is go back to the Get Info box, click on the icon and then do a Command-X to cut. The icon should revert back to the default settings!
To pin the dock to the start, use: defaults write com.apple.dock pinning -string start
To pin the dock to the end, use: defaults write com.apple.dock pinning -string end
To return the dock to the middle, use: defaults write com.apple.dock pinning -string middle
You can set up the location of the flex sdk anywhere and remember to re-adjust the location.
I’ve found out that when you use compc, the swc generated catalog.xml file includes digests and omits the components information that Flash components need to appear in the Components panel. So in order to fix the components, you need to set a custom namespace and include it in your build’s compilation properties. My manifest.xml is located in the resources direct and looks like this –
<?xml version="1.0" encoding="utf-8"?> <componentPackage> <component id="MyComponent" class="com.momentstar.MyComponent" /> </componentPackage>
Then, to disable adding digest information, you have to disable the digests information. The properties highlighted are the namespace, include-namespaces, and compute-digest tags in the build file below –
<taskdef resource="flexTasks.tasks" classpath="${basedir}/flex_sdk_3/ant/lib/flexTasks.jar" />
<property name="FLEX_HOME" value="${basedir}/flex_sdk_3" />
<property name="BUILD.DIR" value="target" />
<property name="PACKAGE.DIR" value="${BUILD.DIR}/project" />
<target name="build" description="Builds project">
<mkdir dir="${PACKAGE.DIR}" />
<compc output="${PACKAGE.DIR}/MyComponent.swc" locale="en_US">
<namespace uri="http://momentstar.com/2008" manifest="resources/manifest.xml" />
<include-namespaces>http://momentstar.com/2008</include-namespaces>
<strict>true</strict>
<optimize>true</optimize>
<warnings>true</warnings>
<source-path>src</source-path>
<compute-digest>false</compute-digest>
</compc>
</target>
In using amfphp, I found that I need to create two configuration files: services-config.xml and remoting-config.xml. In the Flex 2 documentation, the former file defines the basic services settings such as security and logging. Destination services definitions should not be defined in the services-config.xml, instead create references in the file to separate specific configuraton files reserved for the different services types to a dedicated file. These files include the data-management-config.xml, messaging-config.xml, and proxy-config.xml. And finally, the latter file is used on of those so called configuration files and defines RemoteObject services. You may also use multiple files of the same type, if it’ll help with maintaining groups of services.
services-config.xml
There are several nodes and attributes for this file. For a complete list, bring up the help index in Flex Builder and search for “Data Service configuration file syntax”. For amfphp, you only need the following defined:
<?xml version="1.0" encoding="UTF-8"?>
<services-config>
<services>
<service-include file-path="remoting-config.xml" />
</services>
<channels>
<channel-definition id="[your channel service id]"
class="mx.messaging.channels.AMFChannel">
<endpoint uri="http:/[your_server]/amfphp/gateway.php"
class="flex.messaging.endpoints.AMFEndpoint"/>
</channel-definition>
</channels>
</services-config>
From Adobe’s documentation, the services node contains the individual data services or references that are the xml files containing the service definitions. It is declared at the top level of the configuration as the child node for services-config node. Inside the services node, is the service-include file-path node. This provides the service file locations and their path is relative to the directory containing the services-config.xml file. As an aside, if you don’t want to break up the definitions, you could include them using the service as a child of the services node. But based on all the other documentation I’ve read, just break up the definitions into managable smaller files. (I’m sure there’s a reason for this other then scalability, let me know and I’ll update this post.)
The channels node provides information about the data transportation between the server and the clients. The channel-definition node defines the message channel that can be used to transport the data with it’s id attribute should match the one defined in the service definition and it’s class attribute being the fully qualified AS3 class for the message channel, which is the AMF in our case. The others are RTMP, AMF polling, Secure RTMP, Secure AMF, HTTP, and Secure HTTP. Per the Configuring message channels documentation, you can actually pair any type of service with any type of channel. Next, the endpoint node is where the client should begin requesting the service with it’s URI attribute pointing to the url of the service and class attribute is the fully qualified AS3 class for the endpoint. The url points to AMFPHP’s gateway.php file.
And that’s it for the service-config file.
remote-config.xml
Just like the services-config file, there are lot of nodes and their associated attributes that are allowed for the remote-config file, which again only references “RemoteObject” calls. To find the Adobe documentation, do a search for “Understanding destination configuration”. The following example is the only thing needed to make a call from our Flex application:
<?xml version="1.0" encoding="utf-8" ?>
<service id="[my flash remote id]"
class="flex.messaging.services.RemotingService"
messageTypes="flex.messaging.messages.RemotingMessage">
<default-channels>
<channel ref="[your channel service id]"/>
</default-channels>
<destination id="categoryService">
<properties>
<source>com.momentstar.service.CategoryDao</source>
</properties>
</destination>
</service>
So a destination is object/service that you connect to using <mx:RemoteObject>, <mx:WebService>, or <mx:HTTPService> tags or Actionscript code. The service node defines the type of service with the id attribute is your arbitrary value, class and messageTypes referring to the RemoteObject.
The default-channels node and it’s child channel correspond to the channel-definition found in the services-config. Next, the destination node and the id attribute is what is used and referred to in your MXML/AS3 code. And finally, within the destination noe is the properties node, where you provide the source node that contains the qualified class name of our AMFPHP service.
Using the files in the compilation
Next, is to tell your application to use the configuration files. When using mxmlc, add -services option with the path to the services-config.xml file. In Flexbuilder, go to the Project, then Properties, and select the Flex Compiler option and in the Additional compiler arguments text box, where you should add something like:
-services=./WEB-INF/flex/services-config.xml
So the next thing is to use the above definitions in the Flex application. One thing I’d like to ask is how do you make different service destination calls and display them in some datagrid. Right now, I’ve only been making one service call per screen in my Flex application. If anyone has tips, again, just let me know!
References:
http://www.flex.org/documentation/
Disclaimer, the post are my research into the issue as I was curious about the different RPC services.
Now, if I could afford it, I would like to use the Flex Data Services (FDS) especially since I really want to see if Adobe/Macromedia has made Data Management and Messaging simpler, I might research the FDS Express later on; but I want to get up and running, so here we go. For right now, the RPC calls are built-in to the Flex SDK and Flexbuilder, so I got to go with what I got.
Basically, Flex allows three types of RPC services: HttpService, WebServices, and RemoteObject Services. In Flex, using the “RemoteObjects specifies named or unnamed sources and connects to an Action Message Format (AMF) gateway, whereas using the HTTPService and WebService use named services or raw URLs and connect to an HTTP proxy using text-based query parameters or XML”. Specifically, HTTPServices use raw HTTP requests, WebServices use the SOAP protocol and RemoteObjects uses AMF3.
“RemoteObject provides two advantages over HTTP or SOAP. First, while the AMF protocol uses HTTP to transfer packets, the data is transferred in a binary format that is natively understood by the Flash Player. As a result, data can move across the network more quickly and it can be deserialized more rapidly than text-based formats such as XML. Both of these result in performance gains, particularly where large sets of data are involved. Secondly, RemoteObject provides signficant productivity advantages. The remoting service, which runs on your server, automatically marshalls data between AMF and your server-side language (e.g., PHP, Java, C#). As a result, you can directly call methods on your PHP objects without having to write an XML REST interface or create web service interfaces”.
So which one to choose? As far as I’m concerned, I use little data sets so receiving data over the HTTPService has been a cinch. If I ever have to go through a larger data sets, I’ve looked at AMFPHP and found version 1.9 was very good and easier to configure then others. Again, this will probably be something that I’ll have to further research.
References:
http://store1.adobe.com/devnet/flex/articles/refactoring_flex.html
The article explains how to refact flex and about the data management services in FDS.
http://www.adobe.com/devnet/flex/articles/rpc_service.html
An article about Flex’s RPC services
http://www.adobe.com/devnet/flex/articles/remoteobject_sabreamf.html
Article about the other PHP Remoting framework, SabreAMF.