Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-04-2003, 01:34 PM   #1
buggedcom
CONTEMPLATING LIFE
 
Join Date: Sep 2001
Location: i'm feeling slightly teddy-ish
Posts: 733
Send a message via AIM to buggedcom
Default registering a property with in a class

I am currious if it is possible to register a property that is global to the class only.

for instance.

ActionScript Code:
imageWeaver.prototype.createButton_getUrl = function() {     var cB = this;     this.urlOption.onRollOver = function() {         cB.urlOption.gotoAndStop("over");     };     this.urlOption.onRollOut = function() {         cB.urlOption.gotoAndStop("up");     };     this.urlOption.onPress = function() {         cB.urlOption.gotoAndStop("down");     };     this.urlOption.onRelease = function() {         if (cB.debug_options) {             cB.callDebugger("This url : "+cB.urlArray[cB.iLoadNumber-1]+" was launched, which opened in the : "+cB.get_UrlWindow+" window.");         }         getURL(cB.urlArray[cB.iLoadNumber-1], cB.get_UrlWindow);         cB.urlOption.gotoAndStop("over");     };     this.urlOption.onReleaseOutside = function() {         cB.urlOption.gotoAndStop("up");     }; };

instead of registering the var cB to this every time i create a button is it possible to create it globally but just within the class so it doesn't interfer with the root?

Also is there an easier way to call 'this' rather than assign it to the variable. I tried _parent but that didn't work. Any ideas?
__________________
~bugged
I am looking for freelance work

imageWeaver gallery
microsite direct download

play here microgame (unfinshed, also give it a while to load)
game
buggedcom is offline   Reply With Quote
Old 02-04-2003, 03:11 PM   #2
jimburton
no sleep til bedtime
 
jimburton's Avatar
 
Join Date: May 2001
Location: Brighton
Posts: 1,322
Default

global is global is global AFAIK If I understand what your code is trying to do, you can do it by creating a timeline property in an object, like

