开发者

Updating an ASP.NET iFrame without a page refresh using Actionscript 3

I would like to have a FLEX SWF Menu in .NET that is animated, and use button clicks to update an iFrame in an .NET 2.0 Ajax enabled application without a page update or refresh. If I use URLVaribles in Flex, The only way I've gotten to them to ASP.NET is via URL Page Navigation which always refreshes the screen. There is a LOADVARS function but I have not gotten it to work. Is there any suggestion on how one would do this??

Do I need to look into using JSON for Flex??? Or WebOrb???

This works fine... but with a page refresh (which is not cool)...

  navigateToURL( new URLRequest( "http://localhost:50294/WEBAPP/Default.aspx?P=2&H=500" ), "_self" );

This does NOT work fine... (in fact it just loads the whole page .NET page in FLEX, not what I am looking for)

var variables:URLVariables = new URLVariables();
variables.P="1";
variables.H="400";
var request:URLRequest = new URLRequest();
request.url =开发者_StackOverflow "http://localhost:50294/Timber2/Default.aspx?";
request.method = URLRequestMethod.POST;
request.data = variables;
var loader:URLLoader = new URLLoader();
loader.dataFormat = URLLoaderDataFormat.TEXT;
loader.addEventListener(Event.COMPLETE, uploadComplete);
try
{
    loader.load(request);
}
catch (error:Error)
{
    trace("Unable to load URL");
}


What you are really trying to do is interface with JavaScript and not .NET. This is accomplished via the ExternalInterface:

http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/external/ExternalInterface.html

ExternalInterface provides a first class connection to JS via Actionscript 3 and should be able to accomplish what you are asking.


You can use navigateToURL; you just need specify the name of the iframe in the code. For example, if it's called "myFrame":

navigateToURL(
    new URLRequest("http://localhost:50294/WEBAPP/Default.aspx?P=2&H=500"), 
    "myFrame");

Better yet, use relative links so that your code will work in a production environment (this is assuming the menu and the iframe are on the same web server):

navigateToURL(new URLRequest("/WEBAPP/Default.aspx?P=2&H=500"), "myFrame");
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