Not signed in (Sign In)

Vanilla 1.0.3 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorragscoon
    • CommentTimeJan 2nd 2007
     
    I am having a unique problem with swftObject. I'm sending my flash variables using the "so.addVariable" paramitters but I don't always need it, you see if a person hits the page with out the prams in the querystring such as: mypage?value=stuff, my flash goes crazy cause it still gets data passed to it from SWFobject and my flash detects this data cause it's not undefined data. I end up getting HTML tags inserted into the variable by flash cause though no data was passed, swfObject writes the flash content with data expected.

    it's odd to explain but the way it's supposed to work is that my flash loads and checks a variable once it has loaded. That variable is passed via the query string using SwfObject. But when there is nothing to pass, somthing still get's sent, and my flash picks this up but can not comprehend it cause it gets translated into HTML tags which scres up my flash script cause it's not expecting that.

    I have found that the flash is fine when the "so.addVariable" feature is not used, but then I can't pass variables when I need to. So my only workaround is an "IF" statement to add the "so.addVariable" when the query string has info being passed. My real problem now is that I'm not good as JS so I'm not sure if this is possible with SwfObject. somthing like:

    if (getQueryParamValue("websearch") <> "")
    {
    so.addVariable("websearch", getQueryParamValue("websearch"));
    so.write("flashcontent");
    }
    else
    {
    so.write("flashcontent");
    };

    Am I on the right track here?
    • CommentAuthorragscoon
    • CommentTimeJan 2nd 2007 edited
     
    Well it seems that I was on the right track, from what I could figure out flash runs into a problem if the SWFObject is using the "so.addVariable" prams but there is not data in the query of the URL when it's expecting data. Example:

    mypage.htm?variable=value works fine if SwfObject is using "so.addVariable" to pass data to flash that will interact with it.
    mypage.htm has errors if SwfObject is using "so.addVariable" to pass data to flash, when there is nothing to pass and the flash is waiting for the data to do somthing with it.
    mypage.htm is fine if SwfObject write normaly with out passing data even if the flash is waiting for the data to do somthing with it.

    The key is that the problem is on 2 ends the flash scripting and the javascripting, if you have a script in your flash that is checking for an incoming variable when the flash loads but the SwfObject is set up to write the variables to the flash from the URL when there is not Querystring... the flash will still be written to the page but with blank value apended to the swf source like "flash.swf?variable=" from the URL "mypage.htm". Depending on your script if it's using the info in some way it will hang your flash cause a script error. In my case I was using the info for a database search but only if a person requested it. "mypage.htm?search=stuff" when they just went to the page mypage.htm, the page was still being written with "flash.swf?search=" and flash was getting <p> thinking the data not passed was HTML which inturn it tried to process and script crashes.

    My fix was as follows:

    <script type="text/javascript">
    // <![CDATA[
    var so = new SWFObject("Exotic_console_2007.swf", "exoticconsole", "950", "600", "8", "#000000");
    var hasQueryString = document.URL.indexOf('?');
    if (hasQueryString != -1) {
    // Write the flashcontent if there is a querystring so that data is sent
    so.addVariable("websearch", getQueryParamValue("websearch"));
    so.write("flashcontent");
    }
    else
    {
    // Write the flashcontent normally if not querystring
    so.write("flashcontent");
    }
    // ]]>
    </script>

    As you can see I only write the "so.addVariable" prams if there is a querystring in the URL, I suppose it can be adapted to work only for specific values passed.
    • CommentAuthorkamermans
    • CommentTimeJan 2nd 2007
     
    I'm not sure why you would be getting HTML on your Flash side, as you can see from this demonstration script, when you check the existence of an undefined URL parameter, the getQueryParamValue() method will return an empty string - this will be an empty string in Flash as well. I have made a decent number of flash applications that gladly take a whole bunch of empty variables - and they come in as either null or undefined, depending on the situation. I would bet you have something else going on in your Flash that is messing with your data, like binding an HTML enabled dynamic text box to the "websearch" variable. HTML dynamic text boxes have a nice way of messing with data!
    • CommentAuthorragscoon
    • CommentTimeJan 8th 2007
     
    Thanks for the insight, I think you may be correct on that binding, but I'm not sure HOW to get rid of it, the only other solution I had that works for me is to send another variable that validates things before my Flash script runs. so now mypage.htm has the following mypage.htm?search=stuff&valudate=true so if my flash does not see that validate = "true" then it will not run the script, it work well to keep the binds from messing up scripts that expect proper data.

    ragscoon.
    • CommentAuthorkamermans
    • CommentTimeJan 8th 2007
     
    Well, if to test you could make try a different variable and assign it to a textbox. First, use this code to embed your flash:

    <script type="text/javascript">
    // <![CDATA[
    var so = new SWFObject("Exotic_console_2007.swf", "exoticconsole", "950", "600", "8", "#000000");
    so.addVariable("FlashVar_websearch", getQueryParamValue("websearch"));
    so.write("flashcontent");
    // ]]>
    </script>

    Then edit the FLA and in the first frame put the following in the actions panel:
    if(FlashVar_websearch != ""){
    websearch = FlashVar_websearch;
    }else{
    websearch = "";
    }


    I'm 99.9% sure that the problem is with your Flash, and that you used the "Var: " property of a textbox and set it to "websearch" - this will technically work, but if the textbox is HTML enabled and no value is assigned to it, it will put some HTML junk in it instead, so to fix the problem you would need to remove "websearch" from the "Var: " property of the textbox and instead give the textbox an instance name (like "txt_websearch") and in the first frame of the movie, assign the incoming value to it like this:

    txt_websearch.text = websearch; // this is for NON html

    or

    txt_websearch.htmltext = websearch; // this is FOR html