Announcement Announcement Module
Collapse
No announcement yet.
how to setup springactionscript? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to setup springactionscript?

    Hi,

    im new in this forum. i hope u can help me. im interested in springactionscript and want to use it. my problem is how to start? :/

    im using fdt as my ide and flex4sdk as my core library also added sprinactionscript 0.7.1 swc.

    i just want to start but first i need a good example so i tried to draw a rectangle. the constructor of my class which is drawing my rectangle needs only one argument. this argument i want to assign with spring actionscript.

    a simple xml file:
    <?xml version="1.0" encoding="utf-8"?>
    <objects xmlns="http://www.springactionscript.org/schema/objects"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springactionscript.org/schema/objects
    http://www.springactionscript.org/schema/objects/spring-actionscript-objects-1.0.xsd">


    <object id="exampleObject" class="com.spring.ExampleClass">
    <constructor-arg value="600"/>
    </object>


    </objects>

    here is my drawing rectangle class:

    Code:
    package com.spring {
    	import flash.display.Shape;
    	import flash.display.Sprite;
    
    	public class ExampleClass extends Sprite {
    
    		public function ExampleClass(width:int) {
    			
    			
    			var rectPoint4 : Shape = new Shape();
    			rectPoint4.graphics.lineStyle(1, 0x0099FF, 1);
    			rectPoint4.graphics.beginFill(0x0099FF);
    			rectPoint4.graphics.drawRect(- 3,- 3, width, 700);
    			rectPoint4.graphics.endFill();
    			addChild(rectPoint4);		
    			
    		}
    				
    	}
    }
    and here is my class which should invoke the xml file.

    Code:
    package com.spring{
    	import org.springextensions.actionscript.context.support.XMLApplicationContext;
    		
    	import flash.display.Sprite;
    	import flash.events.Event;
    
    	public class AS_Spring_Example extends Sprite{
    		private var applicationContext : XMLApplicationContext;
    
    		private var myObject:ExampleClass;
    
    		
    		public function AS_Spring_Example(){
    			
    			applicationContext = new XMLApplicationContext();
    			applicationContext.addConfigLocation("Application_Context.xml");
    			applicationContext.addEventListener(Event.COMPLETE, handleComplete);
    			applicationContext.load();
    			
    		}
    		
    		public function handleComplete(event : Event) : void {
    			trace("AS_Spring_Example instantiated");
    			myObject = applicationContext.getObject("exampleObject") as ExampleClass;
    			
    		}
    	}
    }

    my question is, what shall i do now?:/
    shall i write "addChild(myObject);" in the "AS_Spring_Example" Constructor? It doesnt work. if i run the AS_Spring_Example class i get first the error message:
    TypeError: Error #2007: Parameter child not allowed to be 'null'.
    at flash.display:: DisplayObjectContainer/addChild()
    at com.spring::AS_Spring_Example()
    and then

    Error: An object definition for 'exampleObject' was not found.
    at org.springextensions.actionscript.ioc.factory.supp ort::AbstractObjectFactory/getObject()
    at com.spring::AS_Spring_Example/handleComplete()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_doParse()
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_loadNextProperties()
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_loadNextConfigLocation()
    at org.springextensions.actionscript.ioc.factory.xml: :XMLObjectFactory/_onLoaderComplete()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
    if im running the rectangle class "ExampleClass" then "of course" i get the error message:
    ArgumentError: Error #1063: inconsistent arguments for com.spring::ExampleClass(). 1 expect, 0 recieved.
    so how can i draw my rectangle?

    It would be nice if u could help me and give me a solution. im saying thank u already and hope the best
    Last edited by Falko; Jun 24th, 2009, 06:30 AM.

  • #2
    same problem

    Hey Falko,

    I'm pretty sure your suffering from the same problems as the person in this thread:

    http://forum.springsource.org/showthread.php?t=73932

    The problem is you're using the new namespaces for the upcoming version 0.8 but are including the version 0.7.1 of the library.

    hope this helps,

    cheers,

    Roland

    Comment


    • #3
      change to flex builder

      thank u for ur suggestion but it's still not working:/

      it seems like i dont get it to start with fdt. so i changed my ide and im using now flexbuilder3 its working fine but i have to get used with flex.

      im still interested how to use springas in fdt, so if somebody have an idea it would be nice

      thank u again and i wish a nice weekend!

      Comment


      • #4
        not working in FDT?

        Hi Falko,

        I find it incredibly strange that it would not work with FDT to be honest, and also don't have any clear suggestions what might be the problem.

        I myself am not an FDT user, so I can't really say much about it. So I hope there's other users on the forum here who do use FDT and might be able to help you out.

        If you find out what the problem was then please report it here as well, if its an FDT specific issue I'd like to include it in the documentation for future reference.

        thanks,

        Roland

        Comment

        Working...
        X