еще раз меня мучает страшная ошибка Flash: Не удается получить доступ к свойству или методу .
Я создаю новый видеоплеер, и мне нужно отправить полную ширину моего индикатора выполнения (созданного в PlayerControls.as) в мой класс VideoPlayer.as. А также контролировать ширину индикатора выполнения из функции обновления внутри моего класса VideoPlayer.as.
Я не могу получить эти значения в своем классе VideoPlayer, мне интересно, имеет ли это какое-либо отношение к порядку, в котором я вызываю эти классы в моем классе Document:
Класс документа
package {
// IMPORTS
public class TEN extends Global {
//private consts
//private vars
public function TEN():void {
if (stage) {
init();
} else {
addEventListener(Event.ADDED_TO_STAGE,init);
}
}
private function init(e:Event=null):void {
removeEventListener(Event.ADDED_TO_STAGE,init);
// Using the BulkLoader class to phrase XML
}
private function onBulkLoadComplete(e:Event):void {
trace("[BulkLoader] COMPLETE"+"\r");
Global.xml=loader.getXML("xmldata");
// I get XML values
// XML info goes into ARRAYS here
drawBackground();
drawVideo();
drawControls();
}
// Background.as
private function drawBackground():void {
trace("\r"+" drawBackground();");
trace("------------------------------");
bg=new Background ;
bg.drawBackground(globalWidth,globalHeight,firstTitle);
stage.addChild(bg);
}
// VideoDisplay.as
private function drawVideo():void {
trace("\r"+" drawVideo();");
trace("------------------------------");
vd=new VideoDisplay ;
vd.drawVideo(globalWidth,globalHeight,videoName,videoHDiff,limeLight);
vd.x=videoX;
vd.y=videoY;
stage.addChild(vd);
}
// PlayerControls.as
private function drawControls():void {
trace("\r"+" drawControls();");
trace("------------------------------");
pc=new PlayerControls ;
pc.drawControls(globalWidth,globalHeight,HEX,specialCheck,specialText,specialUrl);
pc.x=videoX;
pc.y=controlsY;
pc.addEventListener("onPlay",vd.playVideo);
pc.addEventListener("onPause",vd.pauseVideo);
stage.addChild(pc);
}
private function onBulkLoadProgress(e:BulkProgressEvent):void {
//trace(e.weightPercent);
}
}
}
PlayerControls.as
package src.ui
{
// IMPORTS
public class PlayerControls extends MovieClip
{
// private consts
// private vars
public var progressBar:MovieClip;
public var progressTotalW;
public function PlayerControls():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void {
removeEventListener(Event.ADDED_TO_STAGE, init);
}
public function drawControls(w, h, color, specialCheck, extraTxt, extraLink):void
{
// SET VALUES w,h,color, etc...
vd = new VideoDisplay(); // <-- VideoDisplay Class
// I create graphics
// I add graphics
createSpecialBtn(); // Create special button
}
// Create Special Button ·······································
public function createSpecialBtn():void
{
// other code
fullscreenCreate(btn_SpecialW); // Create FullScreen Button
}
// Create Fullscreen Button ·····································
public function fullscreenCreate(extraW):void
{
// other code
createSoundBtn(btn_Fullx); // Create Sound Button
}
// Create Sound Button ·····································
public function createSoundBtn(xSpacer):void
{
// other code
createTimeCounter(timeCountX); // Create Time Clock
}
// Create Time Count ·····································
public function createTimeCounter(spaceX):void
{
// other code
createGroove(); // Create progress bar background
}
// Create Groove Bar ············································
public function createGroove():void
{
// Here we go!
groove = new Groove();
groove.width = grooveW;
groove.x = grooveX;
groove.y = grooveY;
progressTotalW = grooveW;
//trace("grooveW = "+grooveW);
//trace("progressTotalW = "+progressTotalW);
vd.setProgressW(progressTotalW);
createProgress();
}
// Create Progress Bar ··········································
public function createProgress():void
{
progressBar = new ProgBar;
TweenLite.to(progressBar, .1, {tint:xmlColor});
progressBar.x = grooveX;
progressBar.y = grooveY;
progressBar.width = 1;
//trace("progressBar.x = "+progressBar.x);
//trace("progressBar.y = "+progressBar.y);
controls.addChild(groove);
controls.addChild(progressBar);
}
// BUTTON EVENTS here
}
}
VideoDisplay.as
package src.display
{
// IMPORTS
public class VideoDisplay extends PlayerControls
{
// Variables...
private var pc:PlayerControls;
public function VideoDisplay():void
{
this.addEventListener(Event.ADDED_TO_STAGE, stageListens);
}
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ NetStream Check
private function netStatusHandler(event:NetStatusEvent):void {
switch (event.info.code) {
//case "NetConnection.Connect.Success": ... etc
}
}
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Error Handling
private function asyncErrorHandler(event:AsyncErrorEvent):void {trace(event.text);}
private function onBWDone(...args):void {}
private function onXMPData(infoObject:Object):void {}
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ Declare MetaData
function getMetaData(client_ns) {
// Meta data
}
// ☼ --------------------------------------------------------------------------------- Connect to Stream
public function connectStream():void
{
// NetStream code
}
public function drawVideo(w, h, flvUrl, minusHeight, LL):void
{
sizeW = w;
sizeH = h;
flvSource = flvUrl;
appName = LL;
pc = new PlayerControls(); // <- PlayerControls.as
// RTMP - ns - nc CODE
// draw graphics
// Timer
tmrDisplay = new Timer(DISPLAY_DELAY);
tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay); // <--
// addChilds
}
public function playVideo(e:CustomEvent = null):void
{
// play function
}
public function pauseVideo(e:CustomEvent = null):void
{
// pause function
}
// Getter & Setter
public function setProgressW(setMe):void
{
progressTotalW = setMe;
ajoyTest = setMe;
trace("Getter & Setter - progressTotalW = "+progressTotalW);
/*tmrDisplay = new Timer(DISPLAY_DELAY);
tmrDisplay.addEventListener(TimerEvent.TIMER, updateDisplay);*/
}
private function updateDisplay(e:TimerEvent):void
{
//trace("ns.time * 287 / videoDuration = "+(ns.time * 287 / videoDuration));
//pc.progressBar.width = ns.time * pc.progressTotalW / videoDuration;
//trace("ns.time = "+ns.time);
//trace("videoDuration = "+videoDuration);
trace("ajoyTest = "+ajoyTest);
trace("progressTotalW = "+progressTotalW);
}
// Other functions
}
}
^ по какой-то причине я не могу настроить таргетинг на progressBar.width внутри PlayerControls.as