Posted in Flex | Posted on 12-11-2006 | 8,562 views
As a developer on the receiving end of Flash files, I've gotten used to dealing with FlashVars as a way to configure a Flash application. I've wondered how I'd do this in Flex though. Joao Fernandes sent me some sample code and showed me the way.
Consider this simple Flex page:
2<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="components.*">
3
4 <mx:Script>
5 <![CDATA[
6 import mx.controls.Alert;
7
8 private function test():void {
9 Alert.show(this.parameters.flashvar1+' '+this.parameters.flashvar2, "Flashvars");
10 }
11 ]]>
12 </mx:Script>
13
14 <mx:Button id="btnTest" label="Test" click="test()" />
15
16</mx:Application>
Note the this.parameters? This lets me get access to the flashvars. I named them flashvar1 and flashvar2 which isn't very creative. Obviously it could be any name. To pass the variables in you can simply edit the generated HTML.
Don't forget that each Flex project has an HTML template. It would make sense to edit the template so you don't have to re-edit the generated HTML after each build.
This should help take care of the "root CFC" issue I mentioned a week or so ago.


That's my opinion anyway.
Obviously, if you have that stuff on the server-side, that you can hack the client to to your heart's content, and not worry, but just curious; it seems MORE security is better than just the same. For example, using FlashVars to show data:
somerecord=recordA
Back in 1.5, you'd have somerecord defined for you on in your main Flex Application file. There is nothing stopping the user, at least from what I've seen, from doing the same thing they do in attempting to expose regular sites by injecting bad things into the params; the whole reason CFQueryparam (or whatever that tag is called) was invented in the first place; to ensure safe, acceptable query parameters. Flex, in both versions, doesn't appear to make a distinction. It just seems people would take this for granted. The dangers of messing with Application level variables is gone now that they are sequested in the parameters property, but it still seeems pretty easy to pass whatever I want if someone takes no steps client side to project it.
Obviously, if they have the server-side portion, there isn't much I can do, but still I've never seen client side code implementations match up exactly with server-side, so seems to be to still be a valid concern.
Make sense, or still not a big deal?
http://labs.adobe.com/wiki/index.php/Flex_Framewor...
http://flexapps.macromedia.com/flex2beta3/fabridge...
[Add Comment] [Subscribe to Comments]