PDA

View Full Version : I Can't Access variables from the Tineline



Rada
March 25th, 2010, 11:24 AM
I have a class called Butterfly that extends MovieClip and exists as an asset in my Flash CS4 library.

The timeline of Butterfly consists of different wing flaps for different segments of its behavior. One of the animations is the wings opening up. Once the wings are open, dynamic text is shown on the wings of the butterfly.



//Butterfly.as
...
private var _textForWings:String = "Text For Wings";



I don't seem to have access to that variable from frame 159 inside of the clip.

What is the right process for accessing variables defined in the class by the frames inside?

:-/ Currently I'm using a getter for the _textForWings variable and using


//getter inside Butterfly.as
public function get textForWings():String
{
return _textForWings;
}

//frame 159 inside Butterfly
(this.parent as Butterfly).textForWings;



In this instance this works, but this things that i specify in the class are not avaiable to me within the timeline where i need them issue is really causing some headaches.

Thanks guys,
Aaron

Maqrkk
March 25th, 2010, 11:32 AM
The variable is a private var, maybe that's why? Try setting it as public var.

Rada
March 25th, 2010, 11:39 AM
Hi Marqrkk, thanks for taking a stab at it. I've tried private, public, and protected without any luck.

I fear that I'm approaching the structure of this project all wrong. I'm not an OOP expert. Like many I came from AS2 and an art background before that. Maybe there shouldn't ever be the need for the timeline to access variables and I'm trying to do something that AS3 wasn't designed to do.

Maqrkk
March 25th, 2010, 11:45 AM
I for one don't ever use timelines at all, so am pretty umfamiliar with them. Though I'd say that in a timeline of an object, you should be able to access it's properties, and it's parent properties aswell.

Rada
March 25th, 2010, 12:24 PM
Well, I have some bad news. I made a test file that mimics the functionality of the project I'm working on, and I don't have the problems I'm having with this other file..... Like you recommended, and I hoped to be the case originally, after setting the variable to public, the time line has access to it. I'm glad to have at least figured that much out by posting this problem, but it looks like the culprit of my issue is elsewhere.

I appreciate your help.

Rada
March 25th, 2010, 01:52 PM
However, if anyone knows a better way to integrate animated clips into oop projects... I like secret techniques ;D

Rada
March 29th, 2010, 10:52 AM
I was all kinds of confused last week about this. I went through my application and found all sorts of little weird things that i fixed and this problem went away. oopsies :D