473,748 Members | 2,551 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

flash button not working in .net

25 New Member
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("product s.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 4487
rrocket
116 New Member
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 New Member
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 Recognized Expert New Member
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.dataF ormat = URLLoaderDataFo rmat.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 New Member
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 Recognized Expert New Member
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&pa ram2=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 New Member
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 Recognized Expert Specialist
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 Recognized Expert New Member
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 Recognized Expert New Member
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
8598
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 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx). On the aspx page I have the object tag as follows:
115
13322
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 so I can't use the site. What complete losers! When are businesses going to understand that the purpose of a web site is to communicate with customers or business parterns and NOT so your "web master or "web engineer" can show off what they...
8
5909
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 clients (Internet Explorer). My flash content was originally brought in via the “flash satay” method, but I have since used some server-side magic do deliver one <objecttag
5
11982
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 load fires and the web page is displayed. But then if I close that page and then click on the same button the page load does NOT fire and I get the original web page back again. If I do this in Fire Fox it works but not in IE. If I put a simple...
6
16318
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 on flash opens info underneath map in a separate div. div that has hide/show content is called "operator" I found this code, but i'm not sure it's what I need, and it's not working... Flash file>button on stage>script:
1
3999
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 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...
1
2935
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 gets filled when the Flash buttons are clicked. Those pieces work as expected. On several of the iframe pages I have some movable panels that are Javascript driven. They work fine the first time the page is loaded. However, if the user goes to...
0
8832
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9562
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9386
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9333
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9254
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8255
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6799
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4608
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.