Sound and Buttons on TabBar example !

Hi everyone,

i hope somebody have an idea to this.

I have changed the Tabbar Example to my needs but i’m still failing with the sound function because its a function which you schould call in another function.

Here is the code to this from screen1.lua:

[lua]-- Definitions for Object Height and Width
_H = display.contentHeight;
_W = display.contentWidth;

–Definitions for AudioStreams (which audio should be load to which Definition)

local beachSound = audio.loadStream(“oceanwave.mp3”);
module(…, package.seeall)
function new()
local g = display.newGroup()

local background = display.newRect(0,display.screenOriginY, display.contentWidth, display.contentHeight-display.screenOriginY)
background:setFillColor(255, 255, 255)
g:insert(background)

– Buttonimages and Positions
local beachbutton = display.newImage( “beach.png” );
beachbutton.x = _W / 3.3; beachbutton.y = _H /3.8;
g:insert( beachbutton );

–Functions for Soundplayimg, Buttontap and Timer

– At the Beach
function beachbutton:tap( event )

if not soundPlaying then
audio.play(beachSound, {loops=-1, duration=900000} )
else
audio.stop(beachSound)
end

soundPlaying = not soundPlaying – flip flag
end

– Tap Event Listener
beachbutton:addEventListener( “tap”, beachbutton );

– TextLabel
local beachText = display.newText( “At the Beach”, 62, 155, “Helvetica”, 14)
beachText:setTextColor(0, 0, 0)
g:insert( beachtext )

function g:cleanUp()
g:removeSelf()
end

return g
end[/lua]

I don’t know how i can set the functions for the audiostream and the audio.play inside a function because it’s already a function. Or am i wrong with my thinking ? Is there another way for do this ?

Thanks
Daniel
[import]uid: 37574 topic_id: 7875 reply_id: 307875[/import]