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 exampleso 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:
and here is my class which should invoke the xml file.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); } } }
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:
and thenTypeError: Error #2007: Parameter child not allowed to be 'null'.
at flash.display:: DisplayObjectContainer/addChild()
at com.spring::AS_Spring_Example()
if im running the rectangle class "ExampleClass" then "of course" i get the error message: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()
so how can i draw my rectangle?ArgumentError: Error #1063: inconsistent arguments for com.spring::ExampleClass(). 1 expect, 0 recieved.
It would be nice if u could help me and give me a solution. im saying thank u already and hope the best![]()


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.
Reply With Quote
its working fine but i have to get used with flex.