Skip to main content
Inspiring
December 26, 2012
Answered

How to use geturl using class in AS3

  • December 26, 2012
  • 1 reply
  • 1730 views

i try this code (my class name is bAEForm)

package {

     

      import flash.display.SimpleButton;

      import flash.display.Sprite;

      import flash.net.navigateToURL;

      import flash.net.URLRequest;

      import flash.net.URLRequestMethod;

      import flash.net.URLVariables;

    public class bAEForm extends Sprite {

        public function bAEForm() {

            var url:String = "http://www.google.com";

            var request:URLRequest = new URLRequest(url);

            var variables:URLVariables = new URLVariables();

variables.exampleSessionId = new Date().getTime();

variables.exampleUserLabel = "guest";

request.data = variables;

request.method = URLRequestMethod.POST;

navigateToURL(request);

        }

    }

}

I got error this error

The class “bAEForm” msut subclass “flash.disply.SimpleButto” since it is linked to library symbol of that type.

This topic has been closed for replies.
Correct answer kglad

use:

package {

          import flash.display.SimpleButton;

          import flash.display.Sprite;

    import flash.net.navigateToURL;

    import flash.net.URLRequest;

    import flash.net.URLRequestMethod;

    import flash.net.URLVariables;

import flash.events.MouseEvent;

    public class bAEForm extends SimpleButton {

        public function bAEForm() {

            this.addEventListener(MouseEvent.CLICK,clickF);

        }

private function clickF(e:MouseEvent):void{

var url:String = "http://www.google.com";

            var request:URLRequest = new URLRequest(url);

            var variables:URLVariables = new URLVariables();

            variables.exampleSessionId = new Date().getTime();

            variables.exampleUserLabel = "guest";

            request.data = variables;

            request.method = URLRequestMethod.POST;

            navigateToURL(request,"_self");

}

    }

}

1 reply

71081Author
Inspiring
December 26, 2012

I got the solution but again facing some problem. When I go my scene (where I put my button), Automatically 2 browsers are open. I don’t need this. I need, when I press my button then browser should to be open

Any suggestion

package {

          import flash.display.SimpleButton;

          import flash.display.Sprite;

    import flash.net.navigateToURL;

    import flash.net.URLRequest;

    import flash.net.URLRequestMethod;

    import flash.net.URLVariables;

    public class bAEForm extends SimpleButton {

        public function bAEForm() {

            var url:String = "http://www.google.com";

            var request:URLRequest = new URLRequest(url);

            var variables:URLVariables = new URLVariables();

            variables.exampleSessionId = new Date().getTime();

            variables.exampleUserLabel = "guest";

            request.data = variables;

            request.method = URLRequestMethod.POST;

            navigateToURL(request);

        }

    }

}

I got the solution but again facing some problem. When I go my scene (where I put my button), Automatically 2 browsers are open. I don’t need this. I need, when I press my button then browser should to be open

kglad
Community Expert
Community Expert
December 26, 2012

try:

package {

          import flash.display.SimpleButton;

          import flash.display.Sprite;

    import flash.net.navigateToURL;

    import flash.net.URLRequest;

    import flash.net.URLRequestMethod;

    import flash.net.URLVariables;

    public class bAEForm extends SimpleButton {

        public function bAEForm() {

            var url:String = "http://www.google.com";

            var request:URLRequest = new URLRequest(url);

            var variables:URLVariables = new URLVariables();

            variables.exampleSessionId = new Date().getTime();

            variables.exampleUserLabel = "guest";

            request.data = variables;

            request.method = URLRequestMethod.POST;

            navigateToURL(request,"_self");

        }

    }

}

71081Author
Inspiring
December 26, 2012

same prob boss

I have 2 scenes. In 2nd scene I create a button (in this button I use the code). After publish when I go my 2nd scene automatically 2 browsers is open, I need, when I press my button then browser should be open but its opening automatically