8 Replies Latest reply on Apr 9, 2009 9:26 AM by rckehoe

    Very Simple Variable Problem...


      Hey, I know that the answer to this question is very simple, but I cannot seem to figure it out...


      I am accessing my flex app through a URL... http://www.MyDomain.com/myfile.php?id=XXX


      On myfile.php, I have my flex app and I want to pass the id variable into the app, and I want to display it into a text field... It's a very simple task, but for some reason I just can't seem to figure it out.

        • 1. Re: Very Simple Variable Problem...
          Michael Borbor Level 4
          1 person found this helpful
          • 2. Re: Very Simple Variable Problem...
            rckehoe Level 1

            I have already been through the docs on this issue... For some reason I am not having any luck with the FlashVars... I am trying to access it using {Application.application.paramaters.userid}, but no luck. I don't understand what I am doing wrong?


            Here is my code:

            <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
                        id="${application}" width="${width}" height="${height}"
                        <param name="movie" value="${swf}.swf" />
                        <param name="FlashVars" value="userid=572" />
                        <param name="quality" value="high" />
                        <param name="bgcolor" value="${bgcolor}" />
                        <param name="allowScriptAccess" value="sameDomain" />
                        <embed src="${swf}.swf" quality="high" bgcolor="${bgcolor}"
                            width="${width}" height="${height}" name="${application}" align="middle"

            • 3. Re: Very Simple Variable Problem...


              try this one:

              <param name="flashvars" value="var1=123&amp;var2=456" />



              • 4. Re: Very Simple Variable Problem...

                I use a QueryString class to do this...


                package customclasses
                    import flash.external.*;
                    import flash.utils.*;
                    public class QueryString
                        private var _queryString:String;
                        private var _all:String;
                        private var _params:Object;
                        public function get queryString():String
                            return _queryString;
                        public function get url():String
                            return _all;
                        public function get parameters():Object
                            return _params;

                        public function QueryString()

                        private function readQueryString():void
                            _params = {};
                                _all =  ExternalInterface.call("window.location.href.toString");
                                _queryString = ExternalInterface.call("window.location.search.substring", 1);
                                    var params:Array = _queryString.split('&');
                                    var length:uint = params.length;
                                    for (var i:uint=0,index:int=-1; i<length; i++)
                                        var kvPair:String = params[i];
                                        if((index = kvPair.indexOf("=")) > 0)
                                            var key:String = kvPair.substring(0,index);
                                            var value:String = kvPair.substring(index+1);
                                            _params[key] = value;
                            }catch(e:Error) { trace("Some error occured. ExternalInterface doesn't work in Standalone player."); }



                And to use it...


                import customclasses.QueryString;


                private var queryString:QueryString = new QueryString();


                var id:String = queryString.parameters.id;

                • 5. Re: Very Simple Variable Problem...
                  rckehoe Level 1

                  No I tried both of those things, but nothing has worked...


                  I tried to run a test using...


                  for (var i:String in Application.application.parameters) {
                       interests.text += i + ":" + Application.application.parameters[i] + "\n";


                  I wanted to display a list of all the variables that are being sent, and I don't get any errors, but I also don't get any results.


                  I really don't know what I am doing wrong.

                  • 6. Re: Very Simple Variable Problem...
                    Flex harUI Adobe Employee

                    Try using browserManager instead.  Maybe your HTML wrapper doesn't pass the parameters to the SWFObject.  BrowserManager makes it easier to get at the url params.


                    Alex Harui

                    Flex SDK Developer

                    Adobe Systems Inc.

                    Blog: http://blogs.adobe.com/aharui

                    1 person found this helpful
                    • 7. Re: Very Simple Variable Problem...
                      run,ryan! Level 3

                      is flashVar case sensitive?

                      • 8. Re: Very Simple Variable Problem...
                        rckehoe Level 1

                        Thank you everyone for all their help!

                        I figured it out... It was the way that that javascript was passing the variables.... I got it to work now!


                        I knew it was something easy!