| 1 | /** |
|---|
| 2 | * This plugin demonstrates of the new ViewEvent.BUTTON event. |
|---|
| 3 | **/ |
|---|
| 4 | package com.jeroenwijering.plugins { |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | import com.jeroenwijering.events.*; |
|---|
| 8 | |
|---|
| 9 | import flash.display.Sprite; |
|---|
| 10 | import flash.events.MouseEvent; |
|---|
| 11 | |
|---|
| 12 | public class CustomButton extends Sprite implements PluginInterface { |
|---|
| 13 | |
|---|
| 14 | /** Reference to the View of the player. **/ |
|---|
| 15 | private var view:AbstractView; |
|---|
| 16 | /** initialize call for backward compatibility. **/ |
|---|
| 17 | public var initialize:Function = initializePlugin; |
|---|
| 18 | /** URL for button. **/ |
|---|
| 19 | private var button_url:String; |
|---|
| 20 | /** Plugin config. **/ |
|---|
| 21 | private var config:Object; |
|---|
| 22 | |
|---|
| 23 | /** Constructor; nothing going on. **/ |
|---|
| 24 | public function CustomButton() {}; |
|---|
| 25 | |
|---|
| 26 | /** The initialize call is invoked by the player View. **/ |
|---|
| 27 | public function initializePlugin(vie:AbstractView):void { |
|---|
| 28 | view = vie; |
|---|
| 29 | |
|---|
| 30 | config = view.getPluginConfig(this); |
|---|
| 31 | button_url = config['icon']; |
|---|
| 32 | |
|---|
| 33 | /** Load from URL **/ |
|---|
| 34 | view.sendEvent(ViewEvent.BUTTON, {icon:button_url,clickhandler:buttonClick,buttonname:'test'}); |
|---|
| 35 | |
|---|
| 36 | /** Create a movie clip as the icon **/ |
|---|
| 37 | var mc:Sprite = new Sprite(); |
|---|
| 38 | mc.name = 'icon'; |
|---|
| 39 | mc.graphics.beginFill(0x000000); |
|---|
| 40 | mc.graphics.lineTo(9, 4.5); |
|---|
| 41 | mc.graphics.lineTo(0, 9); |
|---|
| 42 | mc.graphics.lineTo(0, 0); |
|---|
| 43 | |
|---|
| 44 | view.sendEvent(ViewEvent.BUTTON, {icon:mc,clickhandler:buttonClick,buttonname:'test2'}); |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | protected function buttonClick(evt:MouseEvent=undefined):void { |
|---|
| 48 | view.sendEvent(ViewEvent.PLAY); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | } |
|---|