Storyboard question

Hi all,

I have a question about the following line in the storyboard scene template:

local group=self.view

I'm trying to add an item to the same view group in a callback from media.playVideo and when I do that, I get a nil reference for self in the callback function.

1
2
3
4
5
6
7
8
9
function onVidComplete( event ) 
        local viewGroup = self.view -- self is nil here and an error is thrown
        -- code to add new image goes here
end
 
function scene:enterScene( event )
        local viewGroup = self.view
        media.playVideo("video/start.mov", false, onVidComplete)
end

From what I know, since group is just self.view which (if your storyboard scene is called scene) is scene.view, you would need to change

1
local viewGroup = self.view

Thanks, that does work and I understand why.

But I'm hoping one of the Corona devs or someone else that may know can tell me why the template doesn't use a scene scoped reference to self.view, and why they chose to use a new local reference in each method.

views:2166 update:2012/2/12 11:34:30
corona forums © 2003-2011