PDA

View Full Version : Accessing variable from package problem OO newbie


EndlessLine
04-08-2008, 05:52 PM
So i'm getting my feet wet with OOP and I've run into bit of a problem. I'm trying to access an instance of a panel that I've created via AS to add a child to (with a video display object). I don't think i'm making my instance available at the right spot or maybe something else, without much further ado...the code...

Error 1120:Access of undefined property mainPnl (in MXML)

MXML instantiating the panel and canvas properties

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" name="rootCV" initialize="init()">
<mx:Style source="videoPlayerStyle.css" />
<mx:Script>
<![CDATA[
import actions.layout.setCanvas;
import actions.vidPlayer.videoFile;

public function init():void
{
var layoutCanvas:setCanvas = new setCanvas;
var vFile:videoFile = new videoFile;
layoutCanvas.createLayout(mainCV,800,900);
vFile.createVD("http://www.urltown.com.city.flv","Econ1",mainPnl);
}

]]>
</mx:Script>
<mx:Canvas id="mainCV" horizontalCenter="0">
</mx:Canvas>
</mx:Application>

My video player class

// Contains Video connection and information
package actions.vidPlayer
{
import fl.video.*;
import actions.layout.setCanvas;
import mx.containers.Panel;
import mx.controls.VideoDisplay;

public class videoFile
{
public function createVD(videoLocation:String,videoID:String,paren tal:Panel):void
{
var lectureVid:VideoDisplay = new VideoDisplay;
var path:String = videoLocation;
var lwidth:Number = lectureVid.width;
var lheight:Number = lectureVid.height;
var cTime:Number = lectureVid.playheadTime;
var lvolume:Number = lectureVid.volume;
var lname:String = new String();
var author:String = new String();
lectureVid.source = path;
lwidth = 400;
lheight = 400;
lvolume = 50;
lname = "This is a test Name";
author = "Theotus Beasley Kleinfeld III";
parental.addChild(lectureVid);
}
public function getCues(video:VideoDisplay):void{
//TODO Get Cues
}
}
}

My Layout creation class
// ActionScript file
package actions.layout
{
import mx.containers.Canvas;
import mx.containers.Panel;
import mx.controls.Alert;
import mx.core.LayoutContainer;

public class setCanvas extends Canvas
{
public var mainPnl:Panel = new Panel;

public function createLayout(par:Canvas,cWidth:Number,cHeight:Numb er):void{
mainPnl.width = cWidth;
mainPnl.height = cHeight;
mainPnl.title = "Knowledge PowerHouse";
mainPnl.layout = "absolute";
mainPnl.id = "mainPl";
par.addChild(mainPnl);
if(mainPnl.parent == null){
Alert.show("The Canvas does not have a parent");
}
}
}
}

Any and all help would be much appreciated. Thanks for your time

dr_zeus
04-08-2008, 05:58 PM
vFile.createVD("http://www.urltown.com.city.flv","Econ1",layoutCanvas.mainPnl);

EndlessLine
04-08-2008, 06:03 PM
Bah! ankle breaker. Thanks zeus...again.