Home Tutorials Forums Articles Blogs Movies Library Employment Press Buy templates

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-26-2007, 10:46 AM   #1
sonic_2k_uk
Web Developer
 
Join Date: Dec 2002
Location: Kendal, UK
Posts: 139
Send a message via MSN to sonic_2k_uk Send a message via Yahoo to sonic_2k_uk
Default "_root" timeline reference

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');
		}
		
	}

}
Instantiation on timeline:

Code:
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.displayisplayObject.

Any help is very much appreciated!
sonic_2k_uk is offline   Reply With Quote
Old 06-26-2007, 10:52 AM   #2
angels.of.promise
Registered User
 
Join Date: Jun 2007
Posts: 18
Default

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:
Originally Posted by sonic_2k_uk View Post
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');
		}
		
	}

}
Instantiation on timeline:

Code:
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.displayisplayObject.

Any help is very much appreciated!
angels.of.promise is offline   Reply With Quote
Old 06-26-2007, 11:05 AM   #3
sonic_2k_uk
Web Developer
 
Join Date: Dec 2002
Location: Kendal, UK
Posts: 139
Send a message via MSN to sonic_2k_uk Send a message via Yahoo to sonic_2k_uk
Default

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!
sonic_2k_uk is offline   Reply With Quote
Old 06-26-2007, 11:49 AM   #4
panel
AS3
 
panel's Avatar
 
Join Date: Mar 2007
Location: Warsaw
Posts: 1,761
Send a message via Skype™ to panel
Default

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.
panel is offline   Reply With Quote
Old 06-26-2007, 12:16 PM   #5
sonic_2k_uk
Web Developer
 
Join Date: Dec 2002
Location: Kendal, UK
Posts: 139
Send a message via MSN to sonic_2k_uk Send a message via Yahoo to sonic_2k_uk
Default

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');
}
This uses the targetted movie clip on the stage to reference the stage root.
sonic_2k_uk is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

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


All times are GMT. The time now is 06:57 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2009 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.