/ Published in: ActionScript 3

This is based on the example from http://blog.onebyonedesign.com/?p=60.
You need to create a thumbnail in the library with Box as the linkage ID
Expand |
Embed | Plain Text
//Custom Class file code package { import flash.display.Sprite; public class CustomObject extends Sprite { private var _link:String; public function CustomObject(link:String):void { _link = link; var box:Box = new Box() // Box is the linkage id name from the box movieclip in the library addChild(box) } public function get link():String { return _link; } public function set link(value:String):void { _link = value; } } } //------------------------------------------------------------------------------------------------- //Document Class file package { import flash.display.*; import flash.events.*; import flash.net.*; public class CustomObjectTest extends Sprite { public function CustomObjectTest():void { var links:Array = new Array("link1.html","link2.html","link3.html","link4.html") for (var n:Number=0; n<4; n++){ var co:CustomObject = new CustomObject(links[n]); co.addEventListener(MouseEvent.CLICK, onClick); addChild(co); co.y = 100*n; } } private function onClick(me:MouseEvent):void { var siteLink:URLRequest = new URLRequest( me.currentTarget.link ); navigateToURL( siteLink ); } } }
You need to login to post a comment.