473,748 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resize div height from rollover event in Flash

9 New Member
I am asking this in javascript and not actionscript because I think the js portion more crucial. I have a viewable area in a SWFcalled box_mc on frame1 that is 300x100 until a rollOver event when it appears to become 300x274 because it has advanced to frame2

I want my actionscript to instruct a div that is 300x100pixels with overflow hidden to expand to a div that is 300x274 in response to the rollOver event. On rollOut I want my div to snap back to the original height.

I think I may have seen what I need on http://www.adobe.com/products/photoshop/family/

which has a script called expando

Expand|Select|Wrap|Line Numbers
  1. function setSWFDimensions(objID, width, height) {
  2.         //alert(objID+' '+width+' '+height);
  3.         if (objID && width && height) {
  4.             var fObj = document.getElementById(objID);
  5.             var fEmb = document.getElementById(objID+'-embed');
  6.             if (fObj && fObj.style) {
  7.                 fObj.setAttribute('width', width);
  8.                 fObj.setAttribute('height', height);
  9.                 fObj.style.width = width+'px';
  10.                 fObj.style.height = height+'px';
  11.             }
  12.             if (fEmb != null) {
  13.                 fEmb.width = width;
  14.                 fEmb.height = height;
  15.                 if (fEmb.style) {
  16.                     fEmb.style.width = width+'px';
  17.                     fEmb.style.height = height+'px';
  18.                 }
  19.             }
  20.         }
  21.     }
  22.  
This is my AS for the rollover rolloff events

Expand|Select|Wrap|Line Numbers
  1. box_mc.onPress = function():Void
  2. {
  3.  getURL("javascript:pageTracker._trackPageview('/flash/click/');");
  4.  getURL("http://www.yahoo.com","_blank");
  5. };
  6.  
  7.  
  8. box_mc.onRollOver = function():Void
  9. {
  10.  getURL("javascript:pageTracker._trackPageview('/flash/rollover/');");
  11.  
  12.     box_mc.gotoAndPlay(2); 
  13. };
  14.  
  15. box_mc.onRollOut = function():Void
  16. {
  17. box_mc.gotoAndStop(1);
  18. };
  19.  
  20.  
  21.  
Feb 16 '08 #1
4 5415
acoder
16,027 Recognized Expert Moderator MVP
Have you tried calling the JavaScript function onrollover?
Feb 16 '08 #2
somnamblst
9 New Member
I have mostly been looking at the example on mustardlab.com/developer/flash/objectresize/ and the resize_flash.js files and FLA example. So based on what you said I think my AS should be:
Expand|Select|Wrap|Line Numbers
  1. box_mc.onRelease = function():Void
  2. {
  3.  getURL("http://www.yahoo.com","_blank");
  4. };
  5. box_mc.onRollOver = function():Void
  6. {
  7. box_mc.gotoAndPlay(2); 
  8. getURL("javascript:setFlashHeight('flashid', 274)");
  9. };
  10. box_mc.onRollOut = function():Void
  11. {
  12. box_mc.gotoAndStop(1);
  13. getURL("javascript:setFlashHeight('flashid', 100)");
  14. };
According to Mustardlab's flash resize demo I need this on my page to check whether the users browser supports the getElementById function:
Expand|Select|Wrap|Line Numbers
  1. <div id="flashid" style="width:100%; height:100%;">
  2.     <script type="text/javascript">
  3.       e = canResizeFlash();
  4.       document.write('<object data="flashResize_300x100.swf" width="100%" height="100%" type="application/x-shockwave-flash">');
  5.       document.write('  <param name="movie" value="flashResize_300x100.swf" />');
  6.       document.write('  <param name="FlashVars" value="allowResize='+e+'" />');
  7.       document.write('  Flash Movie With Resizing Content');
  8.       document.write('</object>');
  9.     </script>
  10.     <noscript>Javascript must be enabled to view Flash movie</noscript>
  11.   </div>
But I also want my resizing div to hide the overflow of the bottom 174 pixels when box_mc is on frame1, because otherwise won't my 300x274 pixel SWF push my div down? It will be z-indexed and wmode=transpare nt and there is HTML content under the bottom 174 pixels that users need to be able to click on that the flash box_mc is preventing clicks on HREF links in FF & Safari but not IE7.

Here is my demo link with a link to my FLA & flash_resize.js

http://xsotek.com/demo6/resize2.html
Feb 16 '08 #3
somnamblst
9 New Member
I did it! Somehow. Wish I could say I understand what I did, but I just kept trying different things. If you rollover the HREF links in FF you get a cursor now and if you rollover in IE you see the "Press spacebar or enter to activate this control" halo is 100px.

