header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
liquidvisual
Points:110
Posts:0

9/11/2010 7:57:10 PM

Title: Scope issue in Class - AS2


Hello, I'm having a scope issue with a button in my class. I've got a Header Class which draws and arranges a series of buttons. They're all dynamically assigned _key properties and when clicked they need to be able to trace this property.

What's the best way to trace their _key property when you rollOver the button?

Cheers,




class head extends MovieClip {
.....
.........
..............

var TL:MovieClip = timeline;

var hit:MovieClip =  TL.attachMovieClip("button", "button", TL.getNextHighestDepth());

var hit._key = "hello"

hit.onRollOver = overEvent;  // Delegate.create(this, overEvent);
	
//-------------------------------------------------------------------
// overEvent
//-------------------------------------------------------------------

private function overEvent():Void {
     trace(this) // this traces the button instance when clicked as desired
     trace(this._key) // causes error because the _key property has not yet been created yet and won't compile
}




1
RedBull
Points: 930
Posts:0
9/11/2010 11:17:04 PM



instead of using this first declare the variable type then point "this" to that variable
//declare it to the class type that has _key property
var myClip:button ;
myClip=this;
trace(myClip._key)

2
Harkin
Points: 0
Posts:0
9/13/2010 1:39:57 AM



if your _key variable is inside the clas you are accessing then you should be able to access it directly without using "this"

trace(_key)


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 4+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions