Well, I finally had a little bit of free time and I wanted to rework all my wordpress and flash integrations stuff into ActionScript 3. There were a couple of interesting things that came up while working on this as well. You can’t tween the alpha property of a textfield created in actionscript (unless you use a simple hack that I found out in the Flash live-docs online). You have to change the blendmode style to “LAYER”, or another type, as long as its not the default style type. Weird but at least I got it to work. Also, I was going to implement the tweens using TweenLite but they also have problems accessing textfield properities, too.
Here is the swf, and below is the actionscript 3:
package { import flash.display.MovieClip; import flash.display.BlendMode; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; import flash.text.*; import fl.transitions.Tween; import fl.transitions.TweenEvent; import fl.transitions.easing.*; /* * Redo of scott rockers's wordpress to flash integration but in AS3 and as3wordpressFlash class file */ public class AS3WordpressFlash extends MovieClip { public var i:uint = 0; public var titleList:XMLList; public var linkList:XMLList; public var tf:TextField; public var format:TextFormat; public var tweenIt:Tween; public var tweenIt2:Tween; public var theXML:XML; public var loader:URLLoader = new URLLoader(); public function AS3WordpressFlash() { loader.addEventListener(Event.COMPLETE, loadXML); loader.load(new URLRequest("http://www.scottrockers.com/blog/wp-rss2.php")); } function loadXML(e:Event):void { theXML = new XML(e.target.data); titleList = theXML.channel.item.title; linkList = theXML.channel.item.link; createTextFields(titleList, linkList); } function createTextFields(titles:XMLList, links:XMLList):void { format = new TextFormat(); format.font = "Arial"; format.color = 0xFFFFFF; format.size = 14; for (i = 0; i < 5; i++) { tf = new TextField(); tf.blendMode = BlendMode.LAYER; tf.width = 10; tf.selectable = false; tf.autoSize = TextFieldAutoSize.CENTER; tf.x = (stage.width)/2; tf.y = -20; tf.htmlText = "<a href=""+ links[i] +"" target="_blank">" + titles[i] + "</a>"; tf.setTextFormat(format); addChild(tf); tweenIt = new Tween(tf, "y", Elastic.easeOut, -20, 50 + (i * 30), 30 + (i * 15), false); tweenIt2 = new Tween(tf, "alpha", Strong.easeOut, 0, 1, 100 + (i * 100), false); } } } }
Tags: Actionscript 3, Design, Development, Flash, Wordpress












