Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,404 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,448 people online right now. Registration is fast and FREE... Join Now!




Flex2/AS3 - Dynamic objects

 
Reply to this topicStart new topic

Flex2/AS3 - Dynamic objects, Help creating dynamic objects

NyGrrl
3 Sep, 2008 - 05:28 PM
Post #1

New D.I.C Head
*

Joined: 1 Apr, 2007
Posts: 16


My Contributions
Hi All...I'm writing an application that uses XMLSockets. I get packets from the remote server and process them, each class that handles the packet has a processResponse(packet:XML) function. Currently I have a case statement that goes through and decides which class will handle the packet. Like this:

CODE

        public override function dataHandler(event:DataEvent):void {

            var packet:XML = new XML(event.data);
            var response_type:String = packet.@type;
            
            switch(response_type){
                case "LOGIN":
                    var login:IqResponseLogin = new IqResponseLogin();
                    login.processResponse(packet);
                    break;
                case "AGENT-STATE":
                    var state:IqResponseAgentState = new IqResponseAgentState();
                    state.processResponse(packet);
                    break;
                case "GENERIC":
                    var generic:IqGeneric = new IqGeneric();
                    generic.processResponse(packet);
                    break;
                case "OFF-HOOK-TERM":
                    var offhookterm:IqNotificationOffHookTerm = new IqNotificationOffHookTerm();
                    offhookterm.processResponse(packet);
                    break;                    
                case "OFF-HOOK-INIT":
                    var offhookinit:IqResponseOffHookInit = new IqResponseOffHookInit();
                    offhookinit.processResponse(packet);
                    break;
                case "NEW-CALL":
                    var newCall:IqNotificationNewCall = new IqNotificationNewCall();
                    newCall.processResponse(packet);
                    break;
                case "END-CALL":
                    var endCall:IqNotificationEndCall = new IqNotificationEndCall();
                    endCall.processResponse(packet);
                    break;
                case "HOLD":
                    var hold:IqResponseHold = new IqResponseHold();
                    hold.processRequest(packet);
                    break;
                case "ADD-SESSION":
                    var addSession:IqNotificationAddSession = new IqNotificationAddSession();
                    addSession.processRequest(packet);
                    break;
                case "RE-QUEUE":
                    var requeue:IqResponseReQueue = new IqResponseReQueue();
                    requeue.processResponse(packet);
                    break;
                case "WARM-XFER":
                    var transfer:IqResponseWarmXfer = new IqResponseWarmXfer();
                    transfer.processResponse(packet);
                    break;
                case "DROP-SESSION":
                    var drop:IqNotificationDropSession = new IqNotificationDropSession();
                    drop.processResponse(packet);
                    break;
                default:
                    UIModel.getInstance().logger.warn(this,"No Handler class found for XMLPacket processing");
                    break;
            }
        }


what i would really like to do is to do this dynamically. Basically the name of the class is included in the XML packet.
<iq_response .....type="RE-QUEUE">.... so I would like to dynamically create the class, and then just call the processResponse() function of that class...

Any ideas?

Thanks,
Amanda
User is offlineProfile CardPM
+Quote Post

BetaWar
RE: Flex2/AS3 - Dynamic Objects
3 Sep, 2008 - 06:36 PM
Post #2

#include <soul.h>
Group Icon

Joined: 7 Sep, 2006
Posts: 2,022



Thanked: 81 times
Dream Kudos: 1175
My Contributions
I am sorry, I won't be of much help with this particular topic, but if you want to get more help (or at least more likely toget better help) I would suggest getting this moved to Flash/Actionscript (as it is AS), or PMing JBrace (He knows AS 3.0 I believe, so he should be able to help).
User is offlineProfile CardPM
+Quote Post

NyGrrl
RE: Flex2/AS3 - Dynamic Objects
3 Sep, 2008 - 07:38 PM
Post #3

New D.I.C Head
*

Joined: 1 Apr, 2007
Posts: 16


My Contributions
QUOTE(BetaWar @ 3 Sep, 2008 - 07:36 PM) *

I am sorry, I won't be of much help with this particular topic, but if you want to get more help (or at least more likely toget better help) I would suggest getting this moved to Flash/Actionscript (as it is AS), or PMing JBrace (He knows AS 3.0 I believe, so he should be able to help).


Thanks BetaWar I will do that.
- Amanda
User is offlineProfile CardPM
+Quote Post

gabehabe
RE: Flex2/AS3 - Dynamic Objects
5 Sep, 2008 - 03:04 PM
Post #4

Donkey DIC
Group Icon

Joined: 6 Feb, 2008
Posts: 5,533



Thanked: 98 times
Dream Kudos: 2650
Expert In: ruling the world.

My Contributions
I'll move it. cool.gif

User is online!Profile CardPM
+Quote Post

NyGrrl
RE: Flex2/AS3 - Dynamic Objects
8 Sep, 2008 - 11:46 AM
Post #5

New D.I.C Head
*

Joined: 1 Apr, 2007
Posts: 16


My Contributions
QUOTE(gabehabe @ 5 Sep, 2008 - 04:04 PM) *

I'll move it. cool.gif



Hi Gabehabe,

Could you delete this one? There is now a duplicate because I already created a new one in this category.

Thanks,
Amanda
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:43AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month