Link to home
Start Free TrialLog in
Avatar of Sean31081
Sean31081

asked on

Flash MX, C#, Embeding

I've seen several examples where someone has passed a variable to Flash from C#, but my question is how do you pass a variable from Flash to C#?  

I'm looking to embed a Flash movie in a C# form and when the user clicks on an object in the flash movie, the form will react by which object the user clicked on.  In other words, how do pass data to C# that will tell me what object i clicked?

Thank you much,
Sean
Avatar of kanary
kanary

hello Sean31081,

concerning the first question, u first define a loadVars(); object. then u can use its both functions load and send for loading and sending data, u can also use a combination of them  like this:

myData=new loadVars();
myData.var1=value1;
myData.sendAndLoad("http://localhost/myapp.aspx",myData,"POST");
myData.onLoad=function()
{
   trace(myData.data1);
}
what did this code do?

first we defined a load vars object that will be used to send data to asp file and recieve data from it.

them we added a variable to myData object that will be sent to the aspx file.

now we used the sendAndLoad function, it take 3 paremeters:

1) the aspx file that will recieve data from flash
2) the object that will recieve the data returned from the aspx file
3) the sending method (post or get)
    if u sent the data using post then u should retrieve it there using:  Request.Form("var1");
    andif u sent it using get u should retrieve it using: Request.QueryString("var1");

the onLoad function makes sure that the data has been loaded and recieved from the aspx file by flash.
suppose there in aspz file u pronted a response value like this;
response.write("data1=true");

the data1 is stored into the myData object after it was sent to the flash file
and now u can print its value using:
trace(myData.data1);


now concerning the object i clicked on:
Do you mean a ASP.NET Webform or a Windows form?

Embedding a swf on a Windows Form:

- Do you have VS.NET? if not, you'll have to create a .NET wrapper with command prompt, if you do:
- Right click in your toolbox, choose 'customize toolbox'
- from COM Components, add Shockwave Flash Object (SFO)
- from the toolbox you can add the SFO to your form
- In the event 'FSCommand' write the handler for SWF Commands.
- the SFO has a property 'embed' to enable embedding the actual SWF movie in your app...

The only way to communicate from Flash is with FSCommands, so you can't pass objects, only strings.
In your Flash movie you use the actionscript function

fscommand(command, arguments)

Luck
concerning objects u can use the instanseof operator.

but im little confused, why u wana know which object is clicked in flash.

in ur flash form, add a handler for every vomponent u have.
if u clicked the pudhbutton sned something to aspx file
and if u clicked another component send other thing to the aspx file.

plzz specify clearly
If u really want it for ALL objects, this little piece of code will fire fscommands for EVERY movieclip when they're clicked, passing the name of the object as argument... check!

MovieClip.prototype.onRelease = function(){
      fscommand("onRelease", this._name);
      trace("onRelease", this._name);
}

But I still wonder if you want a Windows form or Web form...
Avatar of Sean31081

ASKER

Sorry, i'm looking for a Windows Form and I'm using .NET 2002.

Let me try a few of these out then I'll repost

Thanks All.
wooooooooooooow, how man.

flash won't be able to send data to windows form at all.

as u saw above it could send to aspx file implemented using C#.

it can't send data to non-web-enabled projects.
ofcourse it can mr kanary, it can send fscommands to the browser right?

I created a pretty big application in Delphi with a lot of Flash Interaction, only through ActionScript FSCommands ...

the thing you see in your browser is nothing but an ActiveX control that you can put in any windows application, where you can catch the event 'fscommand' and in response to that, you can set a variable in flash, zoom in, jump to a frame or format the users harddrive... :) whatever suits you...
:)) nice hint.

that's the "joint"

so using activeX (that could be used in web application also and with windows applications) u can communicate with flash.

that's why i wasn't immagining communicating  flash with windows forms.
Excuse me for asking this stupid question, but......

What kind of code would have i have to write in the VS.NET program to catch that variable?

Sorry for the ignorance!
ASKER CERTIFIED SOLUTION
Avatar of Uritsukidoji
Uritsukidoji

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial