Posts Tagged ‘css’
Overview
Earlier I wrote a tutorial article about asfunction in as2. Now that I’ m into as3, surprise surprise asfunction has been depreciated and now to replace it is the LINK TextEvent. Dispatched when a user clicks a hyperlink in an HTML-enabled text field, where the URL begins with “event:”. The remainder of the URL after “event:” will be placed in the text property of the LINK event.
This differs from the asfunction method in that we must add an event listener (addEventListener) to the textField object, the event listener specifies which function will be called in the event of a link click and there is no way to send arguments along with the event (AFAIK). But it’s easy enought to use one link event function for all your link events and put in a simple switch statement to coordinate the desired results…
Steps
- Use event in the href attribute. (href=”event:eventText”)
- Listen to the textField (theTextField.addEventListener(TextEvent.LINK, linkHandler);)
- Handle the link event (function linkHandler(linkEvent:TextEvent):void {…)
Example
Actionscript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 | var myHTMLText:String = "Sample text in an html enabled text box.\n"+ "Here's a normal link to <a href='http://bloc.circlecube.com'>circlecube</a> putting the link into the href attribute like normal!\n"+ "<a href='event:clickLink'>Click this circlecube</a>, to see the text event link in action! \n"+ "And some more links that don't go anywhere, but they do call functions in actionscript. "+ "Click this to move <a href='event:moveUp'>UP</a>, click me move back "+ "<a href='event:moveDown'>DOWN</a>.\n"+ "Also, one last example <a href='event:testing'>click for a trace test</a>"; //create and initialize css var myCSS:StyleSheet = new StyleSheet(); myCSS.setStyle("a:link", {color:'#0000CC',textDecoration:'none'}); myCSS.setStyle("a:hover", {color:'#0000FF',textDecoration:'underline'}); myHTML.styleSheet = myCSS; myHTML.htmlText = myHTMLText; myHTML.addEventListener(TextEvent.LINK, linkHandler); function linkHandler(linkEvent:TextEvent):void { switch (linkEvent.text) { case "clickLink": clickLink(); break; case "moveUp": moveUp(); break; case "moveDown": moveDown(); break; default: giveFeedback(linkEvent.text); } } //function to be called from html text function clickLink():void { giveFeedback("Hyperlink clicked!"); var myURL:String = "http://blog.circlecube.com"; var myRequest:URLRequest = new URLRequest(myURL); try { navigateToURL(myRequest); } catch (e:Error) { // handle error here giveFeedback(e); } } //another function to be called from html text, recieves one argument function moveUp():void { feedback.y -= 10; giveFeedback("Up"); } //a simple trick to allow passing of multiple arguments function moveDown():void { feedback.y += 10; giveFeedback("Down"); } function giveFeedback(str):void { trace(str); feedback.appendText(str +"\n"); feedback.scrollV = feedback.maxScrollV; } |
Source
Download the fla here: textlinkevent_as3.fla
asfunction (TextEvent.LINK) Tutorial for AS3 | Flash HTML Link to call actionscript function | Tutorial
Author: Evan Mullins | Filed under: tutorialStomperNet has been a ‘buzz’.
After Andy’s ‘Mea Culpa‘ why wouldn’t it be…
But this is so much better and bigger, learning many lessons from the last launch – StomperNet strikes again!
Teamed up with Paul Lemberg a new product called FormulaFIVE (F5 for short).
Just launched a video to excite the industry!
So check out stomperf5.com now!
StomperNet Strikes Again! with FormulaFIVE
Author: Evan Mullins | Filed under: portfolio, workThanks for your patience as I’ve been tinkering with the theme, layout and css of circlecube.com.
I started with a free theme from Justin Tadlock, Options Theme, available at theme hybrid. I’ve changed that theme quite a bit, from restyling it to fixing bugs I found and updated many other things on the site as well. So the reason I’m going on about it is I think I’m finished… and I’m asking you to let me know if you see anything that looks odd or fishy, or even just want to make a suggestion or comment on how much you like/hate the redesign. Comment on this post or contact me!
And as always, if there’s something you would like me to write about or have questions you can also contact me. I’ve even set up a poll in the sidebar showing post ideas I have which you can vote on and encourage me to write the one(s) you want most first! So let me know what you want, it encourages me to write more as well. And be sure to subscribe to the circlecube rss feed so you won’t miss anything that’s coming up!
Sally, a great photographer in the Augusta, GA area wanted help putting up a website that was easy to maintain and looked professional. I helped her out and set her up with a wordpress install, some essential plugins and a few themes! She is ecstatic!
Check out the site here: http://sallykolar.com/ and book her if you’re in the area and want great photography!

























