最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

JavaScript Alert in ActionScript - Stack Overflow

programmeradmin0浏览0评论

We can easily alert anything in java script. Is it possible to get this or similar alert in ActionScript ?

I have below test Class in Action Script. Trace does same as console.log() in java script. Is it possible to display messages in action script ?

package  {
    import flash.display.MovieClip; 
    public class ooas3 extends MovieClip{
        public var color:String = "red";
        public var num:Number = 100;
        public function ooas3() {
            theMovie_DoFSCommand(color,"ooas3 num is "+num);
        }


        function theMovie_DoFSCommand(color, args) {
                if (mand == "red") {
                 trace(mand + " - " + args);
        // Can above line is replaced by Alert similar to java Script Alert ?        
                }
        }       
    }   
}

As per the philipp's adivice I tested the below class on actionscript docs:

package {
       import flash.text.TextField;
       import flash.display.MovieClip;
       import flash.external.ExternalInterface;

       public class extint_test extends MovieClip {
         public function extint_test() {
           var isAvailable:Boolean = ExternalInterface.available;
           var availTxt:TextField = new TextField();
           availTxt.text = isAvailable.toString();
           addChild(availTxt);
         }
       }
     }

Above code alerts the "test" similar to javascript. This is a Flash Window that shows the message. But How to integrate similar code in my Class. i.e. How to do repalce trace ("something") with this Flash Alert window ?

We can easily alert anything in java script. Is it possible to get this or similar alert in ActionScript ?

I have below test Class in Action Script. Trace does same as console.log() in java script. Is it possible to display messages in action script ?

package  {
    import flash.display.MovieClip; 
    public class ooas3 extends MovieClip{
        public var color:String = "red";
        public var num:Number = 100;
        public function ooas3() {
            theMovie_DoFSCommand(color,"ooas3 num is "+num);
        }


        function theMovie_DoFSCommand(color, args) {
                if (mand == "red") {
                 trace(mand + " - " + args);
        // Can above line is replaced by Alert similar to java Script Alert ?        
                }
        }       
    }   
}

As per the philipp's adivice I tested the below class on actionscript docs:

package {
       import flash.text.TextField;
       import flash.display.MovieClip;
       import flash.external.ExternalInterface;

       public class extint_test extends MovieClip {
         public function extint_test() {
           var isAvailable:Boolean = ExternalInterface.available;
           var availTxt:TextField = new TextField();
           availTxt.text = isAvailable.toString();
           addChild(availTxt);
         }
       }
     }

Above code alerts the "test" similar to javascript. This is a Flash Window that shows the message. But How to integrate similar code in my Class. i.e. How to do repalce trace ("something") with this Flash Alert window ?

Share Improve this question edited Mar 19, 2012 at 12:26 Umesh Patil asked Mar 19, 2012 at 12:04 Umesh PatilUmesh Patil 10.7k16 gold badges54 silver badges81 bronze badges 1
  • 1 yes see this : code.google./p/flash-console |-| labs.findsubstance./2008/02/26/… code.google./p/flash-tracer |-| addons.mozilla/fr/firefox/addon/flashtracer – mgraph Commented Mar 19, 2012 at 14:07
Add a ment  | 

4 Answers 4

Reset to default 3

Alerts can be done in Flash environment in 2 ways :

1. The best way is to use ExternalInterface. It calls up the javascript alert function and displays content accordingly. For example,

import flash.external.ExternalInterface;

ExternalInterface.call("alert", "Hello ExternalInterface");

The swf when loaded in html shall invoke the alert window.


2. The second way is to write your own customized flash ponent/class which displays some movieclip with textfield . You need to write the functions to handle its visibility on button click("OK")

Something like alert.show is not possible in flash cs3 and above as the ponent mx.controls.Alert is available only in flash mx2004 and flex environment.

you can use the ExternalInterface.call() method... look here

f.e.:

ExternalInterface.call( "alert", "hallo" );

yes see this :

http://code.google./p/flash-console

http://labs.findsubstance./2008/02/26/firebugs-console-log-flash-debugging-made-easy/

http://code.google./p/flash-tracer

http://addons.mozilla/fr/firefox/addon/flashtracer

try adding the following line of code. alert.show("alerts") method

发布评论

评论列表(0)

  1. 暂无评论