Skip to main content
January 18, 2013
Answered

AS3 in asp.net

  • January 18, 2013
  • 23 replies
  • 6502 views

Hi All,

I have an as3 project made in flash builder 4.6 that I want to include in asp.net project. In as3 there is an object which position I want to save in Database after button click in asp.net. There will be posibility to set 5 different positions. I will also have 5 buttons in asp.net to show saved position, and also a button which will invoke movement of object from first to last position. How can I achieve it?

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer kglad

Maybe I will write what is the all issues. Flash Application is a part of a large Asp.Net project. There will be a model which user will be able to set position and save it in Database. There will be posibilty to save 5 different positions. Then user will be able to show every positions, and use "play" option where model will be moving from first to last position. So what I need to do is:

1. make a save button which will send information to flash to invoke savevalue().

        public function urlLoader_complete(e:Event):void {

            testN = e.target.data;

            if (testN == "nowe")

            {  

             savevalue()

             }

         }

     and then send back position variables and save it in asp.net DB

2. make 5 position buttons which will invoke getposition() function

           ....

           if (testN == "Pos1")

           {

           getposition1()

           }

3. make "play" button which will invoke play()

           if (testN == "play")

           {

           play()

           }

I would like to make those buttons in asp.net, because i will be able to send also a username from asp.net DB. Unless there is a better solution


it looks like your post in message 12 is a completely different topic.

you're now trying to communicate from asp generated buttons to an embedded flash file?  if yes, you would use the externalinterface class. in particular, you would use the addCallback method.

23 replies

kglad
Community Expert
Community Expert
January 18, 2013

use the urlloader class to call your asp file.

January 18, 2013

But in what form should be variables send from asp.net? Could I use POST FORM, or something similar?

<script src="http://ajax.aspnetcdn.com/ajax/jquery/jquery-1.5.1.js" type="text/javascript"></script>
<script type="text/javascript">
     $(function () {
         $("#btnPayNow").click(function (event) {
             event.preventDefault();

             //construct htmlForm string
             var htmlForm = "<form id='myform' method='POST' action='http://localhost:49816/WebSite1/FlareZnamNew2.swf'>" +
                 "<input type='hidden' id='name' value='15' />" +
             "</form>";

             //Submit the form
             $(htmlForm).appendTo("body").submit();
         });
     });
</script>
            var urlRequest:URLRequest = new URLRequest("http://localhost:49816/WebSite1/CwiczeniaC2.aspx");
            var urlLoader:URLLoader = new URLLoader();
            urlLoader.dataFormat = URLLoaderDataFormat.TEXT; // default
            urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
            urlLoader.load(urlRequest);
           
            function urlLoader_complete(evt:Event):void {
                testN = urlLoader.data;
                updateTextFields()
            }

kglad
Community Expert
Community Expert
January 18, 2013

:

var urlRequest:URLRequest = new URLRequest("http://localhost:49816/WebSite1/CwiczeniaC2.aspx");
            var urlLoader:URLLoader = new URLLoader();

// you probably don't want this unless your asp page is parsing the sent string.  typically you use VARIABLES and the POST (or GET) method property of your urlrequest and you create a urlvariables instance to contain your data and use the data property of the request:

      //      urlLoader.dataFormat = URLLoaderDataFormat.TEXT;

urlLoader.dataFormat=URLLoaderDataFormat.VARIABLES;

urlRequest.method="POST";

var urlVariables:URLVariables=new URLVariables();

urlVariables.whatever=something;

// etc

urlRequest.data=urlVariables;
            urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
            urlLoader.load(urlRequest);
           
            function urlLoader_complete(evt:Event):void {
                testN = urlLoader.data;
                updateTextFields()
            }