[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 291
  • Last Modified:

SIMPLE BUTTON HREF ISSUE! Help needed!

I am a newbie really, I spent half a day going through this tutoria to make ultra cool buttons.
http://www.youtube.com/watch?v=hMzhJOCY6ik
Howevr the tutorial doesn't show how to get a button to change the url of the page,
in actionscript 3 you need something like this:

buttonSymbol.addEventListener(MouseEvent.CLICK, buttonSymbol_click);
function buttonSymbol_click(evt:MouseEvent):void {
    var req:URLRequest = new URLRequest("http://www.adobe.com/");
    navigateToURL(req, "_blank");
}

however because this guys tutorial creates a button wthin a movie clicp witin a movie clip, I can't seem to get this line to work:
buttonSymbol.addEventListener(MouseEvent.CLICK, buttonSymbol_click);
mainly because buttonSymbol seems to be inaccessible fromt the main timeline..

I have tried guessing for ages,and am now just fed up, doesnt CS3 have an object explorer? or a intelli sense that can help me find where the button actuall is????

help please.
regards,
Rob.


0
RBertora
Asked:
RBertora
1 Solution
 
john_hollingsCommented:
If your button is within a movieClip just reference the movieclip instance name first like so:

myMovieClip.buttonSymbol.addEventListener.....

If your button in nested deep in a movie which is in another movieclip reference the first mc, then the second then the button:

myMovieClip1.myMovieClip2.buttonSymbol....
0
 
section25Commented:
AS3 doesn't really have an object explorer, but hang on to this bit of code, it will come in handy in the future. It will allow you to see all of your objects by name, show thier parent, and thier position in the display heirarchy.

If you run it on the main timeline, then the "this" refers to the root (or stage) clip.

var a:int;
var s:DisplayObject;
for(a=1;a<=this.numChildren-1;a++){
      s = getChildAt(a);
      trace(s.name, s.parent, s.parent.getChildIndex(s));
}

0
 
RBertoraAuthor Commented:
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now