LOADING
Loading
Hi , welcome back.
LogoutLOGOUT
 
  Lost password?  
Hi
 




 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 10-17-2007, 05:34 AM
iblokh iblokh is offline
Registered User
 
Join Date: Oct 2007
Posts: 23
Rep Power: 0
iblokh is on a distinguished road
Unhappy Problems: movie clip variables within class and error 1120.

I'm new to AS in general and haven't done any coding in years, but trying to get back into it with AS3. I'm pretty sure my errors are coming from a fundamental misunderstanding of how classes work in AS3, so bare with my please.

I had this code working on a frame in an a .fla file, and when I defined it all within a function in a separate .as file, then called the function in the first frame of the .fla. Now that I am actually trying to extend a class though, no luck.

I get the following errors:

Code:
1120: Access of undefined property  powerbtn.
1120: Access of undefined property powerBtnHandler.
1120: Access  of undefined property armbtn.
1120: Access of undefined property  armBtnDragHandler.
1120: Access of undefined property armbtn.
1120: Access  of undefined property armBtnStopHandler.


My Turntable.as file:

Code:
package {
 import  flash.display.*;
 import flash.events.*;
 import  flash.geom.*;
Code:
  
  dynamic public class Turntable extends MovieClip  {
  
   private var power:Boolean;
  private var  powerbtn:MovieClip;
  private var armbtn:MovieClip;
  
  public  function Turntable() {
   power = false;
   powerbtn = new  MovieClip;
   armbtn = new MovieClip;
  }
  
  //Set functions to be  used in .fla file 
  //to pass instances of power and arm buttons to  class
  public function set _powerbtn(value:MovieClip):void {
   powerbtn  = value;
  }
  
  public function set _armbtn(value:MovieClip):void  {
   armbtn =  value;
  }
     
  powerbtn.addEventListener(MouseEvent.MOUSE_DOWN,  powerBtnHandler);
  armbtn.addEventListener(MouseEvent.MOUSE_DOWN,  armBtnDragHandler);
  armbtn.addEventListener(MouseEvent.MOUSE_UP,  armBtnStopHandler);
  
   //controls power button movie clip and turntable  power status
  function powerBtnHandler( event:MouseEvent ):void {
   if  (power == false) {
    powerbtn.gotoAndStop("power_on");
    power =  true;
   } else {
    powerbtn.gotoAndStop("power_off");
    power =  false;
   }
  }
  //gives user control over the turntable  arm
  function armBtnDragHandler( event:MouseEvent ):void {
   var object  = event.target;
   object.startDrag();
  
   }
  //use relinquishes control of turntable  arm
  function armBtnStopHandler( event:MouseEvent ):void {
   var obj =  event.target;
   obj.stopDrag();
  }
 }
}
and on the first frame of the Turntable.fla file:

Code:
var table:Turntable = new  Turntable();
Code:
  
 table._powerbtn = power_btn;
table._armbtn =  arm_btn;
How could those variables be undefined if I define them in the same class?

PS. This thing keeps adding code wrappers on it's own...

Last edited by iblokh : 10-17-2007 at 05:39 AM Reason: Misformatted code.
Reply With Quote
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

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

Forum Jump




All times are GMT. The time now is 10:43 PM.