School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 300,444 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,527 people online right now. Registration is fast and FREE... Join Now!




Inserting XML into Flash?

 

Inserting XML into Flash?

CamoDeveloper

23 Jun, 2009 - 05:24 AM
Post #1

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
Hi,

I'm working on a clients site and he wants a random flash piece. I have the flash all set and it works fine, but I just had a quick question. Does Flash allow you to input straight XML without using a .XML file? I want to randomize the images that the Flash piece uses, but I don't want to have to create more than one .XML file. Here is the code that I'm using :

CODE

<script language="JavaScript" type="text/javascript">
    if (hasReqestedVersion) {
        AC_FL_RunContent(
            "src", "<%#Me.RootPath%>/images/jewelryflash/dynamic-jewelry.swf?rootPath=<%#Me.RootPath%>/images/jewelryflash/&xmlDoc=<%#Me.RootPath%>/images/jewelryflash/images.xml&speed=5",
            "width", "596", "height", "238", "align", "", "id", "jewelry", "quality", "high", "bgcolor", "#FFFFFF", "name", "jewelry", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "codebase", "https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab", "pluginspage", "http://www.adobe.com/go/getflashplayer");
    } else {
        document.write('<acfwc:randomimage alternatetext="<%#Me.ImageAlt1%>" id="imgFlash" runat="server" relativeimagefolder="/images/jewelryflash/" width="596" height="238"></acfwc:randomimage>');
    }
</script>


That works fine, and the images appear. But I'm wondering is if I can input XML without the use of a file. Some thing like this :

CODE

<script language="JavaScript" type="text/javascript">
    if (hasReqestedVersion) {
        AC_FL_RunContent(
            "src", "<%#Me.RootPath%>/images/jewelryflash/dynamic-jewelry.swf?rootPath=<%#Me.RootPath%>/images/jewelryflash/&xmlDoc=<asp:literal id="litFlashXML" runat="server" />&speed=5",
            "width", "596", "height", "238", "align", "", "id", "jewelry", "quality", "high", "bgcolor", "#FFFFFF", "name", "jewelry", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "codebase", "https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab", "pluginspage", "http://www.adobe.com/go/getflashplayer");
    } else {
        document.write('<acfwc:randomimage alternatetext="<%#Me.ImageAlt1%>" id="imgFlash" runat="server" relativeimagefolder="/images/jewelryflash/" width="596" height="238"></acfwc:randomimage>');
    }
</script>


And the codebehind :

CODE

Me.litFlashXML.Text = "<images><image>aquamarine.jpg</image><image>fancy-sapphire.jpg</image><image>malaia-garnet.jpg</image><image>rhodolite.jpg</image><image>tanzanite.jpg</image><image>tourmaline.jpg</image><image>tsavorite.jpg</image></images>"


But when I do that, nothing shows up. The rendered HTML looks like it should work, so I'm wondering if what I'm doing is even possible. This is the rendered HTML :
CODE

<script language="JavaScript" type="text/javascript">
    if (hasReqestedVersion) {
        AC_FL_RunContent(
            "src", "/LapigemsWebApp/images/jewelryflash/dynamic-jewelry.swf?rootPath=/LapigemsWebApp/images/jewelryflash/&xmlDoc=<images><image>aquamarine.jpg</image><image>fancy-sapphire.jpg</image><image>malaia-garnet.jpg</image><image>rhodolite.jpg</image><image>tanzanite.jpg</image><image>tourmaline.jpg</image><image>tsavorite.jpg</image></images>&speed=5",
            "width", "596", "height", "238", "align", "", "id", "jewelry", "quality", "high", "bgcolor", "#FFFFFF", "name", "jewelry", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "codebase", "https://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab", "pluginspage", "http://www.adobe.com/go/getflashplayer");
    } else {
        document.write('<img id="ctl00_MainContent_imgFlash" src="/LapigemsWebApp/images/jewelryflash/aquamarine.jpg" style="height:238px;width:596px;border-width:0px;" />');
    }
</script>


My only other alternative is to create a page and have it create the XML dynamically, but I really don't want to create any more pages. Thanks for any help in advance.

~Camo

This post has been edited by CamoDeveloper: 23 Jun, 2009 - 10:29 AM

User is offlineProfile CardPM
+Quote Post


CamoDeveloper

RE: Inserting XML Into Flash?

23 Jun, 2009 - 01:49 PM
Post #2

D.I.C Head
Group Icon

Joined: 12 Jun, 2009
Posts: 204



Thanked: 12 times
Dream Kudos: 200
My Contributions
Figured out the problem, our custom "StartSlideShow" function was being called on onLoad. Apparently you can't parse through the XML string and use our function. So I had to opt to using a page to generate the XML string. It's all working now, just need to make it random now.

~Camo
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/8/09 01:37AM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month