Miniblog Part 2
Listing 1. BlogItem component MXML for design elements
Listing 2. ActionScript for the BlogItem component
80) {
Listing 4. Class importing and variable setup
import mx.containers.VBox; private var container:VBox; private var posts:Array; private var phpFile:String = "http://localhost/lab/miniblog_web/ blog.php"; Listing 5. Custom event definition, called when the user clicks on the LinkButton in the custom component
desc.text = txt.substring(0, 80)
+ "...";
return ;
}
desc.text = txt;
[Event(name="readFullPost", type="mx.events.MouseEvent")] Listing 6. Initialization method, called when the application is loaded
} private function continueHandler():void { trace("continueHandler()");
private function init():void {
dispatchEvent( new MouseEvent("readFullPost "));
container = new VBox(); container.x = 10; container.y = 50;
}
]]>
addEventListener("readFullPost", fullPostHandler); addChild(container);
Listing 3. Main blog view code
loadPostData();
} Listing 7. Method to setup the XML loading process
private function loadPostData():void {
var urlLoader:URLLoader = new URLLoader(); urlLoader.addEventListener(Event.COMPLETE, postDataLoaded); urlLoader.load( new URLRequest(phpFile));
} // ActionScript code goes here ]]> 03/2009 (5) 65
Made with FlippingBook HTML5