Copy link to clipboard
Copied
I have some issue which I cannot solve in AS3.
I have a simple application with a myApp.as and a myApp.mxml, now I moved all my function to a class called App.as I get errors on types I miss.
myApp.as:
public function init():void {
myApp = new App();
}
classes/App.as
package classes
{
..
..
[Bindable] public class App
{
..
public function cam {
...
myWebcam.attachCamera(camera);
..
}
}
}
myApp.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:ns1="components.*"
xmlns:ns2="*"
xmlns:gauge="components.gauge.*"
width="800" height="600" applicationComplete="init()" backgroundColor="#FFFFFF"
layout="absolute">
<mx:Script source="myApp.as" />
<mx:VideoDisplay id="myWebcam" x="800" top="0" width="800" height="600" borderColor="#FFFFFF"
borderStyle="none" >
</mx:VideoDisplay>
</mx:Application>
This is kinda rough what I do at the moment where I get an error on:
myWebcam.attachCamera(camera);
TypeError: Error #1009: Cannot access a property or method of a null object reference.
When I had all my functions in myApp.as I never got this issue and I got my Camera in myWebcam. I get the feeling that my whole myApp.mxml is not loaded now I moved to a class ?
I have tried with parent(s) that might be around myWebcam but this doesn't seem to be the problem or at least not fix it.
My class complains about myWebcam not having a propery set, but when I make it a public variable like:
public var myWebcam:VideoDisplay;
The error goes away, but it's still a that null reference error.
What can cause this move from myApp.as to my class generating this "error" ?
I placed a trace in my mxml before my <mx:VideoDisplay id="myWebcam"... and it seems to be loaded up front of the script
Copy link to clipboard
Copied
Small update here:
myWebcam seems to be undefined before I do myWebcam.attachCamera(camera);
How should I define it so make that not happen?
Copy link to clipboard
Copied
Some other update:
Defining my var:
public var myWebcam:VideoDisplay = new VideoDisplay();
Helps me getting around my 1009 error, the issue is that I get a black screen in my mxml and it seems the VideoDisplay is overwritten or so?
Any help on this would be great!
Copy link to clipboard
Copied
New Update:
On my NON-class variant, myWebcam is set as VideoDisplay with Videoplayer as child when I set a breakpoint on this.
On my class-variant I get that the Videoplayer is null instead of set.
How hard can it be ?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now