17 April 2007

Style links in Flash with CSS

A friend asked me if they could style html links in Flash. Prior to Flash 7 you couldn’t … i said sure … just google it ... you should be able to add styles to dynamic text area …

I was surprised and shocked when they came back to me 4 days later … saying that they tried … and started making buttons to achieve the rollover states … I then googled myself and saw that it was hard to find … and even though I have used Flash for ages … I have never done this …. but I found it and decided to post it … before Flash 7 it was not possible … and links had no rollover states…

example…

The link here are either html or links to asfunction …

da code…

//DO STYLES
var styles = new TextField.StyleSheet();
styles.load("style_flash.css");
styles.onLoad = function(ok) {
	if (ok) {
		dynbox.styleSheet = styles;
		
		//looks like you need to trigger 
		//a change for it to display
		dynbox.htmlText += ''; 
	}
};

how…

The secret is with TextField.styleSheet »

Now the example shows exactly how to do with HTML, but there is another way … inside a dynamic textfield you can select text and use the link tool to add URLS ... OR flash functions using asfunction:some_function_name … and voila … those too are styled !!

da source…

flash-style-with-css.zip

 

comment



note: you can only submit after you hit preview


nuff-respec is a weblog written by daniel bulli a senior web programmer in boston, ma.
more >

contact | resume | profile

recently :::

diversions :::

Using Flash And Staying Standards Compliant
Anyone who has ever worked with Flash on the web has likely come across the fact that embedding flash into a web page is usually no walk in the park...
A Design is Finished when...
This is probably the hardest part of designing for me.... 23 Pro designers weigh in with their opinions ...
JungleCrazy.com
Find all the Amazon.com products that are discounted by at least 70%
IETester
IETester is a free WebBrowser that allows you to have the rendering and javascript engines of IE8 beta 1, IE7 IE 6 and IE5.5 on Vista and XP, as well as the installed IE in the same process.
you still want more »