ActionScript Code:
function Class1() { child=new Class2(); child.tl = this; child.onEnterFrame = function() { this.tl.class1Method(); // calls a method on the parent } }

in the same way that is v useful when working with xml objects and loadvars...any help?
jimburton is offline   Reply With Quote
Old 02-04-2003, 03:33 PM   #3
buggedcom
CONTEMPLATING LIFE
 
Join Date: Sep 2001
Location: i'm feeling slightly teddy-ish
Posts: 733
Send a message via AIM to buggedcom
Default

er...right

i really don't understand that. does this mean that i don't have to create

var cB = this

before i call cB? Or does it mean that i wouldn't have to specify cB at all and i could just refer to the component as this in the button code?

how would this function look if it where to come under the imageweaver class? I'm really at a loss to how to implement it?
__________________
~bugged
I am looking for freelance work

imageWeaver gallery
microsite direct download

play here microgame (unfinshed, also give it a while to load)
game
buggedcom is offline   Reply With Quote
Old 02-04-2003, 03:45 PM   #4
jimburton
no sleep til bedtime
 
jimburton's Avatar
 
Join Date: May 2001
Location: Brighton
Posts: 1,322
Default

sorry I'm being unclear...all I'm suggesting is a shortcut to creating your cb var every time...so when you create the urlOption object you do something like:
ActionScript Code:
this.urlOption.tl = this;

so then you can always refer to the timeline of your component:

ActionScript Code:
this.urlOption.onEnterFrame = function() { this.tl.doSomething(); }

but looking at your code, you should be able to simplify it, can't you just go:
ActionScript Code:
imageWeaver.prototype.createButton_getUrl = function() {         this.urlOption.onRollOver = function() {               [b]  this.gotoAndStop("over");[/b]??         }; };
jimburton is offline   Reply With Quote
Old 02-04-2003, 03:54 PM   #5
buggedcom
CONTEMPLATING LIFE
 
Join Date: Sep 2001
Location: i'm feeling slightly teddy-ish
Posts: 733
Send a message via AIM to buggedcom
Default

Thanks i understand a little more now. In regards to just

Quote:
imageWeaver.prototype.createButton_getUrl = function() {
this.urlOption.onRollOver = function() {
this.gotoAndStop("over");??
};
};
i wouldn't been able to do that because when the roll over function is created, everythiing inside the function {} refers to the mc that the function was created on. so this instead of refering to the component timeline becomes this for the urlOption. In that respect i don't think

Quote:
this.urlOption.onEnterFrame = function() {
this.tl.doSomething();
}
would work either.
__________________
~bugged
I am looking for freelance work

imageWeaver gallery
microsite direct download

play here microgame (unfinshed, also give it a while to load)
game
buggedcom is offline   Reply With Quote
Old 02-04-2003, 03:55 PM   #6
buggedcom
CONTEMPLATING LIFE
 
Join Date: Sep 2001
Location: i'm feeling slightly teddy-ish
Posts: 733
Send a message via AIM to buggedcom
Default

my mistake... that would work but isn't it practically the same as what i am doing anyway because i would still have to declare

ActionScript Code:
this.whateverMC.t1 = this;

everytime it needed to be applied to a different object?
__________________
~bugged
I am looking for freelance work

imageWeaver gallery
microsite direct download

play here microgame (unfinshed, also give it a while to load)
game
buggedcom is offline   Reply With Quote
Old 02-04-2003, 04:06 PM   #7
jimburton
no sleep til bedtime
 
jimburton's Avatar
 
Join Date: May 2001
Location: Brighton
Posts: 1,322
Default

sorry bugged, you've lost me! so the target of the rollover etc functions of a urlOption clip change over time? then could you set the functions up once

ActionScript Code:
imageWeaver.prototype.createButton_getUrl = function() {         this.urlOption.onRollOver = function() {                   this.tl.gotoAndStop("over");??         }; };

then just change the value of this.urlOption.tl to change the outcome of the rollover? Maybe I'm not getting it,
jimburton is offline   Reply With Quote
Old 02-04-2003, 04:16 PM   #8
buggedcom
CONTEMPLATING LIFE
 
Join Date: Sep 2001
Location: i'm feeling slightly teddy-ish
Posts: 733
Send a message via AIM to buggedcom
Default

.... it is all a bit confusing ...


the targets don't change they stay the same.

in the example below.... this.("over"); would refer to 'this.urlOption' so in that effect you are correct and i should adjust my code accordingly but...

ActionScript Code:
imageWeaver.prototype.createButton_getUrl = function() {         this.urlOption.onRollOver = function() {                 this.("over");         }; };

... in this example i am trying to call a function in the component timeline aswell as tell the urloption to go to over. but it sees this.callFunction(); as a function in the urloption timeline and not in the component timeline.

ActionScript Code:
imageWeaver.prototype.createButton_getUrl = function() {         this.urlOption.onRollOver = function() {                 this.("over");                 this.callFunction();         }; };

do you follow now?
__________________
~bugged
I am looking for freelance work

imageWeaver gallery
microsite direct download

play here microgame (unfinshed, also give it a while to load)
game
buggedcom is offline   Reply With Quote
Old 02-04-2003, 06:51 PM   #9
jimburton
no sleep til bedtime
 
jimburton's Avatar
 
Join Date: May 2001
Location: Brighton
Posts: 1,322
Default

I think that's what I was suggesting...but I can't be sure! the tl property will allow you to manipulate the main comp. timeline:

ActionScript Code:
imageWeaver.prototype.createButton_getUrl = function() { this.urlOption.tl = this;         this.urlOption.onRollOver = function() {                 this.gotoAndPlay("over");                 this.tl.callFunction();         }; };
jimburton is offline   Reply With Quote
Old 02-04-2003, 06:57 PM   #10
buggedcom
CONTEMPLATING LIFE
 
Join Date: Sep 2001
Location: i'm feeling slightly teddy-ish
Posts: 733
Send a message via AIM to buggedcom
Default

for sure but isn't that pretty much the same as i was doing anyway. assigning a variable before use then using it?

I just wanted to assign the variable once in the entires class because i use 'cB' a lot through out many different functions within the class.
__________________
~bugged
I am looking for freelance work

imageWeaver gallery
microsite direct download

play here microgame (unfinshed, also give it a while to load)
game
buggedcom is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:15 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.