Forum Moderators: open

Message Too Old, No Replies

Property and OOP

Trying to learn OOP

         

nxfx

2:07 pm on Jul 7, 2006 (gmt 0)

10+ Year Member



Hello,

i an trying to learn the whole Classes thing.. So far all is working fine, now i have a question. i have a couple of Buttons(MCs) on the stage and have this class:

import mx.transitions.Tween;
import mx.transitions.easing.*;
class RollOverOutFader extends MovieClip {
public function RollOverOutFader() {
this.onRollOver = this.over;
this.onRollOut = this.out;
this.onLoad = this.onload;
this.onPress = this.onpress;

}
private function over(){
var cic:Tween = new Tween(this,"_alpha",Strong.easeOut,0,50,1,true);
}

private function out(){
var cic:Tween = new Tween(this,"_alpha",Strong.easeOut,50,0,1,true);
}

private function onload(){
this._alpha = 0;
}

private function onpress(){
if(this.link!= ""){
_root.gotoAndStop(this.link);

}
}

}

That all works, some of the button do not have a link there are just for highlighting and effects. But if i do not define a link on them, i get an error.

Any idea how to prevent that?

Thank you

oxbaker

3:54 pm on Jul 7, 2006 (gmt 0)

10+ Year Member



whats the error? im assuming it breaks on this line:

if(this.link!= ""){

please post teh EXACT error, without it we're just spinning our wheels. Perhaps the link is null not "" (blank string) maybe you can try changing your if statement to be:
if(this.link!= null){
... do stuff
}

but really, if you have an error from compiling code you should post the error message. Just telling us that there is an error is hardly enough information.

mcm

nxfx

5:26 pm on Jul 7, 2006 (gmt 0)

10+ Year Member



Sorry,

i was just frustated, here is my error:
**Error** /Volumes/work2/STUFF/ASSETS/FLASH/CLASSES/RollOverOutFader.as: Line 27: There is no property with the name 'link'.
if(this.link!= null){

**Error** /Volumes/work2/STUFF/ASSETS/FLASH/CLASSES/RollOverOutFader.as: Line 28: There is no property with the name 'link'.
_root.gotoAndStop(this.link);

Total ActionScript Errors: 2 Reported Errors: 2

and each of the MCs on the stagen has:

onClipEvent (load) {
this.link = "START";
}

Thank you again!

oxbaker

6:24 pm on Jul 10, 2006 (gmt 0)

10+ Year Member



sounds like a pathing problem.

are you sure its supposed to be this.link?

perhaps this.link.text? or this.PATHTOMYMOVIE.link.

(ie: this._parent.movieClip1.link)?

hth,
mcm