Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically take apart and put together Flash file

Status
Not open for further replies.

ASPNETnewbie

Programmer
May 9, 2006
93
US
Hi,

I have a .swf object that I would like to wrap in a User Control along with other server controls. Basically what I want to happen is to allow users to specify the WIDTH, HEIGHT, DATASOURCE properties for the embedded Flash File
( which uses the information to generate a Pie or BarChart depending on Input collected from user at run time).I have the code below for my flash object and would like to have this all work from within the same User control.

What is the best way to take the code below apart at run time and then put it all back together at runtime using information inputted by user?

ASPNETNEWBIE


Code:
 <object id="FC_2_3_Column3D" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"height="350"[/URL] width="700">
<param name="movie" value="../Charts/FC_2_3_Column3D.swf">
<param name="FlashVars"value=" &dataURL=Data.xml&chartWidth=700&chartHeight=350">
<param name="quality" value="high">
<param name="bgcolor" value="#FFFFFF">
<embed bgcolor="#FFFFFF" flashvars="&dataURL=Data.xml&chartWidth=700&chartHeight=350" height="350" name="FC_2_3_Column3D" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL]
 quality="high" src="../Charts/FC_2_3_Column3D.swf" type="application/x-shockwave-flash"
 width="700"></embed>
        </object>
 
I would put the entire tag as a string constant, replacing the variable parts with string-formatting tokens. When it's time to display the tag, create a new string using the constant as the format and supply the variables. Then display that string in a literal.

A simple example (VB.NET):
Code:
Const MY_FORMAT as String = "Thanks {0}, you entered {1}.  Thanks for entering {1}."

Dim usersName as String  = "Newbie"
Dim usersInput as Integer  = 350

Dim newTag as String

newTag = String.Format(MY_FORMAT, usersName, usersInput)

Me.Literal1.Text = newTag

Output:
[tt]Thanks Newbie, you entered 350. Thanks for entering 350.[/tt]

This gives you the general idea...

[blue]_______________________________________[/blue]
Business Logic:"AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle AND..." - Dr. Suess
 
I have a question about this use of string Literals. Say I actually want to add the modified code to the HTML body of the Control so that when the user open the page, all the user sees is a Flash Animation and not the code that creates the flash movie itself, how do I do this?

ASPNETNewbie
 
I tried Using string literals but for some reason, this does not work for me and I was wondering if someone could me understand my mistake.

Code:
obj="<object id="FC_2_3_Column3D" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" "
    obj=+"codebase="[URL unfurl="true"]http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"[/URL] "
            Obj += "height="
            Obj += cWidth
            Obj += cHeight
            Obj += " >"
    obj+="<param name="movie" value="../Charts/FC_2_3_Column3D.swf"> "
    obj+="<param name="FlashVars" value="&dataURL=" 
            Obj += cXML
            Obj += "&chartWidth="
            Obj += cWidth
            Obj += "&chartHeight="
            Obj += cHeight
            Obj += ">"
    obj+="<param name="quality" value="high"><param name="bgcolor" value="#FFFFFF"><embed bgcolor="#FFFFFF" "
            Obj += " flashvars=" & dataURL = ""
            Obj += cXML
            Obj += "&chartWidth="
            Obj += cWidth
            Obj += "&chartHeight="
            Obj += cHeight
            Obj += " height ="
            Obj += cHeight
            obj+="name = "FC_2_3_Column3D""
            obj+=" pluginspage="[URL unfurl="true"]http://www.macromedia.com/go/getflashplayer"[/URL] "
            obj+="quality = "high""
        obj+="src="../Charts/FC_2_3_Column3D.swf" type="application/x-shockwave-flash"  "
            Obj += "width="
            Obj += cWidth
            Obj += ">"
            Obj += "</embed></object>"
            Literal1.Text = Obj
        End If
 
If you want an actual quote in the string, just double it in VB.NET.

Code:
Dim stringWithQuotes as String = "This has ""quotes"" in it"

output:
[tt]This has "quotes" in it.[/tt]

[blue]_______________________________________[/blue]
Business Logic:"AND when tweetle beetles battle with paddles in a puddle, they call it a tweetle beetle puddle paddle battle AND..." - Dr. Suess
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top