A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: flashvars to use a XML file

  1. #1
    Junior Member
    Join Date
    Feb 2003
    Location
    London, U.K.
    Posts
    26

    flashvars to use a XML file

    Hi,

    I'm using CS3, flash player 8 and AS2.

    I'm trying to make changes on an existing fla that is used to call an xml file to display some images with a timer.

    This is the part of the AS that calls the xml.

    Actionscript Code:
    import util.GetXML;
    import util.VarsIroning;
    var xml = "homeEnglish.xml";
    var nodes:XMLNode = new XMLNode ();
    var shortNode:XML = new XML ();
    var iron:VarsIroning = new VarsIroning (["partner", "xmlUrl"]);
    var xmlReg:GetXML = new GetXML (xml, fnLoad, fnError);
    //var xmlReg:GetXML = new GetXML ("tmp.xml", fnLoad, fnError);
    var loadedImages:Object = new Object ();
    var isPlaying:Boolean = false;
    var control:String;
    var fps:Number = 25;
    var prevIndex:Number;
    var corners_mask_mc:MovieClip;

    Now the client wants me to change the fla so the xml is called from the parameters instead. This is because they want to have several of these swf but calling different xmls.

    I've some idea of how to do that in the parameters, but not sure the changes I have to do in the AS, could anybody help?

    Thanks a lot.
    MoDesign

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Grabbing variables passed via FlahVars to the SWF, is very easy. Just point to _level0.

    If this code is attached to the main timeline of the main movie, and you're passing a variable myFile, all you need is changing the line:
    Actionscript Code:
    var xml = "homeEnglish.xml";
    // to
    var xml = myFile;
    More info here.

  3. #3
    Junior Member
    Join Date
    Feb 2003
    Location
    London, U.K.
    Posts
    26
    Hi Nunomira,

    Thanks a lot for your answer, I've tried what you said. Here is the flash code on the html:

    Actionscript Code:
    <script type="text/javascript">
    AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','659','height','215','src','welcome_English','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','welcome_English' ); //end AC code
    </script><noscript><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="659" height="215">
            <param name="movie" value="welcome_English.swf" />
            <param name="quality" value="high" />
            <param name="FLashVars" value="myFile=homeEnglish.xml" />        
            <embed src="welcome_English.swf"  quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="659" height="215" flashvars="myFile=homeEnglish.xml"></embed>
          </object>
        </noscript>

    I've placed the myFile=homeEnglish.xml to specify the variable in flash.

    This is the section is AS that deals with the xml, the whole code is on the root of the movie:
    Actionscript Code:
    import util.GetXML;
    import util.VarsIroning;
    var xml = myFile;
    var nodes:XMLNode = new XMLNode ();
    var shortNode:XML = new XML ();
    var iron:VarsIroning = new VarsIroning (["partner", "xmlUrl"]);
    var xmlReg:GetXML = new GetXML (xml, fnLoad, fnError);

    Still not working. Sorry my expertise is more design and CSS and some actionscript but not enough to deal with this.

    Thanks for your help.

    Mauricio
    MoDesign

  4. #4
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi,

    Here's a working example.
    I had some trouble making it work because Dreamweaver doesn't automatically add FlashVars everywhere it should.
    I had to add it manually:
    Code:
    'FlashVars', 'myFile=something.xml'
    I always use SWFObject to embed SWF files. It simplifies this and other processes...
    Attached Files Attached Files

  5. #5
    Junior Member
    Join Date
    Feb 2003
    Location
    London, U.K.
    Posts
    26
    Hi Nunomira,

    Thank you so much for your help.

    Used the code from your example and worked perfectly.

    Thanks again
    MoDesign

  6. #6
    Junior Member
    Join Date
    Jul 2010
    Posts
    4

    xmlpath in flashvars

    hi Cocteauuk,

    me too facing the same problem. can u just send me ur sample that how did u read the xml nodes from the flashvars xml path?

    thanks in advance

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center