开发者

Is it possible to create a separate file for httpservices in flex and what are the best practices

Hi I am new new to flex development. I am building a fle开发者_Python百科x application which uses rest APIs.

Right now I have created different for different API calls (login, logout, search etc.) And all these services are in main mxml application file.

I am wondering if I can create a separate mxml file like services.mxml that I can use to call any service.

Is this the right approach? And can you tell me how t do this?

Thanks

Priyank


Yes, you can encapsulate Flex code so it is not all in the same file. Yes, you can also do this with services. In fact the Cairngorm framework uses that exact approach. [And I assume other frameworks do too].

When you create a component architecture the trick is figuring out how components communicate with each other. In Flex, a component can dispatch events to communicate with it's parent. And it can have methods or properties so the parent can communicate with the child.

Encapsulating all services to a single is fine, but you'll need to figure out components will access those services and how those services will send results back to the components. It's not a simple proposition.

I think you need to research the flex component lifecycle a bit and read up on creating Flex Components or ActionScript classes.

Here are a few resources:

http://www.adobe.com/devnet/flex/components.html http://www.adobe.com/devnet/flex/articles/creating_components.html http://livedocs.adobe.com/flex/3/html/help.html?content=Part4_CreateComps_1.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