Tony Alves
Flex, .Net, and Fluorine

ArgumentError: Error #2004

Wednesday, 19 September 2007 16:50 by talves
ArgumentError: Error #2004: One of the parameters is invalid.

I hope this will help you out there before you spend too many hours on this one.

Issue that caused the error:
Making a remote call using a RemoteObject that returns back a strongly typed object. The call is made and the Error is triggered before you can capture it in the debugger. I thought I was losing my mind. Everything is exactly the way I have done remote calls a hundred times.

remoteObject.SomeMethod();
SomeMethod() returns a strongly typed class object.

Solution and reason for the error:
Make sure you have an instance of the object referenced in your project. The object is not linked into your .swf upon compiling the project, because there is not a reference to the object anywhere in the project, so the RemoteObject call cannot find the class. What a simple solution, but what a non descriptive error. Now that I read the error it makes a little more sense.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Flex | .NET
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Accessing values across components in Flex

Thursday, 23 August 2007 16:48 by talves
I am working and see an email come in from flexcoders asking how you would access a variables value in one component from another. Easy enough. Well, that is what I thought. I came up with three different answers to this problem and I am convinced there are others. All good enough, but which is best to implement. I will let you decide.

1. Put bindable public variables (properties) on your components and set the values in the parent.
2. Dispatch an event on one component and have the parent component set the other components property.
3. Create a singleton class that holds the values and bind the data to your components, so when there is a change, the values in the components will be set accordingly.

I like the third answer best, but is a bit overkill for the simple implementation that does not need to access the information more than once. The third has more scalability, but takes longer to code.

Demo Example
Source Code

Which would you use? I think it is based on your needs.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   Flex | Examples
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Flex ComboBox using XML

Thursday, 23 August 2007 16:47 by talves
I needed a way to have a ComboBox be able to load values from an XML file.
Requirements:
  • Needed to be able to load XML with a standard format "label" as the value you see and "data" as the value of the selection.
  • Needed a way to set the selected value, so the correct "label" shows as selected (borrowed).
  • Load the XML dynamically by setting the XML path during runtime.
  • XML list in the ComboBox may change without recompiling the application.
I extended the ComboBox in actionscript and added two new properties to be able to accomplish the requirements.
xmlFile="xml/somefile.xml" sets the files path.
selectedValue="somecode" sets the value of the data to be selected.

Country and State Demo using XMLComboBox
View Source

This example uses Country and State/Province. When you select "United States" as the country, the States xml will load. When you select "Canada" as the country, the Provinces xml will load. The selectedValue can be changed during runtime as in the example using the TextInput component and change event.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Flex | Examples
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Seperate Module Projects in Flex Builder

Tuesday, 21 August 2007 16:46 by talves
I just finished splitting my modules from my main project to a separate project to be able to use the -load-externs and -link-report compiler arguments. The benefit is great when using the seperated project technique. Especially if you follow strict modular programming techniques that have encapsulation. It cut my modules down from 680k to 250k. I suspect my module will now load close to 3 times faster than before (2.72 to be exact).

I read the following documentation to get the specifics on loading modules and setting up different strategies in my projects.
Here is the Adobe Blog Entry
Here is the Adobe PDF of the documentation.
Here are the Adobe examples from the documentation.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Flex | Examples
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed