Welcome, Guest. Please login or register.
Did you miss your activation email?
05/22/12, 07:36
Home Help Search Login Register
News: Parsley Flex framework review featuring quiz application, in our Flex frameworks series
Flex SDK 4.5 mobile roadmap: begin with your mobile development
Swiz Flex framework review featuring quiz application
New homepage we release our new Homepage, take a look ...

+  Flash-db
|-+  General
| |-+  Flash and AS 3 (Moderators: papachan, kofi addaquay)
| | |-+  Access Timeline from MovieClip Object
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Print
Author Topic: Access Timeline from MovieClip Object  (Read 1763 times)
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« on: 01/07/10, 09:39 »

Hi there-  Quick question regarding the timeline.  I have a simple app that generates buttons via an xml file.  This xml file includes the path to the image and the url i want the button to go to when clicked.  All works well in terms of linking to outside sites, however if i want to switch between frames with this menu how would i access the timeline via this MovieClip Object.

For instance, the menu code is housed within it's own .as file. This menu is added to the stage via the Document class.  So far this code gives me an error:

"TypeError: Error #1010: A term is undefined and has no properties."

Any help is appreciated!

Code:
//link to hyperlinks - working
/*
function iconClicked(e:MouseEvent):void {
var linkReq:URLRequest = new URLRequest(e.target.path);
navigateToURL(linkReq, '_blank');
}
*/
//link to frames - not working
function iconClicked(e:MouseEvent):void {
this.root.gotoAndPlay('e.target.path');
}
Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #1 on: 01/07/10, 09:46 »

I suppose, you are accessing the timeline of a loaded clip.

There you address through the loader.
Logged

happy flashing
Cool
Ronald
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« Reply #2 on: 01/07/10, 10:23 »

No actually, the timeline i want to access is the main timeline of the Flash file.  This flash file has a Document class called Doc.as.  This Doc.as file instantiates the menu and adds it to the stage.  Within this menu, Menu.as, the Click Event can be found.

Doc.as
Code:
...
private var _menu:Menu = new Menu();
this.stage.addChild(_menu);

Menu.as
Code:
...
//link to main timeline frames - not working
function iconClicked(e:MouseEvent):void {
var mc:MovieClip = stage as MovieClip;
mc.gotoAndPlay('e.target.path');
}

This gives me a new error:  Is this because the menu has not been added to the stage before i have access to the main timeline?  Perhaps using the ADDED_TO_STAGE Event might work?

"TypeError: Error #1009: Cannot access a property or method of a null object reference."

Any additional advice is appreciated!  Thanks!
« Last Edit: 01/07/10, 10:32 by worked » Logged
Ronald Wernecke
Administrator
Systems Administrator
*****
Posts: 6175


View Profile WWW Email
« Reply #3 on: 01/07/10, 12:11 »

dont do it this way.
In AS3 there is no root anymore

The cleanest way is to allways load animitions into a loader component, there it is isolated and easy to control.
The main movie should consist of script, and maybe background only.

With this philosophy I got about everything managed, I wanted Wink
Logged

happy flashing
Cool
Ronald
worked
Seasoned Programmer
***
Posts: 129


View Profile Email
« Reply #4 on: 01/07/10, 13:54 »

Ok, I'm hearing ya.  Thanks again for the advice!
Logged
Pages: [1] Print 
« previous next »
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!