WebService and ActionScript class
Hi,
I am trying to create an actionscript class to use it in my
mxml component.
I have the floowing code which works perfectly.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application creationComplete="HTTPdecision.send()"
xmlns:mx="
http://www.adobe.com/2006/mxml"
width="870">
<mx:Script>
<![CDATA[
import mx.rpc.events.ResultEvent;
import com.sourcepulse.com.dtRulesClass;
private var endURI:XML;
private var URI:XMLList;
private function setURI(event:ResultEvent):void
endURI = event.result as XML;
URI = new XMLList(endURI.endpoint.webservice.location);
Test.endpointURI= URI.toString();
]]>
</mx:Script>
<mx:HTTPService id="HTTPdecision"
url="../XML/endpointURI.xml" resultFormat="e4x"
result="setURI(event)" />
<mx:WebService service="amazon" port="amazonSOAP"
id="Test"
wsdl="
http://localhost:9081/ezbuyer/amazon/services/amazonSOAP/wsdl/amazon.wsdl"
>
<mx:operation name="getISBNDetails">
<mx:request xmlns="">
<isbnSearchRequest>
<bookName>{txtBookName.text}</bookName>
<category>{txtCategory.text}</category>
</isbnSearchRequest>
</mx:request>
</mx:operation>
</mx:WebService>
<mx:Panel x="100" y="100" width="600" height="500"
layout="absolute"
title="Amazon WebService">
<mx:VBox height="400">
<mx:VBox>
<mx:Form width="400" height="145" autoLayout="true">
<mx:FormHeading label="Specify the following:"/>
<mx:FormItem width="307" label="BookName :">
<mx:TextInput id="txtBookName"/>
</mx:FormItem>
<mx:FormItem width="308" label="Category :">
<mx:TextInput id="txtCategory" />
</mx:FormItem>
<mx:FormItem width="312">
<mx:Button label="Test"
click="Test.getISBNDetails.send()"/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
<mx:VBox>
<mx:Form width="400" height="122" autoLayout="true">
<mx:FormHeading label="Book Details:"/>
<mx:FormItem width="307" label="ISBN :">
<mx:Text text="{Test.getISBNDetails.lastResult.isbn}"
/>
</mx:FormItem>
<mx:FormItem width="308" label="Author :">
<mx:Text text="{Test.getISBNDetails.lastResult.author}"
/>
</mx:FormItem>
</mx:Form>
</mx:VBox>
</mx:VBox>
</mx:Panel>
</mx:Application>
Now instead of binding the input from the textboxes directly
as in the above code
<mx:request xmlns="">
<isbnSearchRequest>
<bookName>{txtBookName.text}</bookName>
<category>{txtCategory.text}</category>
</isbnSearchRequest>
</mx:request>
I created an actionscript class
package com.xxxx.com
public class simpleTest
//Instance Variables
private var bookName:String;
private var category:String;
public function simpleTest()
function getBookName():String {
return bookName;
function setBookName(bookName:String):Void {
this.bookName = bookName;
function getCategory():String {
return category;
function setCategory(category:String):Void {
this.category = category;
How can I use this ActionScript class to use in
<bookName>{txtBookName.text}</bookName>.
Thanks in advance.
I think you're close to achieving what you want... first I
would change your getter and setter methods just a bit to make them
properties. Second add the [Bindable] meta tag in front of one of
each of the group of properties (i.e. you don't need it in front of
both the get and set method, just one of them).
i.e.
[Bindable]
public function get category():String {
return category;
public function set category(value:String):void{
category = value;
then in your mxml you can "bind" to each property you've
defined in the class. so if you create a new instance of your
simpleTest class called "test" you could do the following:
<mx:Label text="{test.category}" />
Similar Messages
-
MXML Components and ActionScript Classes
Hello,
I am fairly new to Flex and OOP and am confused on how some parts of OOP work.
I have a Spark TextInput Component with an id which equals "test".
I also have a function that takes "test.text", appends a string to and and puts the resulting value into another TestInput called test2.
How can I move the "appendPhrase()" function into a class so that it would still accept values from "test" and change the "text2" values?
I tried creating a function that would assign the value of the varaible in the class using classname.variable name, made it bindable, and assigned
the text value of the textinput that value, but I was wondering if there was any other way I could do that?
~~~~~~~~~~~~~~~~Version1~~~~~~~~~~~~~~~~~~~~~
<fx:Script>
private function appendPhrase():void
test2.text = test.text + " was added";
</fx:Script>
<s:TextInput x="0" y="0" id="test" />
<s:TextInput x="0" y="10" id="test2" />
<s:Button click="appendPhrase();" />
~~~~~~~~~~~~~~~~~~Version 2:~~~~~~~~~~~~~~~~~
function in class:
public class ChangeString
[Bindable]
public var text:String;
private function appendPhrase(firstString:Object):void
text = firstString.text + " was added";
main.mxml:
[Bindable]
public var changed:Object = new ChangeString();
<s:TextInput x="0" y="0" id="test" click="changeValue(test.text)" />
<s:TextInput x="0" y="10" id="test2" text="{changed.text}"/>package models
[Bindable]
public class MyViewModel
public var text:String "Hello ";
public function appendText(t:String):String
this.text = this.text + t;
return this.text;
<fx:Script>
<![CDATA[
import models.MyViewModel;
[Bindable]
public var model:MyViewModel = new MyViewModel();
]]>
</fx:Script>
<s:TextInput id="test" x="0" y="0" click="this.model.appendText(this.test.text)" text="World" />
<s:TextInput id="test2" x="0" y="10" text="{this.model.text}" />
I would go about it a little differently maybe. I would use the model class as a data holder, and use a private local method, utility class, or controller class to modify values on the model (data holder class). -
Flex RPC mapping Java nested classes to ActionScript classes
We are calling a Java method in our project using
RemoteObject the value returned by the java method is a ArrayList
containing instances of a class say ParentClass with some nested
classes.
The structure of ParentClass(Java) is something like this
class ParentClass {
//some primitives
private ChildClassA childAInstance;
private ChildClassB childBInstance;
//getters setters
We have created similar class structure on the ActionScript
side, the ActionScript classes(ParentClass,ChildClassA
,ChildClassB) have been properly annotated with the [RemoteClass]
metadata tag,
The problem is that though i'm getting the primitive data
members of the ParentClass through RPC in my corresponding AS
ParentClass class i'm getting an runtime exception trying to access
ChildClassA,ChildClassB members.
Am i missing something, exactly the same scenario is
mentioned in this article
http://www.adobe.com/devnet/flex/articles/complex_data.html
But the Object.registerClass method mentioned in the tutorial
is giving me compilation error, the sample code attached with the
article is corrupt zip too.
Please help me out on thisJAXB will create classes from an XML schema, SAX is a parser library and JAXP is a library of XML a bunch of XML tools.
I don't care for JAXB too much. I would skip it and go right to the JAX-RPC spec (WebServices). -
Error in Importing webservice via ActionScript
Hi All
This is regarding the Webservice via ActionScript (Import->Web Service) for Flex 3
I am using the same method to import the webservice. The proxy classes are getting generated. I am using the following code for accessing the method:
var myVar:Welcome = new Welcome();
myVar.name = "shilpa";
var myService:WelcomeNoteService = new WelcomeNoteService();
myService.addwelcomeEventListener(handleResult);
myServ.addWelcomeNoteServiceFaultEventListener(handleFault);
myService.welcome(myVar);
Here Welcome is the function name in webservice (for which proxy class is generated) and WelcomeNoteService is the webservice name (for which proxy classes is also generated).
When I try to access
public function handleResult(event:WelcomeResultEvent):void{
Alert.show(event.result.toString());
event.result is coming as null.
I have tried to debug also , but not able to find the error.Hi,
<i>My dev is on SP 15 and Cons on SP 10..While transporting SLD product using file system i got following error:
</i>
See SAP Note 832142 for known restrictions about transporting objects between
different XI 3.0 support packages And See SAP Note 834507 for known restrictions about cross-release transports.
Also see the CMS Guide at market place, how to guide,
https://websmp201.sap-ag.de/~form/sapnet?_FRAME=CONTAINER&_OBJECT=011000358700003090422005E
Also refer 780297 for continiuosly updated errors.
May be all this will help you to analyse if not directly arrive at the solution.
All the best,
Anirban. -
Using webServices and Interactive Statement
I'd like to know how can I get information about how to create an Interactive statement that use a webservice.
I can't find something useful on this topic on internet or the official documentation...
Any help?
Regards!Whether inside an Interactive Statement or not, the use of a webservice in Flex is the same:
Step 1. Find a webservice you want to use.
(Here is a public wsdl connection for testing/proof of concept: http://www.webservicex.net/WeatherForecast.asmx?WSDL )
Step 2. Use it, as shown in this example: http://www.cflex.net/showFileDetails.cfm?ObjectID=582
More info on how to use Flex webservices:
http://tv.adobe.com/watch/flex-in-a-week-day-2/retrieving-and-handling-data-using-webservi ce/
http://blogs.4point.com/brad.white/2008/12/4-ways-to-invoke-a-webservice-in-flex-with-mxml -and-actionscript.html
http://blog.flexexamples.com/2008/04/14/calling-a-simple-web-service-from-flex-using-the-w ebservice-class/
Hope it helps,
Oana -
Urgent - Binding Webservice lastresult to class-based models
Hi,
I am using mx:Webservice to get and show data in my app. I am
able to bind the lastResult of the webservice method to
ArrayCollection and display data in my UI. But what I want to do is
bind the lastResult to a class-based model defined as ActionScript
class. Is this possible ?
Likewise, I will send a complex data to my server through a
webservice method. I am planning to use the AS class as a parameter
for one of my webservices. What about this ?
Thanks,
KarakoyunAutomatically mapping QNames to strongly typed Classes for
complexTypes on deserializing a SOAP response is not possible in
Flex 2, but will be possible in Flex 3. The mechanism is not yet
documented so stay tuned.
As for sending strongly typed data as input to operations,
this should work already today. -
How to call setter Method of ActionScript class with in a Flex Application
Hi
I have Action class as shown :
public class MyClass
private var name:String
public function get name():String {
return _initialCount;
public function set name(name:String):void {
name = name;
Now please let me know how can i access this Action class under my Flex Application and call the setter Method of it to set the value for the name .
For example on entering some data in a TextInput and click of a submit Button , on to the Event Listener , i want to call the set name method of my ActionScript class .
Please share your ideas on this .Thanks Gordon for your resonse .
Say for example my Action class is like this :
public class MyClass
private var name:String
public function get name():String {
return name;
public function set name(name:String):void {
name = name;
This is inside the MXML
I know this way we can do it
public var myclass:MyClass = new MyClass();
myclass.name="Kiran";
Now my query is can we do in this way also ??
myclass.set name(SomeTextInput.text);
Please share your views on this , waiting for your replies .
Thanks in advance . -
Consuming a webservice and attributes
I'm trying to noodle my way thru consuming a webservice and
it is not making sense when I'm trying to get attributes from a
webservice. Can someone point me in the right direction. I've
included what the xml output looks like and my cfinvoke and a
cfdump of the invoke return variable. I just don't know how to
bring back that array of course ids??
The service returns course ids
<?xml version="1.0" encoding="utf-8" ?>
- <Courses>
<Course CourseID="1167" CourseName="Human Performance
Tools - Self Checking" />
<Course CourseID="1168" CourseName="Human Perfomance
Tools - 3 Way Communication" />
<Course CourseID="1169" CourseName="Human Performance
Tools - Phonetic Alphabet" />
<Course CourseID="1170" CourseName="Human Performance
Tools - Pre-Job Briefing" />
<Course CourseID="1171" CourseName="Initial Plant Access
Training" PadsCode="PAT034" />
<Course CourseID="1172" CourseName="Initial Radiation
Worker Training" PadsCode="RWT" />
<Course CourseID="1224" CourseName="Plant Access Requal
Training" PadsCode="PAT034" />
<Course CourseID="1225" CourseName="RWT Requal Training"
PadsCode="RWQ" />
<Course CourseID="1226" CourseName="Proctoring
Responsibilities" />
<Course CourseID="1235" CourseName="Generic Confined
Space" />
<Course CourseID="1236" CourseName="Generic Fall
Protection" />
</Courses>
object of
org.tempuri.LMSWebSvc.LMS_Interface.GetCoursesResponseGetCoursesResult
Methods hashCode (returns int)
equals (returns boolean)
getSerializer (returns interface
org.apache.axis.encoding.Serializer)
getDeserializer (returns interface
org.apache.axis.encoding.Deserializer)
getTypeDesc (returns org.apache.axis.description.TypeDesc)
get_any (returns [Lorg.apache.axis.message.MessageElement;)
set_any (returns void)
getClass (returns java.lang.Class)
wait (returns void)
wait (returns void)
wait (returns void)
notify (returns void)
notifyAll (returns void)
toString (returns java.lang.String)I found a way to get the soap request into an xml document.
It was not intuitive to me but works.
Basically rereading this post:
http://www.houseoffusion.com/cf_lists/messages.cfm/forumid:4/threadid:44797#233359
gave me more insight. The tostring function appears to allow me to
get the raw xml that CF is struggling to noodle out. -
What is the difference between document class and normal class
Hi,
Please let me know what is the difference between document class and normal class.
And I have no idea which class should call as document class or call as an object.
Thanks
-Actionscript Developerthe document class is invoked immediately when your swf opens. the document class must subclass the sprite or movieclip class.
all other classes are invoked explicitly with code and need not subclass any other class. -
Mapping existing actionscript class (mx.collections.SortField) to java
Hi,
I would like to map the existing SortField actionscript class on a SortField class on my java backend.
Is it possible to map an actionscript class from standard flex API to a java class? If so, how?
ThanksYeah, there is something awry with your mapped classes. You don't use the java source files to map your classes, you use AS3
classes that are designated to which classes they map to on the backend. Observe..
package shared.servicevos
import flash.events.EventDispatcher;
import flash.events.IEventDispatcher;
[Bindable]
[RemoteClass(alias="amf.ShopperVO")]
public class ShopperVO
public var shopperId:int;
public var shopperLocation:String;
public var shopDate:Date;
public var shopperAddress:Address
If you notice the the metadata beginning with "RemoteClass", I am telling Flex "when you see an object that comes in with this type "alias" it is should be made into a ShopperVO". On the backend, I have a folder with a directory structure of /amf and it contains a ShopperVO.java class.
P.S This isn't exactly the setup I am working with cause I am using php, but the ideas are the same. -
Converting MXML Components to ActionScript Classes
I'm in the process of converting most (if not all) of my MXML
components to Action Script classes. I've found this is easy, and
doesn't require a lot of extra code when extending a simple
container or control. However, several of my MXML components have
several nested containers and controls - i.e. a component that
contains several Labels, a ComboBox, a TextInput, a Button, and a
DataGrid, plus several other containers needed for layout. To code
the layout of all these containers and controls using MXML, it uses
about 16 lines of code. To code the layout in ActionScript, it
takes about 50+ lines of code (see attached).
I'm just wondering if there are any best practices for
creating ActionScript classes that include several (or even A LOT
OF) containers and controls. It's very easy to layout in MXML, and
is more visibly pleasing to look at and understand, but I feel it
is best practice to code components as ActionScript classes. I know
I should be using MVC, but it's a little late to rewrite the entire
application now.
Any thoughts?I can't specifically speak to how to write layout code in
ActionScript, but you can look at the generated code that Flex
creates to get an idea of how Flex does it. When you compile an
app, the Flex compiler takes your MXML input and converts it to
ActionScript classes before compiling the entire set of classes
into a SWF. Because of this, you can look at the interim
ActionScript code.
You do this by setting the keep-generated-actionscript
compiler option to true and looking in the /generated directory.
hth,
matt horn
flex docs -
Browser not responding when there is a Exception in ActionScript class
Hi ,
I am trying to debug my Application , so under the ActionScript lass i am using some
trace print messages .
But the Problem is that when ever there is an Exception on to my ActionScript class , the browser is not responding
Means i need to manually close the Browser by killing the process itself .
I guess there is something problem with the FlashPlayer tat is runnning the swf file .
could anybody please let me know how to resolve this issue .When there is an exception, you need to manually close the browser by either clicking on the close button of browser or stop button of the debugger. There is another button in debugger which allows you to ignore the exception and resume execution. It looks like a play button with green color.
-
How to Access MXML components from ActionScript class
Hi ,
I am having a Application Conataner , in which i am having a Form Container with some Label in it .
This is some thing similar to this as shown :
<Mx:Application>
<Mx:Form>
<Mx:Label text="Hello world"/>
</Mx:Form>
</Mx:Application>
Can any body please let me know how can i access this Form's Label , from an ActionScript class .
catch(error:*)
// Here i want to access these Objects and set data to that Label .
Basically My requirement is that iinside the catch block of my ActionScript class , i want to set some text to the Label , Please
let me know if this is possible or not also ??
Waiting for your Replies .Hi these both are not same these refer to different one...
Well let me explain...
Application.application.myCustomComp.myLabel.text = "sometext"; sets the label "myLabel" which is present inside your customcomponent(which is in main application).
Application.application.myLabel.text = "sometext"; sets the label "myLabel" which is present directly inside your main application.
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Label id="myLabel" text=""/> // So inorder to set the label(myLabel) present here you will use directly the 2nd line of code.
<mx:CustomComp id="myCustomComp" /> // So inorder to set the label(myLabel) present inside this component you use 1st line of code.
</mx:Application>
Hope now its clear.
If this post answers your question or helps, please kindly mark it as such.
Thanks,
Bhasker Chari -
Problem in contacting MXML from ActionScript class catch block
When ever there is a exception inside the ActionScript class , i want to access the MXML TextInputId and dispplay an error Message on to it , but i am unable to succeed.
This is the code i am using
<mx:Application>
<mx:TextInput id="MyTI"/>
</mx:Application>
Inside ActionScript class :
catch(error:Error)
Application.application.MyTI.text="Error Submitting Data"
Need your suggestions to implement this .
Thanks in advanceHi Kiran,
It should defenitely wor for you...
Try to debug and check whether the control is entering into the catch block.
Thanks,
Bhasker Chari -
ActionScript class being run by mistake in Flex project
I have a Flex project where my main MXML file is set as the
one and only application file and is also set as the default file.
I also have an ActionScript class in the project that extends
Sprite. It is _not_ set as an Application file.
When I have the ActionScript class selected, if I hit run or
debug, FB3 creates a new launch configuration for it and tries to
run the AS file instead of the default application MXML file.
Needless to say, this is really annoying as it means I have
to select the main MXML file before hitting debug/run every time.
Is this a bug or feature? (Feels like a bug).
Thanks,
AralHi Aral,
Can you please log it in our public bug system:
http://bugs.adobe.com/flex?
It'd be great if you can provide more info to the bug e.g.
reproducible steps, platform, FB version (Plugin or Standalone).
thanks,
Sharon
Maybe you are looking for
-
Hio everybody. Can someone help-me with this case: My administrative user need to create more than one automatic payment for the same vendor but for different invoices/payment method. But when a vendor is contained in another proposal you cannot sele
-
Essbase 9.3.1 Currency Conversion @ Prior Rate
I am trying to convert some Balance Sheet figures for Jan 2011 data using Dec 2010 Exchange rate. However the calc script will not reference Dec 2010 Xchg rate, it ONLY references Jan 2011 Xchg rate! Config File: CCTRACK FALSE Currency Outline: Time
-
A possible *bug* in java jcombobox
Hi all, I think i found a possible bug in java jcombobox .. i am sure some of you must have already experienced it.. supposedly you put a jcombobox in a jpanel returned the panel from a method to a calling method.. and that method adds it to another
-
SPAM update - LOAD_PROGRAM_CLASS_MISMATCH
Hello, I am just preparing for an upgrade to our DEV ECC system. I have the patches downloaded and ready to go in EPS/In I've run the SPAM update in the usual way and seen this error: Runtime Errors LOAD_PROGRAM_CLASS_MISMATCH Date and Time
-
Duplex Printing with Deskjet 9800
I Bought a Deskjet 9800 and then ordered the appropriate Duplex UNit. The duplexunit was working very well until about 2 months ago. However, after my system crashed and had to reinstall Vista Ultimate. I have tried to go through the configuration