Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > Community Boards > Just for Kicks Challenges

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-06-2008, 02:57 PM   #1
FormerSwinger
CurrentFlasher
 
FormerSwinger's Avatar
 
Join Date: May 2005
Location: Finland
Posts: 382
Default Inherit backround from html

Since the wmode transparent can cause a lot of issues on different browsers I'm starting a challence to create a generic way to "inherit" the background style definitions from the html.

The only way I can think of requires javascript similar to the next function from
http://www.quirksmode.org/dom/getstyles.html
Code:
<script language="javascript" type="text/javascript">
function getStyle(el,styleProp)
{
	var x = document.getElementById(el);
	if (x.currentStyle)
		var y = x.currentStyle[styleProp];
	else if (window.getComputedStyle)
		var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	return y;
}
</script>
THE RULES:
  • The solution needs to be generic (i.e. work on all browsers, and all flashfiles)
  • Generic javascript functions can be required. So the use of the function above is optional You can write your own.
THE GOALS
  • A snippet of code that can be pasted to any flash file
  • The background of the swf will inherit color from the html
  • The background of the swf will inherit bg image from the html
  • The background of the swf will inherit image position and tiling settings from the html

Here is my example that sort of works for bg color on Firefox (remember to include the js function into the header)
Code:
if(flash.external.ExternalInterface.available==true){
	var c=flash.external.ExternalInterface.call("getStyle","flash","background-color");
	if(c){
		var cs=c.substring(4,c.length-1).split(",");
		var cn="0x"+Number(cs[0]).toString(16)+Number(cs[1]).toString(16)+Number(cs[2]).toString(16);
		_root.moveTo(0,0);
		_root.beginFill(cn);
		_root.lineTo(0,Stage.width);
		_root.lineTo(Stage.height,Stage.width);
		_root.lineTo(Stage.height,0);
		_root.endFill();
	}	
}
ps. To those who are wondering why the hell would someone go through the trouble when you can just use the bgcolor attribute: The bg color only works for solid colors , If the bg color changes all flash emebds need to be edited.
__________________
Just that it hasn't been done before doesn't mean it's impossible.
FormerSwinger is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML in Flash MX Mystro ActionScript 1.0 (and below) 1 10-10-2005 04:17 PM
in Flash it runs SMOOTH but in HTML it's SLOW !? blaatorx ActionScript 1.0 (and below) 9 09-10-2005 08:11 PM
Loading movies between HTML frames anticonnor ActionScript 1.0 (and below) 1 08-30-2005 02:46 AM
loading new HTML documents.... tinonetic ActionScript 1.0 (and below) 4 10-30-2002 03:14 PM
Problem importing HTML formatted text eye5 Other Flash General Questions 14 09-16-2002 06:43 AM


All times are GMT. The time now is 04:11 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.