Please login or register.

Login with username, password and session length
Advanced search  

News:

Forum rules - please read before posting, it can save you a lot of time.

Author Topic: Button and .GetControl  (Read 3587 times)

0 Members and 1 Guest are viewing this topic.

VEn0m

  • 85 lvl elf
  • Lurker
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 30
  • Live & Learn, Блеать!
    • View Profile
Button and .GetControl
« on: July 14, 2012, 05:56:23 PM »

Hi! And once again im stuck and need help :)

Well, i have a Options.window there i placed a button "music" and a static control "musicvolume".

The button has a script attached:
Code: WME Script
  1.  
  2. var IsLeftDown;
  3.  
  4. on "LeftClick"
  5. {
  6. IsLeftDown = true;
  7. var dx=Game.MouseX-this.X;
  8.  
  9. while(IsLeftDown==true)
  10.         {
  11.                 //while we holding a left mouse button move the "music" after mouse cursor
  12.                 this.X = Game.MouseX-dx;
  13.                
  14.                 //a border
  15.                 if (this.X<120) this.X=120;
  16.                 else
  17.                 if (this.X>390) this.X=390;
  18.                
  19.                 //set volume 1-100 %
  20.                 RefreshVolume(ToInt(Math.Floor((this.X-120)/270*100)));
  21.                 //refresh text on static control "musicvolume"
  22.                 setstate();
  23.  
  24.                 Sleep(10);
  25.         }
  26. }
  27.  
  28. on "LeftRelease"
  29. {
  30. IsLeftDown = false;
  31. }
  32.  
  33. function RefreshVolume(var volume)
  34. {
  35.   muse.channelVolSet(0,volume);
  36. }
  37.  
  38. function setstate()
  39. {
  40. var buttontext = this.GetControl("musicvolume");
  41. buttontext.X = this.X;
  42. buttontext.Text = muse.channelVolGet(0);
  43. }
  44.  

And i got an error "Call to undefined method 'GetControl'. Ignored." because the button doesn't have method .GetControl.

So. How can i fix the text refreshment while we holding a mouse button?

« Last Edit: July 15, 2012, 05:26:04 AM by VEn0m »
Logged

metamorphium

  • Global Moderator
  • Addicted to WME forum
  • *
  • Karma: 12
  • Offline Offline
  • Gender: Male
  • Posts: 1511
  • Vampires!
    • View Profile
    • CBE  software s.r.o.
Re: Button and .GetControl
« Reply #1 on: July 14, 2012, 08:25:53 PM »

this.GetControl must be in script attached to a window. Think of it this way:

window has a control called music or musicvolume
button doesn't have any child controls
Logged
J.U.L.I.A. Enhanced Edition, Vampires!, J.U.L.I.A., J.U.L.I.A. Untold, Ghost in the Sheet

VEn0m

  • 85 lvl elf
  • Lurker
  • *
  • Karma: 3
  • Offline Offline
  • Gender: Male
  • Posts: 30
  • Live & Learn, Блеать!
    • View Profile
Re: Button and .GetControl
« Reply #2 on: July 17, 2012, 06:16:39 AM »

I found the right solution! Just delete static control and left only button music. Thnx a lot :)
Logged
 

Page created in 0.063 seconds with 22 queries.