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 | twitter

recently :::

diversions :::

45+ Amazing Insect Shots in Photography
Insects are one of the most fascinating creatures on earth. There are more than 800, 000 species of insects in the world.
Grayscale color | Stroep Blog
This is how I create a grayscale color in actionscript 3.
Google Flash API
This is great ... google has made this easy ... stay tuned to see what i am working on ...
25 Free Mac Apps That Will Boost Your Productivity
There are many applications that can help you work faster and efficiently. Though, not many applications come cheap.
you still want more »