| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Web Developer
|
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: Code:
// 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');
}
}
}
Code:
var objOption:somePackage.Option = new somePackage.Option (this); 1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display Any help is very much appreciated! |
|
|
|
|
|
#2 | |
|
Registered User
Join Date: Jun 2007
Posts: 18
|
I'm a total noob to AS but i think you need to import the class that has gotoandstop in it before you can use it. does import flash.display.DisplayObject; do this? i'm not sure. sorry if this is just confusing i'm still learning.
Quote:
|
|
|
|
|
|
|
|
|
|
#3 |
|
Web Developer
|
Same boat at me =D
My understanding is that the flash.display.DisplayObject allows you to reference and create instances of that type, and this provides you with any properties and methods of that type. Just as if you imported any other class. flash.display.stage does not seem to have the gotoAndStop method, so i need to find a way to reference the root timeline so that i can access the gotoAndStop method for it. I presumed the stage type allows me to do this! |
|
|
|
|
|
#4 |
|
AS3
|
First of all you don't have to use full package path to define variable (just use import statement and then you can use only object name).
Secound Display object dosen't have gotoAndStop methos. only Movie Clip has, so your main document class should extend MovieClip if you want to control timeline. Chech out those tutorials. They helped me a lot when I was starting to learn as3. Also languae reference become very usefull over time. |
|
|
|
|
|
#5 |
|
Web Developer
|
Many thanks panel, have actually just solved the problem a different way
AS3 is as ive read, very different to previous versions! Problem solved by modifying the submit method to the following: Code:
// Submit method
public function submit (event:MouseEvent):void
{
event.target.root.gotoAndStop ('start');
}
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Controlling a MovieClip timeline with another MovieClip | kritter | ActionScript 3.0 | 5 | 08-09-2007 12:33 PM |
| unloading MovieClip and playing the main timeline | imbu22 | ActionScript 2.0 | 1 | 10-08-2006 01:59 PM |
| Controlling a mc timeline with another mc help pls | kritter | ActionScript 2.0 | 7 | 09-18-2006 05:00 PM |
| Controlling timeline and MediaPlayback Controlling timeline | BlackCrow | Components | 1 | 08-02-2005 05:27 PM |
| Help!! loading/attaching rootMC to new MC's timeline | SecretAgentRege | ActionScript 2.0 | 3 | 05-26-2005 09:15 AM |