ทำให้ As3 และ Javascript คุยกันได้ by

28
Dec
1

เรียก Function AS3 ด้วย Javascript

http://blog.code-head.com/calling-a-javascript-function-from-actionscript-3-flash

ง่ายมากมายด้วย ExternalInterface

import flash.external.ExternalInterface;
...
ExternalInterface.call("your_javascript_function()");

จะเอาค่า Return ก็ได้


var x:int = ExternalInterface.call("get_x()");

ส่ง Parameter กะได้ :-D

var retval:int = ExternalInterface.call("some_js_function", "the-argument");

เรียก Function AS3 ด้วย Javascript

http://codingforums.com/showthread.php?t=152181

Javascript

			// Provides the proper address for the movie depending on browser
			function getFlashMovie(movieName) {
			  	var isIE = navigator.appName.indexOf("Microsoft") != -1;
			  	return (isIE) ? window[movieName] : document[movieName];
			}

			function playMovie() { 
				getFlashMovie("video").JStoASviaExternalInterface("start");
			}

Action Script

function getTextFromJavaScript(str:String):Void {
		if (str = "start") {
startVideo();
}
}
ExternalInterface.addCallback("JStoASviaExternalInterface", this, getTextFromJavaScript);

Enjoy this article?

Consider subscribing to our RSS feed!

1 ความเห็น

ใส่ความเห็น

RSS feed for comments on this post

 เราชนะรอบ 4 | ยืมเงิน 3000 ด่วน | แอพกู้เงิน | แอพเงินด่วน | สินเชื่อออนไลน์อนุมัติทันที | Site Map | กู้เงินก้อน | กระเป๋าตัง | thisshop และ ยืมเงินฉุกเฉิน 5000 ด่วน