Hi
I have created a video player skin Class, that implements an Interface IPlayerSkin, that will allow me to swap out video player skins at run-time. I have this situation where I can't access the contents of my skin class from another class and I can't figure out why, should be pretty straightforward process. Maybe another set of eyes will know know what I am missing here.
For now I am keeping it simple just trying to get a trace of the contents of my skin class from another class. When I run the code from the CleanSkin.fla it traces correctly and shows that the controls MovieClip in the Skin class contains 7 children. When I run the code from the other class Test.fla it throws an error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
Which means it can't see the controls MovieClip in the Skin class for some reason
I have attached is zip file with all the necessary files. And here is some code for the Skin class, the Interface class and the other class (Test.as)
CleanSkin.as
Code: package com.ui.skins{
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.text.TextField;
public class CleanSkin extends MovieClip implements IPlayerSkin {
public var controls:MovieClip;
//////////////////////////////////////////////////////////
//
// IPlayerSkin Properties
//
//////////////////////////////////////////////////////////
private var _loader_icon:Bitmap;
private var _hover_image:Bitmap;
private var _background:Bitmap;
private var _base:MovieClip;
private var _track:Bitmap;
private var _progress_Bar:Bitmap;
private var _seek_btn:Bitmap;
private var _playPause_Btn:Bitmap;
private var _stop_Btn:Bitmap;
private var _mute_btn:Bitmap;
private var _volume_slider:Bitmap;
private var _fullscreen_btn:Bitmap;
private var _playlist_btn:Bitmap;
private var _playhead_time_txt:TextField;
private var _duration_txt:TextField;
public function get loader_icon():Bitmap { return _loader_icon; }
public function set loader_icon(value:Bitmap):void { _loader_icon = value; }
public function get hover_image():Bitmap { return _hover_image; }
public function set hover_image(value:Bitmap):void { _hover_image = value; }
public function get background():Bitmap { return _background; }
public function set background(value:Bitmap):void { _background = value; }
public function get base():MovieClip { return _base; }
public function set base(value:MovieClip):void { _base = value; }
public function get track():Bitmap { return _track; }
public function set track(value:Bitmap):void { _track = value; }
public function get progress_Bar():Bitmap { return _progress_Bar; }
public function set progress_Bar(value:Bitmap):void { _progress_Bar = value; }
public function get seek_btn():Bitmap { return _seek_btn; }
public function set seek_btn(value:Bitmap):void { _seek_btn = value; }
public function get playPause_Btn():Bitmap { return _playPause_Btn; }
public function set playPause_Btn(value:Bitmap):void { _playPause_Btn = value; }
public function get stop_Btn():Bitmap { return _stop_Btn; }
public function set stop_Btn(value:Bitmap):void { _stop_Btn = value; }
public function get mute_btn():Bitmap { return _mute_btn; }
public function set mute_btn(value:Bitmap):void { _mute_btn = value; }
public function get volume_slider():Bitmap { return _volume_slider; }
public function set volume_slider(value:Bitmap):void { _volume_slider = value; }
public function get fullscreen_btn():Bitmap { return _fullscreen_btn; }
public function set fullscreen_btn(value:Bitmap):void { _fullscreen_btn = value; }
public function get playlist_btn():Bitmap { return _playlist_btn; }
public function set playlist_btn(value:Bitmap):void { _playlist_btn = value; }
public function get playhead_time_txt():TextField { return _playhead_time_txt; }
public function set playhead_time_txt(value:TextField):void { _playhead_time_txt = value; }
public function get duration_txt():TextField { return _duration_txt; }
public function set duration_txt(value:TextField):void { _duration_txt = value; }
public function CleanSkin() {
trace("This is the CleanSkin class");
trace("The controls MovieClip contains " + this.controls.numChildren + " children");
}
}
}
IPlayerSkin.as
Code: package com.ui.skins{
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.text.TextField;
public interface IPlayerSkin {
function set background(graphic:Bitmap):void
function get background():Bitmap
function set base(graphic:MovieClip):void
function get base():MovieClip
function set track(graphic:Bitmap):void
function get track():Bitmap
function set progress_Bar(graphic:Bitmap):void
function get progress_Bar():Bitmap
function set seek_btn(graphic:Bitmap):void
function get seek_btn():Bitmap
function set playPause_Btn(graphic:Bitmap):void
function get playPause_Btn():Bitmap
function set stop_Btn(graphic:Bitmap):void
function get stop_Btn():Bitmap
function set mute_btn(graphic:Bitmap):void
function get mute_btn():Bitmap
function set volume_slider(graphic:Bitmap):void
function get volume_slider():Bitmap
function set fullscreen_btn(graphic:Bitmap):void
function get fullscreen_btn():Bitmap
function set playlist_btn(graphic:Bitmap):void
function get playlist_btn():Bitmap
function set playhead_time_txt(graphic:TextField):void
function get playhead_time_txt():TextField
function set duration_txt(graphic:TextField):void
function get duration_txt():TextField
function set loader_icon(graphic:Bitmap):void
function get loader_icon():Bitmap
function set hover_image(graphic:Bitmap):void
function get hover_image():Bitmap
}
}Test.as
Code: package com {
import flash.display.MovieClip;
import com.ui.skins.*;
public class Test extends MovieClip {
private var _skin:CleanSkin;
public function Test() {
_skin = new CleanSkin();
trace("Skin has " + _skin.numChildren + " children.");
}
}
}
Attached Files PlayerSkin.zip (78.9 KB)
Can't access my class's content.
Sunday, May 13, 2012
[Action Script] Can't access my class's content. May,2012
Posted by Bimo Hery Prabowo at 4:22 PM
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment