PDA

Просмотр полной версии : как вызвать js?


enepx
25.09.2007, 10:24
Не могу понять, все делаю по инструкции через flashmovie_DoFSCommand(command, args) , хочу вызвать js-функцию, например, alert("УРА") Юзаю Firefox2. Помогите. :bye:

Инструкция:

Create a new FLA file, and save it as myMovie.fla.
Drag two instances of the Button component to the Stage and give them the instance names window_btn and alert_btn, respectively, and the labels Open Window and Alert.
Insert a new layer on the Timeline, and rename it Actions.
Select Frame 1 of the Actions layer, and add the following ActionScript in the Actions panel: window_btn.onRelease = function() {
fscommand("popup", "http://www.adobe.com/");
};
alert_btn.onRelease = function() {
fscommand("alert", "You clicked the button.");
};

Select File > Publish Settings, and make sure that Flash with FSCommand is selected in the Template menu on the HTML tab.
Select File > Publish to generate the SWF and HTML files.
In an HTML or text editor, open the HTML file that was generated in step 6 and examine the code. When you published your SWF file using the Flash with FSCommand template on the HTML tab of the Publish Settings dialog box, some additional code was inserted in the HTML file. The SWF file's NAME and ID attributes are the filename. For example, for the file myMovie.fla, the attributes would be set to myMovie.
In the HTML file, add the following JavaScript code where the document says // Place your code here.: if (command == "alert") {
alert(args);
} else if (command == "popup") {
window.open(args, "mmwin", "width=500,height=300");
}

(For more information about publishing, see Using Flash.)
Alternatively, for Microsoft Internet Explorer applications, you can attach an event handler directly in the <SCRIPT> tag, as shown in this example:

<script Language="JavaScript" event="FSCommand (command, args)" for="theMovie">
...
</script>

Save and close the HTML file.
When you're editing HTML files outside of Flash in this way, remember that you must deselect the HTML check box in File > Publish Settings, or your HTML code is overwritten by Flash when you republish.

In a web browser, open the HTML file to view it. Click the Open Window button; a window is opened to the Macromedia website. Click the Alert button; an alert window appears.

CorC
25.09.2007, 10:41
Проще забыть про flashmovie_DoFSCommand с fscommand и использовать

getURL("javascript:<имя функции>();");

А про fscommand вы недочитали


function myDocument_DoFSCommand(command, args) {
if (command == "messagebox") {
alert(args);
}
}



In the Flash document, add fscommand() to a button:

fscommand("messagebox", "This is a message box");


http://livedocs.macromedia.com/flash/8/main/00001727.html

enepx
25.09.2007, 10:47
да все я сделал по фскомманде, добавил все и дочитал.

getURL("javascript:alert(\"test\");");
тупо не работает! как сделать еще вызов своей функции? :umnik2:

etc
25.09.2007, 12:57
Заглянуть в FAQ в тему по настройке локального доступа.