tag:robotlegs.tenderapp.com,2009-10-18:/discussions/problems/199-context-in-flashbuilder-gives-error-type-1136-incorrect-number-of-arguments-expected-1Robotlegs: Discussion 2018-10-18T16:35:19Ztag:robotlegs.tenderapp.com,2009-10-18:Comment/36005582010-11-01T22:08:51Z2010-11-01T22:08:51ZContext in FlashBuilder gives error Type 1136: Incorrect number of arguments. Expected 1. <div><p>Hi Tim,</p>
<p>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:</p>
<pre><code><?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.*">
<fx:Declarations>
<local:ServiceExampleContext contextView="{this}"/>
</fx:Declarations>
<components:SearchResultsView/>
</s:Application></code></pre>
<blockquote><p>Context class needs 1 parameter to be passed to the constructor and MXML cannot pass parameters to constructors.</p></blockquote>
<p>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?</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/36005582010-11-02T12:41:05Z2010-11-02T12:41:07ZContext in FlashBuilder gives error Type 1136: Incorrect number of arguments. Expected 1. <div><p>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 <a href="http://insideria.com/2010/06/an-introduction-to-robotlegs-a-2.html">Joel Hooks Service tutorial</a>. I meant to delete it before posting.</p>
<p>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.</p>
<p>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? <em>itching neck</em></p>
<p>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?</p></div>timkindbergtag:robotlegs.tenderapp.com,2009-10-18:Comment/36005582010-11-02T13:26:32Z2010-11-02T13:26:32ZContext in FlashBuilder gives error Type 1136: Incorrect number of arguments. Expected 1. <div><blockquote><p>I had added the Script block because it was the only way I could get it to work</p></blockquote>
<p>Hmm.. something is very wrong then. It should work fine without it. It's redundant and makes your root mxml file look pretty gross.</p>
<blockquote><p>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</p></blockquote>
<p>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.</p>
<p>Joel is obviously uber busy at the mo, but hopefully he'll pop by soon and offer some input.</p></div>Shaun Smithtag:robotlegs.tenderapp.com,2009-10-18:Comment/36005582010-11-02T13:36:57Z2010-11-02T13:36:57ZContext in FlashBuilder gives error Type 1136: Incorrect number of arguments. Expected 1. <div><p>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.</p>
<p>Now I am able to delete the Script tag and only have the MXML declaration of Context and the SearchResultsView component.</p>
<p>You've been very helpful :) It turns out it was just a newb.</p></div>timkindbergtag:robotlegs.tenderapp.com,2009-10-18:Comment/36005582010-11-02T13:40:12Z2010-11-02T13:40:12ZContext in FlashBuilder gives error Type 1136: Incorrect number of arguments. Expected 1. <div><p>Just to clarify to followup readers, the issue was that I still had the old constructor in my concrete Context class.</p>
<p>I had this:<br />
</p>
<pre><code>public class ServiceExampleContext extends Context
{
/**
* Constructor
*/
public function ServiceExampleContext(contextView:DisplayObjectContainer)
{
super(contextView);
}
override public function startup():void
{
mediatorMap.mapView(SearchResultsView, SearchResultsViewMediator);
injector.mapSingletonOf(ISearchService, TwitterSearchService);
injector.mapSingletonOf(ISearchResultsParser, TwitterSearchResultsParser);
}
}</code></pre>
<p>Which needed to be this (removed constructor):<br />
</p>
<pre><code>public class ServiceExampleContext extends Context
{
override public function startup():void
{
mediatorMap.mapView(SearchResultsView, SearchResultsViewMediator);
injector.mapSingletonOf(ISearchService, TwitterSearchService);
injector.mapSingletonOf(ISearchResultsParser, TwitterSearchResultsParser);
}
}</code></pre></div>timkindberg