all groups > flash actionscript > november 2006 >
You're in the

flash actionscript

group:

Video object _width property


Video object _width property Manno Bult
11/12/2006 4:19:53 PM
flash actionscript:

Hi all,

I have a class which has a private property 'screen' containing a
reference to a Video object like:

private var screen:Video;

A few lines below there's a public method returning the width of the
video object:

public function getWidth():Number{
return this.screen._width;
}

Now, when I compile I get the following error:

**Error**
D:\aloft\FlashLibrary\current\nl\aloft\media\phpflv\ScreenView.as: Line
35: There is no property with the name '_width'.
return this.screen._width;

However, when i run the code and call the method I get the width of the
object without any problems.

If I have the method return any of the properties without the underscore
(like: width, smoothing, deblocking etc.) I get no compile error.

What am I missing here?

Thanks in advance,
Manno

--
----------
Manno Bult
Re: Video object _width property myIP
11/12/2006 6:28:55 PM
The ?_width? property is used to assign the video a value or transform the
video to whatever value. The ?width? property is a read-only property. It
will simply just return the current width of the video. Look at the example in
the link below;


http://livedocs.macromedia.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.ht
m?context=LiveDocs_Parts&file=00002848.html

Re: Video object _width property Manno Bult
11/12/2006 10:14:27 PM


[quoted text, click to view]

I know the distinction between the two, I was only wondering why it
gives compiletime errors when referring to the "_width" property (whith
preceding underscore) and not when referring to the "width" property.
Though representing different properties, they are both _valid_ properties.

The error makes no sense to me really since the _width property does
exist while it claims it does not...

Manno



--
----------
Manno Bult
Re: Video object _width property myIP
11/15/2006 1:15:48 AM
Re: Video object _width property Manno Bult
11/15/2006 10:23:10 PM
Hi myIP
thanks for the heads up,

I've found an ugly hack though:
The anonimous function in the init method compiles without error and
works, like the one below it, as expected. For now I'm OK with it, but
it annoys me pretty much. Maybe later I'll look into it deeper at a
later time (and post it here). Must be something silly...

private function init(target:MovieClip,
depth:Number,
ns:NetStream){
//... more code here

this.update = function(){
this.screen._width = this.screen.width;
this.screen._height = this.screen.height;
};
}

public function update(){
this.screen._width = this.screen.width;
this.screen._height = this.screen.height;
}


[quoted text, click to view]

--
----------
Manno Bult
AddThis Social Bookmark Button