open frame in html by clicking flash button

  • gracequeen
  • Newbie
  • Newbie
  • gracequeen
  • Posts: 14

Post 3+ Months Ago

hi buddies,

actually i need to detect which button have been clicked 1st in flash form by using javascript. i have 4 html page:

1. form.html - which include a flash form with 2 buttons n some input field.

2. a.html - will appear at the right frame of main.html when btn1 been clicked.

3. b.html - will appear at the right frame of main.html when btn2 been clicked.

4. main.html

From the form.html(single page), i need to detect which button have been clicked first. Let said, if i clicked btn1first, a.html will appear on the right frame of main.html, n form.html will straight away be insert into the left frame of main.html, same thing happen if i clicked btn2 first. However if i clicked 2nd btn fist, b.html will appear at the right frame of main.html, n then when i click btn1after that, a.html will appear at the bottom right frame of main.html, so the right side of main.html will become 2 row of frames, therefore, main.html will have 3 frames after both buttons been clicked.

Is it possible to do so? n how do to work it out? BTW, the input data must not be change when the form.html become 1 part of main.html.

main.html
___________|____________
| |
form.html content
_________|_________
| |
a.html b.html


anyone can help on this?

Thanks.... :D

gracequeen:roll:
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

:scratchhead: Why not add getURL("a.html", "name_Of_Frame"); to the event handler of the buttons in flash ?

Other than that if you want to communicate with javascript with the buttons in the flash form you need to use fsCommand.

Flashs reference panel gives a really good explaination of how to use this. Here is a brief exerpt,
Macromedia wrote:
To use the fscommand action to send a message to a scripting language such as JavaScript in a Web browser, you can pass any two parameters in the command and parameters parameters. These parameters can be strings or expressions and are used in a JavaScript function that "catches," or handles, the fscommand action.

In a Web browser, the fscommand action calls the JavaScript function moviename_DoFScommand in the HTML page containing the Flash movie. The moviename is the name of the Flash Player as assigned by the NAME attribute of the EMBED tag or the ID property of the OBJECT tag. If you assign the Flash Player the name myMovie, the JavaScript function called is myMovie_DoFScommand.

The following example uses the fscommand action applied to a button in Flash to open a JavaScript message box in an HTML page. The message itself is sent to JavaScript as the fscommand parameter.

You must add a function to the HTML page that contains the Flash movie. This function, myMovie_DoFSCommand sits in the HTML page and waits for an fscommand action in Flash. When an fscommand is triggered in Flash (for example, when a user presses the button), the command and parameter strings are passed to the myMovie_DoFSCommand function. You can use the passed strings in your JavaScript or VBScript code in any way you like. In this example, the function contains a conditional if statement that checks to see if the command string is "messagebox". If it is, a JavaScript alert box (or "messagebox") opens and displays the contents of the parameters string.

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

}

In the Flash document, add the fscommand action to a button:

fscommand("messagebox", "This is a message box called from within Flash.")

You can also use expressions for the fscommand action and parameters, as in the following example:

fscommand("messagebox", "Hello, " + name + ", welcome to our Web site!")
  • gracequeen
  • Newbie
  • Newbie
  • gracequeen
  • Posts: 14

Post 3+ Months Ago

Thanks, joebert!

i have tried using "getURL..." like the 1 u have shown me, but it's not working...... may be it's the way that i detect the button affect the "getURL".... this is the button's script which i try to detect which buttons have been clicked 1st. (there r 2 buttons there, which i need to detect by using javasript.)

Code: [ Select ]
on(release){
btn2.onRelease = function() {
    if (this.btn1 == undefined) {
        //if (this.btn1.onRelease = 1) {
        //getURL("page2_sb.html", "_top");
        getURL("distance.html", "right_frame");
    }else {
        //getURL("page2_pop1.html", "_top");
        getURL("guide.html", "right_top");
        getURL("distance.html", "right_bottom");
        }
};
}
  1. on(release){
  2. btn2.onRelease = function() {
  3.     if (this.btn1 == undefined) {
  4.         //if (this.btn1.onRelease = 1) {
  5.         //getURL("page2_sb.html", "_top");
  6.         getURL("distance.html", "right_frame");
  7.     }else {
  8.         //getURL("page2_pop1.html", "_top");
  9.         getURL("guide.html", "right_top");
  10.         getURL("distance.html", "right_bottom");
  11.         }
  12. };
  13. }



any other suggestions?

:cry:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

Use this for the event handlers in flash,

Code: [ Select ]
_root.pathToButtonOne.onRelease = function(){
   fscommand("buttonCheck", "1")
}
_root.pathToButtonTwo.onRelease = function(){
   fscommand("buttonCheck", "2")
}
  1. _root.pathToButtonOne.onRelease = function(){
  2.    fscommand("buttonCheck", "1")
  3. }
  4. _root.pathToButtonTwo.onRelease = function(){
  5.    fscommand("buttonCheck", "2")
  6. }


In main.html's javascript script use this,
Code: [ Select ]
// Replace MOVIENAME with the id/name attribute in your object/embed tag,
// and leave the _ between it and DoFSCommand
function MOVIENAME_DoFSCommand(command, args) {
   if (command == "buttonCheck") {
     if(args == 1){
        //.........handle button one actions
     }else{
        //.........handle button two actions
     }
   }
}
  1. // Replace MOVIENAME with the id/name attribute in your object/embed tag,
  2. // and leave the _ between it and DoFSCommand
  3. function MOVIENAME_DoFSCommand(command, args) {
  4.    if (command == "buttonCheck") {
  5.      if(args == 1){
  6.         //.........handle button one actions
  7.      }else{
  8.         //.........handle button two actions
  9.      }
  10.    }
  11. }

The only things that need changed are MOVIENAME and //.........handle button one/two actions
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

be sure the frames are name properly when targetting them. What does the frames page html look like?
  • gracequeen
  • Newbie
  • Newbie
  • gracequeen
  • Posts: 14

Post 3+ Months Ago

Thanks buddies.....

i have try so many method to solve the prob... but still not working....

currently i try to use this code, but i think the combination of 2 function is still having some prob.....
:cry:

the code that i have apply in flash button:
---------------------------------
Code: [ Select ]
on(release) {
    // change thisVar for each button
    thisVar=1
    getURL("java script:setVar('"+thisVar+"');");
}
  1. on(release) {
  2.     // change thisVar for each button
  3.     thisVar=1
  4.     getURL("java script:setVar('"+thisVar+"');");
  5. }


------------------------------------------------------------------------------
and the html:

Code: [ Select ]
<HTML>
<script language="JavaScript">
var i = 0;
function deleteIframe () {
 i--;
 if (document.all)
  document.all['iframe' + i].outerHTML = '';
 else if (document.getElementById) {
  var ifr = document.getElementById('iframe' + i);
  ifr.parentNode.removeChild(ifr);
 }
}
function addIframe () {
 if (document.all)
  document.body.insertAdjacentHTML('beforeEnd',url);
 else if (document.getElementById) {
  var ifr = document.createElement('IFRAME');
  ifr.src = url;
  document.body.appendChild(ifr);
 }
}
</script>
<script language="JavaScript">
//detect which flash button have been clicked 1st
function setVar(id) {
var thisVar=id;
var ifr = document.createElement('IFRAME');
if(id==1){
document.getElementById.addIframe();
ifr.src="guide.html";
}else if (id==2){
document.getElementById.addIframe();
ifr.src="distance.html";
}else{
document.getElementById.addIframe();
ifr.src="both.html";
}
}

</script>

<HEAD>
<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
<TITLE>Enrich - MAS Frequent Flyer Programme</TITLE>
</HEAD>

<BODY bgcolor="#FFFFFF" topmargin="50">
<table cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
    <td align="left">
    <font face="arial" size="2"><b>ENRICH Product Training</b> - <i>Calculating Points from Flights</i></font>
    </td>
    <td rowspan="3"><img src="white.jpg"></td>
    <td align="right">
    <font face="arial" size="1">Page ID: 0003MAS_P02_05_0</font></td>
</tr>
</table>

<table cellspacing="0" cellpadding="0" border="0" align="center">
<tr>
      <td colspan="3"></td>
</tr>
<tr>
      <td rowspan="3"><img src="left_border.jpg"></td>
      <td valign="top"><img src="top_border.jpg"></td>
      <td rowspan="3"><img src="right_border.jpg"></td>
</tr>
<tr>
      <td><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
WIDTH="600" HEIGHT="400" id="0003MAS_P02_05_0" ALIGN="">
<PARAM NAME=movie VALUE="0003MAS_P02_05_0.swf">
<PARAM NAME=menu VALUE=false>
<PARAM NAME=quality VALUE=best>
<PARAM NAME=scale VALUE=exactfit>
<PARAM NAME=devicefont VALUE=true>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src="0003MAS_P02_05_0.swf" quality=best scale=exactfit devicefont=true bgcolor=#FFFFFF WIDTH="600" HEIGHT="400" NAME="Mas=""
TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
</OBJECT></td>
</tr>
<tr>
      <td valign="bottom"><img src="bottom_border.jpg"></td>
</tr>
<tr>
      <td colspan="3"></td>
