开发者

Is it possible to load an ASP.Net aspx.cs variable as a flashvar in flex

I have a aspx webpage that is successfully hosting a flex app. On the page there is some varables that are generated at load time. I was wondering if there was a way to take these variables and use them in the flex app.

I have tried a couple of things but the latest one looks like this:

<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='100%' height='100%' id='FlexApp'title='FlexApp'>
      <param name='movie' value='FlexApp.swf' />
      <param name='quality' value='high' />
      <param name='wmode' value='opaque' />
      <param name='AllowScriptAccess' value='always' />
      <param name='swfversion' value='9.0.45.0' />
      <embed src=FlexApp.swf' AllowScriptAccess='always' pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=Sh开发者_运维问答ockwaveFlash' type='application/x-shockwave-flash' width='100%' height='100%' 
flashVars='param1='+<%=param1%>'&param2='+<%=param2%>
    </object>

Where param1 and param2 are global variables in the page.aspx.cs file something like this:

public string param1,param2;
protected void Page_Load(object sender, EventArgs e)
{
    param1 ="Something"
    param2 = "Else"
}

In the flex app to test i have

import  mx.core.FlexGlobals;

private void Init()
{
    Alert.show(FlexGlobals.topLevelApplication.parameters.param1);
}

When I load the flash app i get an alert dialog with the "ok" button having the text "void". Obviously it is not reading the variables... Is there any solution to this?

The reason that I need this, is there's a function that flex cannot access but the webpage that it is hosted on can so i wanted to post the result in the flex app.


unless this is a typo, did you forget the closing /> on the embed tag? Also, you don't need to build the flashVars like a string inline, try one continuous string flashVars='param1=<%=param1 %>&param2=<%=param2 %>' like this:

<embed 
    src='FlexApp.swf'
    AllowScriptAccess='always' 
    pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'
    type='application/x-shockwave-flash'
    width='100%'
    height='100%' 
    flashVars='param1=<%=param1 %>&param2=<%=param2 %>' />

where is the <object> tags <param name="flashvars"...?

<param name='flashvars' value='param1=<%=param1 %>&param2=<%=param2 %>'>

follow these steps for x-browser flash embedding


<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='100%' height='100%' id='FlexApp'title='FlexApp'>
    <param name='movie' value='FlexApp.swf' />
    <param name='quality' value='high' />
    <param name='wmode' value='opaque' />
    <param name='AllowScriptAccess' value='always' />
    <param name='swfversion' value='9.0.45.0' />
    <param name='flashvars' value='param1=<%=param1 %>&param2=<%=param2 %>'>
    <embed 
        src='FlexApp.swf'
        AllowScriptAccess='always' 
        pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'
        type='application/x-shockwave-flash'
        width='100%'
        height='100%' 
        flashVars='param1=<%=param1 %>&param2=<%=param2 %>' />
</object>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