Context in FlashBuilder gives error Type 1136: Incorrect number of arguments. Expected 1.
In an MXML file I have this code from Joel Hooks Service tutorial:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="300" height="300"
xmlns:local="*"
xmlns:components="components.*"
creationComplete="application1_creationCompleteHandler(event)">
<fx:Script>
<![CDATA[
import components.SearchResultsView;
import mx.events.FlexEvent;
protected function application1_creationCompleteHandler(event:FlexEvent):void
{
var context:ServiceExampleContext = new ServiceExampleContext(this);
var searchResultsView:SearchResultsView = new SearchResultsView();
addElement(searchResultsView);
}
]]>
</fx:Script>
<fx:Declarations>
<local:ServiceExampleContext contextView="{this}"/>
</fx:Declarations>
<components:SearchResultsView/>
</s:Application>
I keep getting the error Type 1136: Incorrect number of arguments. Expected 1.
because the Context class needs 1 parameter to be passed to the constructor and MXML cannot pass parameters to constructors.
How are people getting around this?
Comments are currently closed for this discussion. You can start a new one.
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Shaun Smith on 01 Nov, 2010 10:08 PM
Hi Tim,
Where does that code come from? It looks pretty broken to me - everything is doubled up (both the context initialization and the SearchResultsView addition). Try deleting the script block and creationComplete handler and updating to the latest version of Robotlegs. It should look something like this:
The Context should not have any required constructor arguments when working with MXML (unless you are working with a pre-1.0.0 version of Robotlegs). Perhaps the tutorial you are following is very old?
2 Posted by timkindberg on 02 Nov, 2010 12:41 PM
Hi Shaun, Thank you for the quick reply! I'm sorry, I had added the Script block because it was the only way I could get it to work. It's from Joel Hooks Service tutorial. I meant to delete it before posting.
I have the robotlegs-framework-v1.3.0.swc in my libs folder, so unless the swc was compiled incorrectly I have the latest version.
I just commented out the Script block and published and it works in the HTML publish but I still get the error (red overlay X icon) on my MXML file in FlashBuilder 4. I'm pretty OCD, does that ever go away or I just have to live with it? itching neck
Also a quick side question. In that tutorial he calls a class called HTMLStringTools, which I would assume is in the as3corelib.swc, but it's not there. A search for it on the internet literally returns only 2 results, neither helpful. Do you know where the heck he could be getting that class from?
Support Staff 3 Posted by Shaun Smith on 02 Nov, 2010 01:26 PM
Hmm.. something is very wrong then. It should work fine without it. It's redundant and makes your root mxml file look pretty gross.
Not a chance mate! I doubt there is a single RL user who would be okay with any errors/warnings - something is definitely wrong with your setup. You should have 0 constructor arguments in your concrete Context. Make sure to "clean" your FB project.
Joel is obviously uber busy at the mo, but hopefully he'll pop by soon and offer some input.
4 Posted by timkindberg on 02 Nov, 2010 01:36 PM
That was it. I still had the constructor arguments in my actual constructor class. I just deleted the constructor completely and only kept the startup function. I thought the Context constructor parameter was mandatory, I didn't think I was allowed to delete it. So now I know.
Now I am able to delete the Script tag and only have the MXML declaration of Context and the SearchResultsView component.
You've been very helpful :) It turns out it was just a newb.
timkindberg closed this discussion on 02 Nov, 2010 01:37 PM.
timkindberg re-opened this discussion on 02 Nov, 2010 01:40 PM
5 Posted by timkindberg on 02 Nov, 2010 01:40 PM
Just to clarify to followup readers, the issue was that I still had the old constructor in my concrete Context class.
I had this:
Which needed to be this (removed constructor):
timkindberg closed this discussion on 02 Nov, 2010 01:40 PM.