demo

Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript" src="http://xsotek.com/demo6/flash_resize.js"></script>
  2. <script type="text/javascript">
  3. function setFlashHeight(divid, newH) {
  4. document.getElementById(divid).style.height = newH+"px";
  5. }
  6. </script>
  7.  
  8. <div id="flashid" style="overflow:hidden; height:100px; width:300px; position:absolute; z-index:100; background: Aqua;">
  9. <script type="text/javascript" language="JavaScript">
  10. e = canResizeFlash();
  11. document.write('<object data="flashResize4_300x100.swf" width="300" height="274" type="application/x-shockwave-flash">');
  12. document.write('<param name="movie" value="flashResize4_300x100.swf" />');
  13. document.write('<param name="FlashVars" value="allowResize='+e+'" />');
  14. document.write('Flash Movie With Resizing Content');
  15. document.write('<param name="wmode" value="transparent" />');
  16. document.write('</object>');
  17.         </script>
  18.         <noscript>Javascript must be enabled to view Flash movie</noscript>
  19.     </div>
  20.  
And my AS is

Expand|Select|Wrap|Line Numbers
  1. box_mc.onRelease = function():Void
  2. {
  3.  getURL("http://www.yahoo.com","_blank");
  4. };
  5. box_mc.onRollOver = function():Void
  6. {
  7. box_mc.gotoAndPlay(2); 
  8. getURL("javascript:setFlashHeight('flashid', 274)");
  9. };
  10. box_mc.onRollOut = function():Void
  11. {
  12. box_mc.gotoAndStop(1);
  13. getURL("javascript:setFlashHeight('flashid', 100)");
  14. };
  15.  
Feb 17 '08 #4
acoder
16,027 Recognized Expert Moderator MVP
That seems to be the way it should be done. There are ways to get rid of that message in IE. Perhaps you can ask in the Flash forum for that. Anyway, well done!
Feb 18 '08 #5

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

Similar topics

6
3703
by: JezB | last post by:
I need to code my own resize event, and Im not sure how. I have a DIV whose width I always want to be the browser height (the inner pane, excluding the toolbars, status bar etc) - 200 points (say). I can't use a height % for this, so as I understand it I need to code my own onresize event. Trouble is, I know almost nothing about javascript, so I dont know how to get the browser window height or set the DIV height. The solution should...
0
1569
by: Chubby Arse | last post by:
Hi all, I have a control, that basically is my own version of the datagrid, except that is renderers purely readonly tabular information. When the control is rendered to the designer, I can click on the control as rendered and move it, however I cannot resize it. I can change the height and Width properties in the PropertyGrid and they change, but the control doesn't resize.
1
2064
by: Mike P | last post by:
what is the syntax for adding a rollover button as an image button? I have saved the button as a .swf file and put it as the ImageUrl, but since it isn't an image, do I need to save it as an image in flash rather than a button? Cheers, Mike
6
5202
by: Rob | last post by:
I need to create a form that will resize only the verticle size of the Form and not the width. So far I'm partial to the following code. Can someone please elaborate the ??? . . . . Const WM_SIZE = &H5 Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Call MyBase.WndProc(m)
18
21597
by: gconrads | last post by:
OK, today is my twofer special on js questions. BTW: the method used here is working in Firefox I'm working on a script that switches the width of a Flash movie between 100% and 812 pixels depending on the innerwidth of the browser window. The point is when a flash movie is embedded for fullscreen usage (100%) it acts somewhat like a background, and won't cause scrollbars if the window is scaled to a smaller size than the 'actual' content...
1
2038
by: | last post by:
I'm creating a user control where the size always needs to be divisible by three. In the resize event within the custom control I'm having no problem maintaining the height to be the same as the width, but as soon as I try to add some code to make sure that the width is always divisible by three, VS crashes. How can I force the width 9and height) to always be a factor of three? Thanks. J
1
2214
by: Starance | last post by:
Well... I'm not sure if this can be fixed, I've tried many ways. But here goes; When you resize your browser window it seems to move my video & photo divs. I want them kept in line with the main div. please help. Yes, its for myspace profile. <div class="main"> <table style="width="800px"; height="1024px"; cellpadding="0"; cellspacing="0";background-color="1c1c1c";"> <tr><td valign="top"> <tr> <td colspan="10">
3
2081
by: Jills | last post by:
Hi All, Does anyone have any idea about how can we resize an IFRAME dynamically according to its content from another domain? I want to increase the height according to the page that is displayed on it. Regards, Jills
7
2598
by: Anz | last post by:
Can any one know the javascript function to auto resize the swf when resizing its pop up window. I need to auto resize the swf when i resize my popup window in which the swf is displayed. Is there any javascript function available to perform this requirement ?
0
8995
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8832
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9558
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9331
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9253
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6798
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6077
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4879
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.