Not signed in (Sign In)

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

  1.  
    Hi there!

    I have a big problem with my work. I have to include a xml file with dynamic file names.

    # HTML ########
    <p id="obenlinks" style="position:absolute;top:0;left:0;width:229px;;height:104px;margin:0;padding:0;">
    <a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Plugin</a> to see this.
    </p>
    <script type="text/javascript">
    var s1 = new SWFObject("film2.swf","mpl","229","104","9");
    s1.addParam('menu','false');
    s1.addVariable('xmlfile','videoplaylist.xml');
    s1.write("obenlinks");
    </script>
    ###############

    This should be right ..

    # AS ###########
    var myLoader:URLLoader = new URLLoader();
    var myURL = new URLRequest(xmlfile);
    myLoader.load(myURL);
    myLoader.addEventListener(Event.COMPLETE, onLoadComplete);
    var myXML:XML;
    [...]
    ###############

    When i try ## var myURL = new URLRequest("videoplaylist.xml"); ##, everything works fine.

    Is there anybody who know why this is wrong and what i can do against this?


    Greetings and thanks!

    # christian
    • CommentAuthorphilip
    • CommentTimeDec 7th 2007
     
    personally i would add some error-checking in your AS code.

    something as simple as:


    if(!xmlfile){
    // error and/or troubleshooting message
    } else {
    var myLoader:URLLoader = new URLLoader();
    var myURL = new URLRequest(xmlfile);
    myLoader.load(myURL);
    myLoader.addEventListener(Event.COMPLETE, onLoadComplete);
    var myXML:XML;
    [etc...]
    }


    you might be having a path issue. are all of your files in the same folder?

    - philip
  2.  
    Thanks for your help.

    All the files are in the same folder.

    Now i have an error message:

    "ReferenceError: Error #1065: Variable xmlfile ist nicht definiert.
    at film2_fla::MainTimeline/film2_fla::frame1()"

    (Not-defined-variable)

    Why? .. Doesn't s1.addVariable('xmlfile','videoplaylist.xml'); set this variable?
    • CommentAuthorphilip
    • CommentTimeDec 10th 2007
     
    xmlfile is currently being declared externally by SWFObject. This means error-checking in the FLA will always show xmlfile as undefined, because it hasn't been defined in the SWF. You could probably declare xmlfile yourself and then add more specific error-checking:

    var xmlfile:String = "";
    if(xmlfile == ""){
    // error and/or troubleshooting message
    } else {
    var myLoader:URLLoader = new URLLoader();
    var myURL = new URLRequest(xmlfile);
    myLoader.load(myURL);
    myLoader.addEventListener(Event.COMPLETE, onLoadComplete);
    var myXML:XML;
    }
  3.  
    Ok, this is a reason..

    With your example, didn't i declare in the fla the variable an the declaration from SWFObject will be overwrited/ignored? If i see it on the html page in my browser, it looks like anyway..
    Not the Variables from the xml-file will be there but them i declared in if(xmlfile == ""){ }

    Here i will show you my whole AS-code, maybe you have any ideas else..


    var xmlfile:String = "";

    if(xmlfile == ""){
    // error and/or troubleshooting message

    land.appendText("x");
    region.appendText("x");
    stadt.appendText("x");

    } else {

    var myLoader:URLLoader = new URLLoader();

    var myURL = new URLRequest(xmlfile);

    myLoader.load(myURL);

    myLoader.addEventListener(Event.COMPLETE, onLoadComplete);

    var myXML:XML;

    function onLoadComplete(evt : Event):void {

    XML.ignoreComments = true;

    XML.ignoreWhitespace = true;

    myXML = new XML(evt.target.data);

    land.appendText(myXML.land.text().toString());
    region.appendText(myXML.region.text().toString());
    stadt.appendText(myXML.stadt.text().toString());

    }

    }

    stop();
    • CommentAuthorphilip
    • CommentTimeDec 11th 2007
     
    so, getting back to the original issue, everything works if the XML URL is hard-coded in your AS, but it doesn't work when the XML URL is passed via SWFObject?
  4.  
    yes .. that's the problem i couldn't handle :/
    • CommentAuthorphilip
    • CommentTimeDec 11th 2007
     
    do you have a link we can look at? it would help us identify potential problems.
  5.  
    • CommentAuthorphilip
    • CommentTimeDec 11th 2007 edited
     
    your XML file has an error.


    XML Parsing Error: syntax error
    Location: http://www.videoweb.de/videos/xmlcreate.php
    Line Number 1, Column 16:
    <?xml version="2.0" encoding="utf-8"?>
    ---------------^
  6.  
    Shame on me..
    http://www.7rats.com/tests/xmlcreate.php

    Now i fixed this but http://www.7rats.com/tests/index.html still dont do what it should...
    • CommentAuthorphilip
    • CommentTimeDec 11th 2007
     
    hmm... might be a scope issue with your AS. when flashvars declares xmlfile, it's being done at the root. if your AS code is wrapped in a function, the scope will be off. is your code located in a function or anywhere other than the main timeline?

    - philip

    PS - have you tried embedding the SWF without SWFObject? i don't think swfobject is the problem here, it's probably somewhere in your code.

    try using this in firefox:
    <embed type="application/x-shockwave-flash" src="film2.swf" style="" id="mpl" name="mpl" quality="high" menu="false" flashvars="xmlfile=xmlcreate.php" height="104" width="229">

    if the flashvars don't work, we'll know for sure it isn't a swfobject issue.
  7.  
    You are right.. This has nothing have to do with SWFObject...

    I have 3 Layers in my File, the AS in on the toplayer.. There sould be nothing else..

    Could you or anybody else take a look at my .fla file? My skills in flash are not the greatest, i have to do this for work, cause nobody else is there with a graphic eye..

    You can find it on http://www.7rats.com/flash.zip

    Greetings.
  8.  
    I have it!

    Cause i use AS3, i have to use "root.loaderInfo.parameters.xmlfile"!

    Thanks for help :)