hoony's web study

728x90
반응형

URLRequest를 이용해서 웹개발을 할때처럼 자바스크립트를 실행시킬 방법이 없을까해서
찾아봤음.
사용법은 무지 간단해 보이더군요. ㅋ
역시 모르면 힘들지만 알면 정말 간단한것 같습니다. ^^

<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        import flash.net.*;
        public function callWrapper(e:Event):void {
            public var eType:String = String(e.type);
            public var eName:String = 
String(e.currentTarget.id); public var u:URLRequest = new URLRequest
("javascript:catchClick('" + eName + "','" + eType + "')"); navigateToURL(u,"_self"); } </mx:Script> <mx:Button id="b1" click="callWrapper(event)" label="Call Wrapper"/> </mx:Application>

The enclosing HTML page includes the following JavaScript:

<script language="JavaScript">
    function catchClick(name, type) {
        alert(name + " triggered the " + type + " event.");
    }
</script>

You can also use the navigateToURL() method with basic JavaScript functions in the URLRequest itself. For example, you can launch the default e-mail client with a single line of code:

public function sendMail():void {
    public var u:URLRequest = new URLRequest("mailto:" + ta1.text);
    navigateToURL(u,"_self");
}


728x90

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading