473,385 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Flash button hide/show a DIV-Layer on a html page?

elamberdor
Hi All!
Trying to get a drop down hide/show div on a html page triggered by a button in flash.
(Intro: Very very Little experience in dynamic flash)

setup: html page, flash map on page, button on flash opens info underneath map in a separate div. div that has hide/show content is called "operator"

I found this code, but i'm not sure it's what I need, and it's not working...

Flash file>button on stage>script:
Expand|Select|Wrap|Line Numbers
  1. on (release) {
  2. import flash.external.ExternalInterface;
  3. ExternalInterface.call("hideDiv", "operator");
  4. }
  5.  
And the code in the html file:
Expand|Select|Wrap|Line Numbers
  1. <html>
  2. <head>
  3. <title>page title</title>
  4. <script type="text/javascript">
  5. function hideDiv(id)
  6. {
  7.    document.getElementById(id).style.display = 'none';
  8. }
  9. </script>
  10. </head>
  11. <body>
  12. <div id="operator">
  13. </div>
  14. </body>
  15. </html>
  16.  
Does anyone have a better (working) way of getting a flash button to talk to the html page to *togggle* a hidden div?

Any ideas would be muchly appreciated!
Thankyou so much in advance!
=)
Aug 23 '07 #1
6 16292
I eventually got it to work! (Flash8, I.E 7)
Here's the answer explained for anyone else that needs it!

But I changed it a little to make it toggle......

What i've done is made the "operator" div hidden on page load with a css class attached to the div to start with:

in css file:
Expand|Select|Wrap|Line Numbers
  1. .clearfix:after {
  2. content: "."; 
  3. display: block; 
  4. height: 0; 
  5. clear: both; 
  6. visibility: hidden;
  7. }
  8.  
then in flash:
ive got a button on the stage with:

Expand|Select|Wrap|Line Numbers
  1. on (press) {
  2. import flash.external.ExternalInterface;
  3. ExternalInterface.call("toggleLayer", "operator");
  4. }
  5.  
(i'm still researching AS3 regarding on (release) button and still getting my head around the new script - its quite hard to grasp!)

then in the html file, ive got a link to the css file and the javascript in the header telling it to toggle:
Expand|Select|Wrap|Line Numbers
  1. <head>
  2. <link href="../css/SVW_css_test_1.css" rel="stylesheet" title="medium" type="text/css">
  3. <script type="text/javascript">
  4. function toggleLayer( whichLayer )
  5. var elem, vis;
  6. if( document.getElementById ) // this is the way the standards work
  7. elem = document.getElementById( whichLayer );
  8. else if( document.all ) // this is the way old msie versions work
  9. elem = document.all[whichLayer];
  10. else if( document.layers ) // this is the way nn4 works
  11. elem = document.layers[whichLayer];
  12. vis = elem.style;
  13. // if the style.display value is blank we try to figure it out here
  14. if(vis.display==''&&elem.offsetWidth!=undefined&&e lem.offsetHeight!=undefined)
  15. vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block ':'none';
  16. vis.display = (vis.display==''||vis.display=='block')?'none':'bl ock';
  17. }
  18. //-->
  19. </script>
  20.  
  21. </head>
  22.  
then i've got the div in the body with the class of clearfix to make it invisible on page load:
Expand|Select|Wrap|Line Numbers
  1. <div id="operator" class="clearfix">
  2.  
Thanks!!
=)
Aug 23 '07 #2
out of curiosity, do you know what this line does?

import flash.external.ExternalInterface;

that is a reallly useful thing to know!
Aug 23 '07 #3
Hi there!

Well ~ As far as I know (which with Dynamic flash is VERY limited)

You can call in images and swf's using the Load script into flash, but to do the opposite and use things in flash to affect things outside the flash file, you use the
Expand|Select|Wrap|Line Numbers
  1. ExternalInterface.call() function
it is used to call things like Javascript functions on the flash's HTML page. Apparently it is a more advanced version of this:
Expand|Select|Wrap|Line Numbers
  1. navigateToURL(new URLRequest("javascript:hideDiv('my_div_id');"));
Aug 23 '07 #4
xNephilimx
213 Expert 100+
Hi, there.
Not quite, the ExternalInterface class lets you communicate with javascript back and forth.
Here is a pretty good explanation http://www.thescripts.com/forum/thread694359.html

Kind regards,
The_Nephilim

Hi there!

Well ~ As far as I know (which with Dynamic flash is VERY limited)

You can call in images and swf's using the Load script into flash, but to do the opposite and use things in flash to affect things outside the flash file, you use the
Expand|Select|Wrap|Line Numbers
  1. ExternalInterface.call() function
it is used to call things like Javascript functions on the flash's HTML page. Apparently it is a more advanced version of this:
Expand|Select|Wrap|Line Numbers
  1. navigateToURL(new URLRequest("javascript:hideDiv('my_div_id');"));
Aug 24 '07 #5
sounds good, i'll have a read!
Aug 27 '07 #6
miao
1
hi! thank you for these instructions. I followed them exactly but couldn't get it to work. (the button inside the div is already visible when the page is opened.)
I have been searching the web for days now cause I'm not very experienced in java and actionscript.
please help!
Jul 7 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: dje | last post by:
In the OnClick event on a radioButtonList, I run a javascript to show/hide the appropriate div along with a submit button, which displays as expected. The problem is the submit no longer works on...
0
by: Loane Sharp | last post by:
Hi there I am trying to display a dropdownlist, label and image in the foreground with a Flash animation in the background. I'm using the following code, which works for the dropdownlist but...
2
by: Advo | last post by:
Basically, ive got information in a table for the layout purposes, as its text for a questionnaire What i Need, is for instance when the user click a radio button, that information can be...
7
by: Haines Brown | last post by:
I'm trying to use a Shockwave Flash file as is except for a line of text that it displays. I'd like to hide that line of text, and so I tried to create a black mask to do it. However, I can't move...
5
by: ali | last post by:
Hello every one i need you help regarding div hide and show. i am having a link like <a href="#" onClick="expandWin()">show/hide </a> <div id=showHide> </div> within div i have lots of...
0
by: nostef | last post by:
I am trying to hide a flash movie when a user clicks a button. Since using display: none would cause all browsers to refresh the movie, I used negative margins. This is the code: function...
5
by: rollwithit80 | last post by:
Hi Guys, I have an embedded flash file that contains a button when clicked displays a div object over the flash file by setting the div visibility attribute to visible. This is done by activating a...
3
by: rollwithit80 | last post by:
Hi Guys, I have an embedded flash file that contains a button when clicked displays a div object over the flash file by setting the div visibility attribute to visible. This is done by activating a...
5
by: Mike P | last post by:
How would I show or hide a div that is using client side Javascript based upon a server side variable? Here are my divs : <div id="idButton5" class="otherLeftBarLink" onmouseover="javascript:...
11
by: casucci | last post by:
I do a return as XMLDataDocument in my webservice but it returns not with the namespaces etc in them. Anyone have and example where I can have the webservice return it as a XML. C# preferred....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.