473,385 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

flash button not working in .net

i am using a flash template for my website.i am working on asp.net 2.0 for creating my website. this flash template has got buttons.on the click of the button i want the user to be redirected to the respective pages.hence i have written the following code in the action script window of flash for my "products" button
on (press)
{
getURL("products.aspx","_self","POST");
}
but when i run my page in asp.net the click of my products button does not show any change.it is still in the same page.what code should i write in order to make this button work?in short how do i redirect my flash button to the aspx page?Thanking in advance.
Oct 12 '07 #1
9 4465
rrocket
116 100+
Is it even possible to post variables to .NET? I have been searching the internet and only come up with info on how to do it with PHP. If anyone has any info on doing it with .NET (C#) I would appreciate it.
Oct 25 '07 #2
rrocket
116 100+
I am trying to create a flash email form with Actionscript 3.0 and have gotten this far with it:
Expand|Select|Wrap|Line Numbers
  1. var variables:URLVariables = new URLVariables();
  2. var varSend:URLRequest = new URLRequest("http://thefreightrateco.com/dev/Contactus.aspx");
  3. var varLoader:URLLoader = new URLLoader;
  4. varSend.method = URLRequestMethod.POST;
  5. varSend.data = variables;
  6.  
  7. stop();
  8.  
  9. stage.focus = tbName;
  10.  
  11.  
  12. send_btn.addEventListener(MouseEvent.CLICK, sendEmail);
  13.  
  14. function sendEmail(event:MouseEvent):void
  15. {
  16.     variables.tbName = tbName.text;
  17.        variables.tbEmail = tbEmail.text;
  18.        variables.tbBody = tbBody.text;
  19.        varLoader.load(varSend);
  20. }
I have the same issue with the button not doing anything... I would prefer to use C# for the backend and am using .NET 2.0... Anyone have any ideas on what the problem is?
Oct 26 '07 #3
xNephilimx
213 Expert 100+
Hi! I really don't know anything about the .NET framework, I use php, but POST and GET are standard methods for sending variables to any server-side script.
Also if you are waiting any kind of response from the server when sending the request, it's just in vain, since you didn't added any event listener for the Complete event of the URLLoader object. Unless you add it and at least make the listener function trance something the flash movie won't do anything, but that doesn't mean it's not working.
You also missed the dataFormat for the URLLoader:

varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

If you want you can check this link http://livedocs.adobe.com/flex/201/h...ons_173_2.html
It's very helpfull, but it's for flex, anyway it's the same thing, just ommit the scope part (private, public and stuff)

Best regards
The_Nephilim

I am trying to create a flash email form with Actionscript 3.0 and have gotten this far with it:
Expand|Select|Wrap|Line Numbers
  1. var variables:URLVariables = new URLVariables();
  2. var varSend:URLRequest = new URLRequest("http://thefreightrateco.com/dev/Contactus.aspx");
  3. var varLoader:URLLoader = new URLLoader;
  4. varSend.method = URLRequestMethod.POST;
  5. varSend.data = variables;
  6.  
  7. stop();
  8.  
  9. stage.focus = tbName;
  10.  
  11.  
  12. send_btn.addEventListener(MouseEvent.CLICK, sendEmail);
  13.  
  14. function sendEmail(event:MouseEvent):void
  15. {
  16.     variables.tbName = tbName.text;
  17.        variables.tbEmail = tbEmail.text;
  18.        variables.tbBody = tbBody.text;
  19.        varLoader.load(varSend);
  20. }
I have the same issue with the button not doing anything... I would prefer to use C# for the backend and am using .NET 2.0... Anyone have any ideas on what the problem is?
Oct 30 '07 #4
rrocket
116 100+
Hello,

Thanks for the article... I did read it, but am still missing a few things.

This is what I have now:
Expand|Select|Wrap|Line Numbers
  1. var variables:URLVariables = new URLVariables();
  2. var varSend:URLRequest = new URLRequest();
  3. varSend.url = "http://www.thefreightrateco.com/dev/contactus.aspx";
  4. varSend.method = URLRequestMethod.POST;
  5. varSend.data = variables;
  6. var varLoader:URLLoader = new URLLoader();
  7. varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  8. varLoader.addEventListener(Event.COMPLETE, sendEmail);
  9.  
  10.  
  11. stop();
  12.  
  13. stage.focus = tbName;
  14.  
  15.  
  16. send_btn.addEventListener(MouseEvent.CLICK, sendEmail);
  17.  
  18. function sendEmail(event:MouseEvent):void
  19. {
  20.     variables.tbName = tbName.text;
  21.        variables.tbEmail = tbEmail.text;
  22.        variables.tbBody = tbBody.text;
  23.        trace(varSend.data);
  24.     varLoader.load(varSend);
  25.     //varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  26. }
The trace shows the right data and an error message:
Expand|Select|Wrap|Line Numbers
  1. tbEmail=Bob%40Bob%2Ecom&tbBody=Body%20of%20email&tbName=Bob
  2. Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
  3.     at Error$/throwError()
  4.     at flash.net::URLVariables/decode()
  5.     at flash.net::URLVariables$iinit()
  6.     at flash.net::URLLoader/flash.net:URLLoader::onComplete()
How do I append the query string to the URL?
Oct 30 '07 #5
xNephilimx
213 Expert 100+
I see, your problem is that your function sendEmail is only accepts mouse events.
Also, the event listener fot the URLLoader fires the function once the mail has already been sent. The mail is being sent when you click the button, the event listener for the URLLoader is just to keep track of the completition process.

So write a function to tell the user when the email has been sent.
and use the one you got (sendEmail) just for the mouse.

You cannot use a event handler function for various types of events.

You also need to pass the URL variables as a query string (like in Ajax), not by creating nonexistent properties.
Something like this: "param1=val1&param2=val2";

Your code would be like this now:

Expand|Select|Wrap|Line Numbers
  1. stop();
  2. var variables:URLVariables = new URLVariables();
  3. var varSend:URLRequest = new URLRequest("http://www.thefreightrateco.com/dev/contactus.aspx");
  4. varSend.method = URLRequestMethod.POST;
  5. var varLoader:URLLoader = new URLLoader();
  6. varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  7. varLoader.addEventListener(Event.COMPLETE, onComplete);
  8.  
  9. stage.focus = tbName;
  10.  
  11.  
  12. send_btn.addEventListener(MouseEvent.CLICK, sendEmail);
  13.  
  14. function onCompete(e:Event):void {
  15.     trace('The email has been sent');
  16.     //you can add eny other functionality to actually tell the user
  17.     //I'm just tracing a legend
  18. }
  19.  
  20. function sendEmail(event:MouseEvent):void
  21. {
  22. variables.decode("tbName=" + tbName.text + "&tbEmail=") + tbEmail.text + "&tbBody=" + tbBody.text);
  23. varSend.data = variables;
  24.  
  25.        trace(varSend.data);
  26.  
  27.     varLoader.load(varSend);
  28. }
Try that and tell me how it worked

Best regards
The_Nephilim
Oct 30 '07 #6
rrocket
116 100+
It is still giving me the same errors after I dropped the code you gave me in.

Thanks,
RRocket
Oct 30 '07 #7
Motoma
3,237 Expert 2GB
Hello,

Thanks for the article... I did read it, but am still missing a few things.

This is what I have now:
Expand|Select|Wrap|Line Numbers
  1. var variables:URLVariables = new URLVariables();
  2. var varSend:URLRequest = new URLRequest();
  3. varSend.url = "http://www.thefreightrateco.com/dev/contactus.aspx";
  4. varSend.method = URLRequestMethod.POST;
  5. varSend.data = variables;
  6. var varLoader:URLLoader = new URLLoader();
  7. varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  8. varLoader.addEventListener(Event.COMPLETE, sendEmail);
  9.  
  10.  
  11. stop();
  12.  
  13. stage.focus = tbName;
  14.  
  15.  
  16. send_btn.addEventListener(MouseEvent.CLICK, sendEmail);
  17.  
  18. function sendEmail(event:MouseEvent):void
  19. {
  20.     variables.tbName = tbName.text;
  21.        variables.tbEmail = tbEmail.text;
  22.        variables.tbBody = tbBody.text;
  23.        trace(varSend.data);
  24.     varLoader.load(varSend);
  25.     //varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
  26. }
The trace shows the right data and an error message:
Expand|Select|Wrap|Line Numbers
  1. tbEmail=Bob%40Bob%2Ecom&tbBody=Body%20of%20email&tbName=Bob
  2. Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
  3.     at Error$/throwError()
  4.     at flash.net::URLVariables/decode()
  5.     at flash.net::URLVariables$iinit()
  6.     at flash.net::URLLoader/flash.net:URLLoader::onComplete()
How do I append the query string to the URL?
Try this out:

Expand|Select|Wrap|Line Numbers
  1. function EmailPost(name, email, body)
  2. {
  3.     var postData = new LoadVars();
  4.  
  5.     //Load up all the variables you want to POST
  6.     postData.tbName = name;
  7.     postData.tbBody = body;
  8.     postData.tbEmail = email;
  9.  
  10.     postData.send("http://www.thefreightrateco.com/dev/contactus.aspx", "_self","POST");
  11. }
  12.  
Nov 1 '07 #8
xNephilimx
213 Expert 100+
Hi motoma, the functionalities of loadvars and others in AS2, in AS3 moved to the URLLoader Class, so LoadVars shouldn't work. at least in Flex2, I don't know if Flash CS3 offers some kind of backwards compatibility with AS2 when using AS3. Even thoug I don't think so, because you can choose which language you will use.

I'll try this exaple in flex to see if I made some typo in the way and post the working code.

Best regards,
The_Nephilim

Try this out:

Expand|Select|Wrap|Line Numbers
  1. function EmailPost(name, email, body)
  2. {
  3.     var postData = new LoadVars();
  4.  
  5.     //Load up all the variables you want to POST
  6.     postData.tbName = name;
  7.     postData.tbBody = body;
  8.     postData.tbEmail = email;
  9.  
  10.     postData.send("http://www.thefreightrateco.com/dev/contactus.aspx", "_self","POST");
  11. }
  12.  
Nov 1 '07 #9
xNephilimx
213 Expert 100+
Got it, all you had to change was the dataFormat of the URLLoader to text.
I also reorganized the code into a function, so it's easier to read now:

Expand|Select|Wrap|Line Numbers
  1. send_btn.addEventListener(MouseEvent.CLICK, onClick);
  2.  
  3. function onClick(e:MouseEvent):void {
  4.     var src:String = "tbName=" + tbName.text + "&tbEmail=" + tbEmail.text + "&tbBody=" + tbBody.text;
  5.     var vars:URLVariables = new URLVariables(src);
  6.     var request:URLRequest = new URLRequest('http://www.thefreightrateco.com/dev/contactus.aspx');
  7.     request.method = URLRequestMethod.POST;
  8.     request.data = vars;
  9.  
  10.     var loader:URLLoader = new URLLoader();
  11.     loader.dataFormat = URLLoaderDataFormat.TEXT;
  12.  
  13.     loader.load(request);
  14. }
  15.  
I did this in Flex and it's working perfectly.

Best regards,
The_Nephilim
Nov 1 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Keith Rowe | last post by:
Hello, I am trying to reference a Shockwave Flash Object on a vb code behind page in an ASP.NET project and I receive the following error: Guid should contain 32 digits with 4 dashes...
115
by: post2google | last post by:
I was thinking about where to go for lunch the other day, so I went to hardees.com to see what the menu looked like these days. What comes up is a big note that my flash version is not new enough...
8
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web...
5
by: mutlyp | last post by:
I have an web application, for a menu to go to page to page wit in the web app I am using flash buttons. The problem is that the first time I click on the flash button everything works fine the page...
6
elamberdor
by: elamberdor | last post by:
Hi All! Trying to get a drop down hide/show div on a html page triggered by a button in flash. (Intro: Very very Little experience in dynamic flash) setup: html page, flash map on page, button...
1
by: anuparvathy | last post by:
i am using a flash template for my website.i am working on asp.net 2.0 for creating my website. this flash template has got buttons.on the click of the button i want the user to be redirected to the...
1
by: johnlanglois | last post by:
I found several discussions that hinted at my issue, but none that contained a solution. I have a main page that contains a FLASH movie/Menu. The rest of the site is contained in an IFrame that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.