source: trunk/fl5/src/com/longtailvideo/jwplayer/view/SkinBase.as @ 311

Revision 311, 1.9 KB checked in by pablo, 4 years ago (diff)

Skin loading

Line 
1package com.longtailvideo.jwplayer.view
2{
3        import flash.display.DisplayObject;
4        import flash.display.DisplayObjectContainer;
5        import flash.display.Sprite;
6        import flash.events.ErrorEvent;
7        import flash.events.Event;
8        import flash.events.EventDispatcher;
9
10        /**
11         * Send when the skin is ready
12         *
13         * @eventType flash.events.Event.COMPLETE
14         */
15        [Event(name="complete", type = "flash.events.Event")]
16
17        /**
18         * Send when an error occurred loading the skin
19         *
20         * @eventType flash.events.ErrorEvent.ERROR
21         */
22        [Event(name="error", type = "flash.events.ErrorEvent")]
23
24
25        public class SkinBase extends EventDispatcher implements ISkin
26        {
27                protected var _skin:Sprite;
28
29                public function load(url:String=null):void
30                {
31                        dispatchEvent(new Event(Event.COMPLETE));
32                }
33               
34                public function hasComponent(component:String):Boolean
35                {
36                        return _skin.getChildByName(component) is DisplayObjectContainer;
37                }
38               
39                public function getSkinElement(component:String, element:String):DisplayObject
40                {
41                        var comp:DisplayObjectContainer = _skin.getChildByName(component) as DisplayObjectContainer;
42                        return comp.getChildByName(element);
43                }
44               
45                public function addSkinElement(component:String, element:DisplayObject, name:String=null):void
46                {
47                        if (name) element.name = name;
48                                               
49                        var comp:DisplayObjectContainer =  _skin.getChildByName(component) as DisplayObjectContainer;
50                                               
51                        if (!comp) {
52                                comp = new Sprite();
53                                comp.name = component;
54                                _skin.addChild(comp);
55                        }
56                                               
57                        if(comp.getChildByName(element.name)) {
58                                delete comp[element.name];
59                                comp.removeChild(comp.getChildByName(element.name));
60                        }
61                        comp.addChild(element);
62                        comp[element.name] = element;
63                }
64               
65                public function getSkinProperties():SkinProperties
66                {
67                        return new SkinProperties();
68                }
69               
70                protected function sendError(message:String):void {
71                        dispatchEvent(new ErrorEvent(ErrorEvent.ERROR, false, false, message));
72                }
73
74
75               
76        }
77}
Note: See TracBrowser for help on using the repository browser.