WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 01-29-2007, 12:01 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Ah, the "global" varable problem. The first sound file you create and assign to the "music" varable is a global varable.

When you use the equals sign in a fuction, it creates a *new and local* varable which only lives within the function. So your "Change" fuctions are trying to create new sound objects and playing them without reasigning the global music function. You are probably getting the "accessing varable before instatiated" error here because you are trying to rewind() the music varable, then assigning to it.

The following code avoids this by added a 'currentMusic' parameter to the fuctions which takes as an argument the global music varable:

Code:
music = viz.add('song.mp3')
music.play()

def stopOldAndPlayNewSong(currentMusic, newSongFile):
    currentMusic.stop()
    currentMusic = viz.add(newSongFile)
    currentMusic.play()

def onkey(key):
    key == '1':
         stopOldAndPlayNewSong(music, 'song1.mp3')
Also, Vizard does not have a rewind() function.


Rather than diving right into Vizard programming, I strongly suggest investing in your python skills. Here is an exclent tutorial: http://docs.python.org/tut/
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #2  
Old 01-29-2007, 12:03 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
Triple jinks!!!
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
  #3  
Old 01-29-2007, 12:13 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Quote:
Originally Posted by Gladsomebeast View Post
Triple jinks!!!
It's spelled jinx. I guess we get off on a technicality. Your powers, they do nothing!!!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 05:50 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC