How do I rename a button with AS

  • Red Hat
  • Novice
  • Novice
  • Red Hat
  • Posts: 16

Post 3+ Months Ago

Hi, I have a problem.

I'm generating a menu dynamically in a custom made scroolbar with a mask.
A movie clip holds my mc effect that is supposed to happen on roll over, a text field and a button. I’m creating instances of that movie clip with action script dynamically inside two other movie clips (two depths). I have a problem with the onRollOver method of the button that is inside.

I’m assigning like this:

Code: [ Select ]
for(var i=0; i < num; i++){
    this.scroll_content.item_holder.attachMovie("meni", i+"_meni_mc", i, {_x:0, _y:(24*i) });
    this.scroll_content.item_holder[i+"_meni_mc"].Tekst_txt.text = "SomeName";
}
  1. for(var i=0; i < num; i++){
  2.     this.scroll_content.item_holder.attachMovie("meni", i+"_meni_mc", i, {_x:0, _y:(24*i) });
  3.     this.scroll_content.item_holder[i+"_meni_mc"].Tekst_txt.text = "SomeName";
  4. }



Code: [ Select ]
_root._level0.scroll_content.item_holder.0_meni_mc.button_btn.onRollOver = function () {
 _root._level0.scroll_content.item_holder.0_meni_mc.efekt_mc.gotoAndPlay("k1");
};
  1. _root._level0.scroll_content.item_holder.0_meni_mc.button_btn.onRollOver = function () {
  2.  _root._level0.scroll_content.item_holder.0_meni_mc.efekt_mc.gotoAndPlay("k1");
  3. };



I get an error like this when testing:

Quote:
**Error** Scene=Scene 1, layer=Script, frame=1:Line 7: Syntax error.
_root._level0.scroll_content.item_holder.0_meni_mc.button_btn.onRollOver = function () {


The path is true.
I think maybe I need to change the name of the button instance...
But how do I do that dynamically with AS?

The parent movie clips don’t have rollover methods assigned to them.

does anyone know a solution?
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • roarmeow
  • Professor
  • Professor
  • User avatar
  • Posts: 861
  • Loc: BKNY

Post 3+ Months Ago

i'll take more time with it in a bit, but the first thing that pops out is:
"_root._level0"

_root is the same thing as _level0, so it's a contradiction to tell it to look for _level0 within _root. take out the reference to _level0 and see if it works.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 16 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.