sonic_2k_uk
06-26-2007, 10:46 AM
Hi,
I understand that referencing root doesnt *technically* exist in the conventional sense anymore.
I am trying to tell the root timeline to gotoAndStop through a class, but am not having much luck:
Class:
// somePackage Class
package somePackage
{
// Stage Class
public class Option
{
// Import required classes
import flash.display.DisplayObject;
// Create class variables
private var stageRef:flash.display.DisplayObject;
// Constructor Method
public function Option (stageRef:flash.display.DisplayObject)
{
this.stageRef = stageRef;
}
// createButton Method
public function createButton:Sprite
{
// Create button mc
var button:MovieClip = new MovieClip ();
// !!! ... Code to create button with click event referencing submit method and return sprite object to another class which is then displayed on the stage ... !!!
button.addEventListener (MouseEvent.CLICK, this.submit);
return button;
}
// Submit method
public function submit (event:MouseEvent):void
{
this.stageRef.gotoAndStop ('start');
}
}
}
Instantiation on timeline:
var objOption:somePackage.Option = new somePackage.Option (this);
I get the following error:
1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObject.
Any help is very much appreciated!
I understand that referencing root doesnt *technically* exist in the conventional sense anymore.
I am trying to tell the root timeline to gotoAndStop through a class, but am not having much luck:
Class:
// somePackage Class
package somePackage
{
// Stage Class
public class Option
{
// Import required classes
import flash.display.DisplayObject;
// Create class variables
private var stageRef:flash.display.DisplayObject;
// Constructor Method
public function Option (stageRef:flash.display.DisplayObject)
{
this.stageRef = stageRef;
}
// createButton Method
public function createButton:Sprite
{
// Create button mc
var button:MovieClip = new MovieClip ();
// !!! ... Code to create button with click event referencing submit method and return sprite object to another class which is then displayed on the stage ... !!!
button.addEventListener (MouseEvent.CLICK, this.submit);
return button;
}
// Submit method
public function submit (event:MouseEvent):void
{
this.stageRef.gotoAndStop ('start');
}
}
}
Instantiation on timeline:
var objOption:somePackage.Option = new somePackage.Option (this);
I get the following error:
1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObject.
Any help is very much appreciated!