|
From: Stephan B. <be...@xs...> - 2008-03-18 18:39:01
|
Hi Mandy, If you're starting with learning Actionscript, we very much recommend starting with Actionscript 3, and not Actionscript 2, since AS3 is the language of the future for the Flash player. Especially for people with backend experience, Actionscript 3 makes a lot more sense, as the API is a lot more consistent and logical, and therefore much easier in daily use. So get your hands on tools like Flash CS3, Flex Builder 3, FlashDevelop 3, or Eclipse with FDT3, and you can write for Flash player 9, AIR, Flex etc. We wrote ASAPLibrary in AS2, and have now also moved on to AS3, for which we are currently working on ASAPLibrary (http://www.asaplibrary.org/ ). We're not developing ASAPLibrary anymore, but put our effort into ASAPLibrary. If you intend to write tutorials, we'd be most happy to assist in any way we can, but preferably for AS3, and not AS2. As for the code below, AS2 requires the use of delegate functionality to regain scope. Basically, when you write myXMLLoader.addEventListener( XMLEvent.ON_LOADED, this ); the function onXMLLoaded is run in the scope of the object where the event originated, i.e. myXMLLoader. So inside the scope of the function, you suddenly lose access to the properties & methods of the enclosing class. I know, it's a pain, but to circumvent this, Adobe came up with the Delegate class, that was extended & enhanced in ASAPFramework by the EventDelegate class. This moves the scope back into the enclosing class. So you should write: myXMLLoader.addEventListener(XMLEvent.ON_LOADED, EventDelegate.create(this, handleXMLLoaded); private function handleXMLLoaded (e:XMLEvent) : Void { trace("handleXMLLoaded : " + e.name); } In AS3, scope is retained, and you can write myXMLLoader.addEventListener(XMLEvent.ON_LOADED, handleXMLLoaded); Hope this helps! Cheers, Stephan On 18 mrt 2008, at 17:11, Mandy Singh wrote: > Hello Everyone, > > I am actually a backend programmer and now beginning actionscript to > create some widgets. > > In order to do that I first searched on the net for a library/ > framework that might make life simpler and came across asap. > > Is this project still alive? I don't see much activity. > > Anyways, since I am a beginner I have foolish questions and the > little bit documentation didn't help me at all. > > I just wanted to use the XMLLoader class and had to experiment a > little. > > Want to know if my usuage is correct? (If I really get into this > library, I intent to write beginner tutorials for people like me who > find it hard to read code in a language that they have no idea > about :) > > var myXMLLoader:XMLLoader = XMLLoader.getInstance(); > myXMLLoader.addEventListener( XMLEvent.ON_LOADED, this ); > myXMLLoader.addEventListener( XMLEvent.ON_ERROR, this ); > myXMLLoader.load("photoAlbum.xml", "myFile", true); > > function onXMLLoaded (e:XMLEvent) : Void { > //trace(myXMLLoader); > //ObjectUtils.traceObject(e,2); > // handle result > //trace(e.error); > trace(e.xmlSource); > trace('file has loaded'); > var xmlData:Object = XML2Object.parseXML( e.xmlSource ); > ObjectUtils.traceObject(xmlData, 50); > //trace(xmlData.days.subscription.data); > //trace(xmlData.days.subscription.attributes.num); > } > > function onXMLLoadError(e:XMLEvent) { > trace("Error is - " + e.error); > //ObjectUtils.traceObject(e,5); > } > > Have I used the above correctly? > > Can someone shed light on this? > > Thank you, > Mandy > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________ > Asapframework-support mailing list > Asa...@li... > https://lists.sourceforge.net/lists/listinfo/asapframework-support -- Stephan Bezoen be...@xs... |