开发者

POST data to a Flex/Flash (mxml) application

开发者 https://www.devze.com 2022-12-20 13:57 出处:网络
I have Flex application requiring to filter users depending on there database groups. Depending on which group they are, the\'re is a config.xml file that is use to populate the swf.

I have Flex application requiring to filter users depending on there database groups. Depending on which group they are, the're is a config.xml file that is use to populate the swf.

Here is how I figure how 开发者_开发技巧to do this :

1. The client comes to a .aspx page with a form requiring a username and a password.

2. On the server side I confirm the user credential

3. Once the username/password is valid I redirect to the mxml file with the config.xml file in the html headers (post).

My problem comes when I need to get the post data from the http request. Let's say I have this code :

<mx:Application initialize="init()">

    <mx:Script>
        <![CDATA[
            private function init():void
            {
                // get the post data here
            }

            /* More code here */
        ]]>
    </mx:Script>

</mx:Application>

How do I get the post data on the init() function.

Thank you.


For those that would be interested, I've found some ressources on the Adobe Flex 3 Ressource center.

Basically there is no current way to pass data with the POST method. You can either add the parameters at the end of you swf url (GET method) as shown here : http://livedocs.adobe.com/flex/3/html/help.html?content=deep_linking_5.html#245869

The other way is to embed them in the page with the flashVars method shown here : http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html#229997

If you still wonder, how I'll manage to do this if you run to in the same situation. Here is my idea (feel free to share if you have different vision) :

1.User logs in login.aspx
2.Depending on the credentials of the users the server side code modify the index.html file to embed the correct xml file in the flash object.
3.With the FlashVars method, I get back the xml file path and job done!

If you ever run in a similar situation and need help contact me.


I don't think it's possible to get the POST data, but others might have a way. An alternative solution would be:

  1. User logs in: login.aspx
  2. User directed to Flash content: content.html embedding content.swf
  3. Flash requests config.xml from server: content.swf makes HTTP request for config.xml.aspx
  4. Server provides user's configuration in config.xml.aspx

In your init() function, you'd make the URLLoader request to get the configuration, and you'd do the configuration in the Event.COMPLETE handler.

Another possibility is to use HTTP cookies--not handled natively by Flash, but you can get to them via Javascript--see this CookieUtil class.

0

精彩评论

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

关注公众号