</tr>
<tr>
    <td></td>
        <td align="right"><font face="arial" size="1">[ <a href="page1.html">Home</a> | <a href="page1.html">Previous</a> | Next ]</font></td>
</tr>
</table>

</BODY>

</HTML>
  1. <HTML>
  2. <script language="JavaScript">
  3. var i = 0;
  4. function deleteIframe () {
  5.  i--;
  6.  if (document.all)
  7.   document.all['iframe' + i].outerHTML = '';
  8.  else if (document.getElementById) {
  9.   var ifr = document.getElementById('iframe' + i);
  10.   ifr.parentNode.removeChild(ifr);
  11.  }
  12. }
  13. function addIframe () {
  14.  if (document.all)
  15.   document.body.insertAdjacentHTML('beforeEnd',url);
  16.  else if (document.getElementById) {
  17.   var ifr = document.createElement('IFRAME');
  18.   ifr.src = url;
  19.   document.body.appendChild(ifr);
  20.  }
  21. }
  22. </script>
  23. <script language="JavaScript">
  24. //detect which flash button have been clicked 1st
  25. function setVar(id) {
  26. var thisVar=id;
  27. var ifr = document.createElement('IFRAME');
  28. if(id==1){
  29. document.getElementById.addIframe();
  30. ifr.src="guide.html";
  31. }else if (id==2){
  32. document.getElementById.addIframe();
  33. ifr.src="distance.html";
  34. }else{
  35. document.getElementById.addIframe();
  36. ifr.src="both.html";
  37. }
  38. }
  39. </script>
  40. <HEAD>
  41. <meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
  42. <TITLE>Enrich - MAS Frequent Flyer Programme</TITLE>
  43. </HEAD>
  44. <BODY bgcolor="#FFFFFF" topmargin="50">
  45. <table cellspacing="0" cellpadding="0" border="0" align="center">
  46. <tr>
  47.     <td align="left">
  48.     <font face="arial" size="2"><b>ENRICH Product Training</b> - <i>Calculating Points from Flights</i></font>
  49.     </td>
  50.     <td rowspan="3"><img src="white.jpg"></td>
  51.     <td align="right">
  52.     <font face="arial" size="1">Page ID: 0003MAS_P02_05_0</font></td>
  53. </tr>
  54. </table>
  55. <table cellspacing="0" cellpadding="0" border="0" align="center">
  56. <tr>
  57.       <td colspan="3"></td>
  58. </tr>
  59. <tr>
  60.       <td rowspan="3"><img src="left_border.jpg"></td>
  61.       <td valign="top"><img src="top_border.jpg"></td>
  62.       <td rowspan="3"><img src="right_border.jpg"></td>
  63. </tr>
  64. <tr>
  65.       <td><OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
  66. WIDTH="600" HEIGHT="400" id="0003MAS_P02_05_0" ALIGN="">
  67. <PARAM NAME=movie VALUE="0003MAS_P02_05_0.swf">
  68. <PARAM NAME=menu VALUE=false>
  69. <PARAM NAME=quality VALUE=best>
  70. <PARAM NAME=scale VALUE=exactfit>
  71. <PARAM NAME=devicefont VALUE=true>
  72. <PARAM NAME=bgcolor VALUE=#FFFFFF>
  73. <EMBED src="0003MAS_P02_05_0.swf" quality=best scale=exactfit devicefont=true bgcolor=#FFFFFF WIDTH="600" HEIGHT="400" NAME="Mas=""
  74. TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED>
  75. </OBJECT></td>
  76. </tr>
  77. <tr>
  78.       <td valign="bottom"><img src="bottom_border.jpg"></td>
  79. </tr>
  80. <tr>
  81.       <td colspan="3"></td>
  82. </tr>
  83. <tr>
  84.     <td></td>
  85.         <td align="right"><font face="arial" size="1">[ <a href="page1.html">Home</a> | <a href="page1.html">Previous</a> | Next ]</font></td>
  86. </tr>
  87. </table>
  88. </BODY>
  89. </HTML>


anyone can help on this?
  • UNFLUX
  • Genius
  • Genius
  • User avatar
  • Posts: 6376
  • Loc: twitter.com/unflux

Post 3+ Months Ago

gracequeen - please do not post your topic in multiple forums, or create
new topics in the same forum with the same problem. You have this
topic going already, with people helping you.

I removed your other 2 threads.
  • gracequeen
  • Newbie
  • Newbie
  • gracequeen
  • Posts: 14

Post 3+ Months Ago

oops... sorry.... :oops: i just hope that can get attention from more ppl to solve my prob coz i need to solve the prob within these 2 days.....

Post Information

  • Total Posts in this topic: 8 posts
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.