While teaching a Flex class recently, I had several students encounter this error in which their application would error out with the following: “Error #2148: this error did not allow to read data from a file XML”
This seemed rather strange because the XML file was surely there, but something else was up. So we started debugging the error. The Flex RPC Fault faultString would come back as “Error #2148: this error did not allow to read data from a file XML”. Hmmm, great help!
One of the students, Martin, found the solution. In Flex Builder you can set compiler arguments. They are located via Properties > Flex Compiler > Additional Compiler Arguments.
Simply add the following: “-use-network=false”
You will have to do this for each Flex project in Flex Builder that you’re experiencing the problem.
Tags: Flex
Having used a dozen or so IDE over the years, I appreciate it when they provide a way for me you use my favorite font (Bitstream Vera Sans Mono). You can set the font in Flex Builder from Windows > Preferences dialog window. Select the General > Appearance > Colors and Fonts category. Then in the Basic folder select Text Font. Finally, click the Change… button and select the desired font.
Tags: Best Practise · Eclipse
There is a new view that you can get from Adobe Labs that will add an RDS view to the eclipse IDE. It uses an updated version of ColdFusion MX, so it takes an update to your ColdFusion MX server before you add the plugin to eclipse.
The RDS view can be configured to point to any installation by using the RDS Configuation settings in the eclipse Preferences dialog.
The RDS plugin comes with all the old favorites plus the ability to generate an entire Flex 2 back-end! Did I studder? Yes, you can generate CFCs from ActionScript and ActionScript from CFCs. You can even generate CFCs from tables. This is not a “big whoop” kind of feature. I can tell it to create Active Records, Beans & DAO or even full integration with Flex Data Services.
Code generation is not one of my favorite things, but this does put you in a nice starting place.
This is all part of “Mystic”. You have to check this out!
Tags: ColdFusion · Eclipse
Copy a line:
Place the cursor on desired line or select multiple lines.
Press and hold the Ctrl + Alt keys. Use the up/down arrow keys to duplicate line(s).
Move a line:
Place the cursor on the desired line or select multiple lines.
Press and hold the Alt key. Use the up/down arrow keys to move the line(s).
Delete a line:
Place the cursor on the desired line or select multiple lines.
Press the Ctrl + D.
Indent Text:
Place the cursor on the desired line or select multiple lines.
Press the Tab key to increase the indent.
Press and hold the Shift key. Use the Tab key to decrease the indent.
Code Complete:
If you are in a tag and just want a list of it’’s properties. Press the Ctrl and SpaceBar.
If you start typing, AS or MXML, and press the Ctrl and SpaceBar it will complete the property/method if there are no other possible matches otherwise you get a list.
From the list, use the up/down arrows to highlight an item and the Enter to insert the item.
Insert Comment Block:
Select text and press Ctrl + Shift + C. (good for both AS and MXML)
Insert an ASDoc Comment:
Place the cursor where you would like to place a comment and press Crtl + Shift + D.
And for those of us that are annoyed by import lists that are out of order:
Press Crtl + Shift + O to organize the imports in an AS file in case sensitive order.
Code Navigation:
Below the Navigator View on the left-hand side is the Outline View. From here you can quickly jump to tags in the current file. Type a letter and it will jump through those tags that are visible.
Double click on a component in the outline and it will open that file.
Hold the Ctrl and mouse around an AS or MXML file. Notice that many things turn into hyperlinks that will take you to the source for that item. i.e. Ctrl + click a component to open the component file, Ctrl + click a variable or a method, etc…
Switching Between Open Files:
Press and hold the Alt key while pressing the left or right arrow key.
Switching Between Views:
Press and hold the Ctrl key while pressing the F7 key.
Uppercase/Lowercase:
Converting selected text to lowercase or uppercase press Ctrl + Shift + Y or Ctrl + Shift + X respectively.
Brace Highlighting:
Place the cursor after either the open or close to see the opposite one highlighted.
Tags: Flex
There are many reasons why you may want to add a JRun server instance to the Windows Services panel. I”ve found that its very handy on production machines in a cluster. If one fails, it recovers nicely without me having to help. Here is how I do it.
JRun provides an executable for managing its server instances called jrunsvc.exe. You can find it in the jrun_install_root\\bin directory. Open a command line window to this directory and execute jrunsvc along with some of these options:
|
Option
|
Description
|
|
-install jrun_server [service-name [service-display [service-description]]]
|
Installs the JRun server as a Windows service. The Windows service name, Windows service display name, and Windows service description fields are optional. If a name contains spaces, use quotation marks.
The Mask:jrunsvc -install server_name “service display name” “service description”
The Example:
jrunsvc -install flexsamples “Flex Sample Applications Server” “Flex Samples”
|
|
-remove service-name
|
Removes the named Windows service, if you installed it using this utility. You can mark the service for deletion on system start.
|
|
-stop service-name
|
Starts the named service, if it is not already started.
|
|
-start service-name
|
Stops the named service, if it has started.
|
|
-console service-name
|
Runs the service from the console rather than from the Windows service Control Manager. Use this option for debugging.
|
|
-config path-to-jvm.config
|
Specifies a path to the JVM configuration file used by the Windows service.
Overrides the default, jrun_root\\bin\\jvm.config, to determine the JVM configuration.
|
|
-help
|
Lists all options.
|
This table is from the JRun Documentation with some modifications.
That is it! Now, when ever the server is restarted, the necessary Flex servers will start as well.
Tags: Flex · JRun
I was recently trying to create a document collaboration tool for one of my clients. In order to make it a bit easier for the user, I decided I would use FlashPaper to display the uploaded documents they are discussing. It took a couple of hours to figure it out but its pretty simple in the end.
First, you have to have the FlashPaperConnect .dll. Contribute 3, and some other products comes with the FlashPaperConnect .dll that makes it all possible. Contribute also registers the dll on your system, so all you do is CFOBJECT the FlashPaperConnect2.object.2 component.
Like so:
<cfobject type=”com” name=”FlashPaper” class=”FlashPaperConnect2.object.2″ action=”create”>
The method you need to call is BeginConversion(). Its arguments are the source file, destination file; include outline; paper size; and something else. I”m still looking for documentation on this and if it violates the EULA. But until then…
<cfset FlashPaper.BeginConversion(”c:\\temp\\doc1.doc”,”c:\\temp\\doc1.swf”,0,210,297)
This seems to work.
Good luck.
Tags: ColdFusion
While working on a recent Flex project I found a code sample that someone created because they were having trouble getting the useHandCursor to work. It was pretty obvious what they were trying to do, take a look:
-
<mx:Canvas width="176" height="87">
-
<mx:Link height="100%" width="100%" />
-
<mx:Image width="100%" height="100%"
-
source="@Embed(”images/logo.swf”)"
-
mouseDown="doThis()" />
-
</mx:Canvas>
They obviously wanted to call an event handler when someone clicked on the image, but because they couldn”t get useHandCursor to work, they used an alternative method, albeit not all that pretty.
The solution is rather simple though. Just add a mouseOver event to the component and set it to the following:
-
mouseOver="event.target.onRelease=null;
-
event.target.useHandCursor=true;"
Works pretty much anywhere.
UPDATED For Flex 2:
You may have noticed that the above does not work in Flex 2. This process has been replaced. It is now done through a set of properties that are inherited from the Sprite class.
-
useHandCursor="true"
-
buttonMode="true
-
Add these properties to your component and you”re all set. Now, that was easy!
Tags: Uncategorized
“When you create a SharedObject, Macromedia Flash Player creates a new directory for the application and domain, and creates an empty *.sol file that stores the SharedObject data. The default location of this file is in a subdirectory of the user’’s home directory; for example: c:/Documents and Settings/username/Application Data/Macromedia/Flash Player/web_domain/lso.mxml.swf/. While usually predictable, the location of the StoredObject file can be anywhere that Flash Player has access to within its sandbox and can have any name that Flash Player assigns to it.
By default, Flash can save locally persistent SharedObjects of up to 100K in size. When you try to save a larger set of data, Flash Player displays the Local Storage dialog box, which lets the user allow or deny local storage for the domain that is requesting access.”
Tags: Flash · Flex
One limitation of the Model tag is that if you supply one instance of a child tag in an <mx:Model> tag, there is no way for Flex to know if you intend it to be an array or a single property instance. You can work around this limitation by using an <mx:Object> tag instead of an <mx:Model> tag and declaring an <mx:Array> tag inside the <mx:Object> tag. As an added benefit, you can then dynamically add to the object creating an array of objects.
Here’’s the sample code:
-
<?xml version="1.0" encoding="utf-8"?>
-
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*">
-
-
<mx:Script>
-
<![CDATA[
-
-
-
public function addToModel():Void
-
{
-
-
newRecord.name = "Toby";
-
newRecord.sign = "Leo";
-
newRecord.birthYear = "1984";
-
test[ count++ ] = newRecord;
-
}
-
]]>
-
</mx:Script>
-
-
-
-
<mx:Button label="Add" click="addToModel()"/>
-
-
<Inspect/>
-
-
</mx:Application>
Tags: Uncategorized
So you want to use Eclipse to do Flex 1.5 development? No fluff, I”ll get right to it.
What you are going to do is use the Flex 2 alpha and point it to the Flex 1.5 compiler. This will compile your application into a SWF, which will be put in your web site.
- Start with getting the Flex 2 alpha plug-in (either stand alone or plug-in). Follow the installation instructions, if necessary, to get Flex Builder 2 running. Once it is working, create a new Flex Project using the menu bar: File > New > Flex Project
- Now for the changes. Right-click the project that will use the Flex 1.5 compiler and select Properties. This will open the Properties dialog. In the list on of properties on the left hand side, select Builders. You are going to add a new builder and disable the existing one. When you deselect the existing ”Flex Builder” builder you will get a prompt. Just click OK.
- Click the New button to create a new builder. The configuration chooser dialog will open. Select Program and click OK.
- Now you are ready to set the new builder up. Give it a name like ”Flex 1.5”.
- Set the Location to point to the mxmlc.exe file, most likely something like this: C:\\Program Files\\Macromedia\\Flex\\bin\\mxmlc.exe
- Set the Working Directory to point to the directory holding the compiler. Something like this: C:\\Program Files\\Macromedia\\Flex\\bin\\
- And now the hard part… the arguments. Click the variables button and select the project_loc variable. This is an eclispe variable which has the absolute file system path for the project. Double-click project_loc to select that variable and close the dialog. Now append to the end of the variable the path to the main application mxml for the project. Something like this: ${project_loc}\\Main.mxml
- You need to add two more arguments; one that points to the flex-config.xml, and an output file. To do so, you will add the -configuration switch and the -o output file switch. They will look something like this: -configuration ${project_loc}\\WEB-INF\\flex\\flex-config.xml -o C:\\inetpub\\wwwroot\\mysite\\Main.swf
In the end the arguments will look something like this: ${project_loc}\\Main.mxml -configuration ${project_loc}\\WEB-INF\\flex\\flex-config.xml -o C:\\inetpub\\wwwroot\\mysite\\Main.swf
- One last thing I would do is run your application the old way and copy the source HTML from a dynamically created Flex site (i.e. view source from the browser). Then create a new HTML page with the HTML source you copied. Finally, change the references to the [filename].mxml.swf to your new SWF ([filename].swf)
That’’s it!
Thanks again to Marcin, Sean and Tony for sharing with me.
Tags: Eclipse · Flex