Skip to main content
Inspiring
January 21, 2013
Answered

History back scene button in AS3

  • January 21, 2013
  • 1 reply
  • 1523 views

I want to go back scene (history back scene) on click. I try this code but, I got this OUTPUT ERROR

i try to publish this file in "AIR for ANDROID"

package  {

          import flash.display.SimpleButton;

          import flash.display.MovieClip;

          import flash.events.MouseEvent;

          import flash.external.ExternalInterface;

 

          public class hback extends SimpleButton {

               public function hback() {

                                   this.addEventListener(MouseEvent.CLICK, clickF);

                              }

              

         public function clickF(e:MouseEvent):void {

               ExternalInterface.call("goBack");

                    }

          }

}

OUTPUT ERROR

[SWF] 01.swf - 6919 bytes after decompression

Error: Error #2067: The ExternalInterface is not available in this container. ExternalInterface requires Internet Explorer ActiveX, Firefox, Mozilla 1.7.5 and greater, or other browsers that support NPRuntime.

          at Error$/throwError()

          at flash.external::ExternalInterface$/call()

          at hback/clickF()

This topic has been closed for replies.
Correct answer kglad

you need a javascript goBack function defined in the embedding html and you need to load that embedding html into a browser.  or, you could inject the javascript using actionscript:

import flash.external.ExternalInterface;

var js:XML =

<script>

    <![CDATA[

        function(){

            function goBack(){

                history.go(-1);

            };

            goBack();

        }

    ]]>

</script>

ExternalInterface.call(js);

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 21, 2013

you need a javascript goBack function defined in the embedding html and you need to load that embedding html into a browser.  or, you could inject the javascript using actionscript:

import flash.external.ExternalInterface;

var js:XML =

<script>

    <![CDATA[

        function(){

            function goBack(){

                history.go(-1);

            };

            goBack();

        }

    ]]>

</script>

ExternalInterface.call(js);

71081Author
Inspiring
January 21, 2013

but how boss??

kglad
Community Expert
Community Expert
January 21, 2013

see message 1.

i added a way to inject the js.