Hi, thanks for the reply.
I have 2 classes
1.
Code:
package
{
import flash.net.NetConnection;
import flash.net.ObjectEncoding;
public class RemotingService extends NetConnection
{
function RemotingService(url:String)
{
// Is this the right coding?
objectEncoding = ObjectEncoding.AMF0;
// Connect to gateway
connect(url);
}
}
}
2.
Code:
package
{
import flash.net.*;
import flash.display.*;
import flash.events.*;
import flash.text.*;
public class RemotingTest extends Sprite
{
//private var rs:RemotingService;
private var nt:NetConnection;
private var t:TextField = new TextField();
function RemotingTest()
{
//just a button on the stage - so i can click it to start the code running
btnRemote.addEventListener(MouseEvent.CLICK, btnRemote_Click);
}
private function btnRemote_Click(event:MouseEvent):void
{
init();
t.text = "test";
addChild(t);
}
// init function
private function init()
{
try
{
nt = new NetConnection();
nt.objectEncoding=ObjectEncoding.DEFAULT;
//should this be The browser is not supported.... ? cos is embeded in aspx page so should be able to just use gateway.aspx? flash
//gives me error if invalid parameter if don't have http:// at front
nt.connect("http://gateway.aspx");
var responder:Responder = new Responder(onResult, onFault);
//just so i can see stuff is happenng
var t2:TextField = new TextField();
t2.text = "gonna try";
t2.x = 50;
addChild(t2);
nt.call("_Default.Test", responder);
//just so i can see stuff is happenng
var t20:TextField = new TextField();
t20.text = "did it call";
t20.x =100;
addChild(t20);
}
catch(e:Error)
{
//never shows anything? but in flash says -
//"Error #2044: Unhandled NetStatusEvent:. level=error, code=NetConnection.Call.BadVersion
// at RemotingTest/::init()
// at RemotingTest/::btnRemote_Click()"
trace(e.message);
var t3:TextField = new TextField();
t3.text = e.message.toString();
addChild(t3);
}
}
private function onResult(result:Object):void
{
//nothing is shown
var t4:TextField = new TextField();
t4.text = result.toString();
t4.x = 150;
addChild(t4);
trace(result);
}
private function onFault(fault:Object):void
{
//nothing is shown
var t5:TextField = new TextField();
t5.text = fault.toString();
t5.x = 150;
addChild(t5);
trace(fault);
}
}
}
in asp.net project - website.
I have a page called Default2.aspx which contains:
HTML Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>RemotingTest</title>
<script language="javascript">AC_FL_RunContent = 0;</script>
<script src="http://www.flepstudio.org/forum/advanced-actionscript-3-0/AC_RunActiveContent.js" language="javascript"></script>
</head>
<body bgcolor="#ffffff">
<!--url's used in the movie-->
<!--text used in the movie-->
<!-- saved from url=(0013)about:internet -->
<script language="javascript">
if (AC_FL_RunContent == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
'width', '550',
'height', '400',
'src', 'RemotingTest',
'quality', 'high',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'align', 'middle',
'play', 'true',
'loop', 'true',
'scale', 'showall',
'wmode', 'window',
'devicefont', 'false',
'id', 'RemotingTest',
'bgcolor', '#ffffff',
'name', 'RemotingTest',
'menu', 'true',
'allowFullScreen', 'false',
'allowScriptAccess','sameDomain',
'movie', 'RemotingTest',
'salign', ''
); //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,0,0" width="550" height="400" id="RemotingTest" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="RemotingTest.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#ffffff" /> <embed src="http://www.flepstudio.org/forum/advanced-actionscript-3-0/RemotingTest.swf" quality="high" bgcolor="#ffffff" width="550" height="400" name="RemotingTest" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</noscript>
</body>
</html>
And the code behind, just to see if will go into it
Code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public void Test()
{
//i have a break point here
string strTemp = "";
}
}
If the remoting did work, would it hit my break point?
Am not sure what I need to do in order to get this to work.
Hope someone can help me with this.
Thanks a lot, Dan.
Bookmarks