I am trying to access vars, functions and objects hard coded on the main timeline from a class. The Objects, vars etc... are loaded when I call a function in the class like this:
Some code from main timeline:
import com.beauMoves;
var bm = new beauMoves();
bm.thisWorks();
and below is the class. But it is not accessing the main timeline. In this case I am trying to access a display object loaded from the lib and place on the timeline. The object is called "Beau" as you can see in the code below.
package com {
import flash.display.MovieClip;
import com.*;
public class beauMoves extends MovieClip
{
public function beauMoves()
{
// constructor code
trace("BeauMoves");
}
public function thisWorks()
{
trace("Cool Beans! This one worked");
// THESE TWO LINES BELOW ARE NOT WORKING
var main:MovieClip = MovieClip(this.parent);
main.Beau.alpha = .3;
}
}
}
Presuming the two lines below are on the main timeline, pass to beauMoves() this as a constructor argument:
import com.beauMoves;
var bm = new beauMoves( this );
Then in your beauMoves() class:
package com {
import flash.display.MovieClip;
import com.*;
public class beauMoves extends MovieClip
{
private var _mainTimeline:MovieClip;
public function beauMoves( mainTimeLine:MovieClip )
{
// constructor code
trace("BeauMoves");
_mainTimeline = mainTimeLine;
}
public function thisWorks()
{
trace("Cool Beans! This one worked");
_mainTimeline.bm.alpha = .3;
}
}
}