🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.javascript
3 messages
3 total messages Started by Czesiu Thu, 11 Nov 2010 13:21
Przekazywanie zmiennych między funkcjami
#50378
Author: Czesiu
Date: Thu, 11 Nov 2010 13:21
22 lines
1710 bytes
Witam!
Czy zmienną utworzoną w jednej funkcji można przekazać do drugiej?
Jeżeli tak to jak to wykonać?

Mam taki kod aplikacji air:

function playSound(){
var soundPath = new air.URLRequest(file.nativePath);
var s = new air.Sound();
s.load(soundPath);
var channel = s.play();

}
function pauseSound(){
var pausePosition = channel.position;
channel.stop();
}

Potrzebuje zmiennej channel utworzonej w playSound() do pauseSound().
Próbowałem wszystkiego, googlowałem, ale nic!
Dzięki z góry!
Pozdrawiam Czesiu!
Re: Przekazywanie zmiennych między funkcjami
#50379
Author: Peter May
Date: Thu, 11 Nov 2010 13:43
37 lines
1742 bytes
W dniu 2010-11-11 14:21, Czesiu pisze:
> Witam!
> Czy zmienną utworzoną w jednej funkcji można przekazać do drugiej?
> Jeżeli tak to jak to wykonać?
>
> Mam taki kod aplikacji air:
>
> function playSound(){
> var soundPath = new air.URLRequest(file.nativePath);
> var s = new air.Sound();
> s.load(soundPath);
> var channel = s.play();
>
> }
> function pauseSound(){
> var pausePosition = channel.position;
> channel.stop();
> }

Ustaw zmienną channel jako globalną. Spróbuj tak:

var channel;

function playSound(){
var soundPath = new air.URLRequest(file.nativePath);
var s = new air.Sound();
s.load(soundPath);
channel = s.play();
}

function pauseSound(){
var pausePosition = channel.position;
channel.stop();
}

-- 
Peter
Re: Przekazywanie zmiennych między funkcjami
#50380
Author: Czesiu
Date: Thu, 11 Nov 2010 18:20
49 lines
2165 bytes
On 11 Lis, 14:43, Peter May <peter....@onet.pl> wrote:
> W dniu 2010-11-11 14:21, Czesiu pisze:
>
>
>
>
>
> > Witam!
> > Czy zmienn utworzon w jednej funkcji mo na przekaza do drugiej?
> > Je eli tak to jak to wykona ?
>
> > Mam taki kod aplikacji air:
>
> > function playSound(){
> > var soundPath = new air.URLRequest(file.nativePath);
> > var s = new air.Sound();
> > s.load(soundPath);
> > var channel = s.play();
>
> > }
> > function pauseSound(){
> > var pausePosition = channel.position;
> > channel.stop();
> > }
>
> Ustaw zmienn channel jako globaln . Spr buj tak:
>
> var channel;
>
> function playSound(){
> var soundPath = new air.URLRequest(file.nativePath);
> var s = new air.Sound();
> s.load(soundPath);
> channel = s.play();
>
> }
>
> function pauseSound(){
> var pausePosition = channel.position;
> channel.stop();
>
> }
>
> --
> Peter- Ukryj cytowany tekst -
>
> - Pokaż cytowany tekst -

Dzięki wielkie wszystko działa!!
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads