Copy link to clipboard
Copied
So I have a movieclip with 3 frames and when I call the instance from the library (as shown below) it's not switching to the desired frame. The ultimate goal is to have multiple instances with random frames chosen, but it is currently not chosing any other frame. I have tested this by adding the object to the stage and it works fine, just not when I'm calling it from the library.
function testInit(){
var star = new lib.star();
star.gotoAndStop(1); //this does nothing?
star.x = 346;
star.y = 386;
stageRoot.addChild(star); // stageRoot = this
}
testInit();
Perfection. I broke apart the symbol and I was able to change the fill color. Thing works perfectly now. Bizarre.
Copy link to clipboard
Copied
stageRoot needs to be defined or use:
function testInit(){
var star = new lib.star();
star.gotoAndStop(1); //this does nothing?
star.x = 346;
star.y = 386;
this.addChild(star); // stageRoot = this
}
testInit.bind(this)();
p.s. frame 1 is the 2nd frame.
Copy link to clipboard
Copied
Everything you say is correct. I accidently left off the variable defining stageRoot. The instance is appearing as it's supposed to. The instance is defaulting to frame 0 no matter what. Any other suggestions?
Copy link to clipboard
Copied
does frame 0 have a this.stop() on it?
Copy link to clipboard
Copied
Not at the moment. Does it need it? gotoAndStop() seems to work when I place it on the stage.
Copy link to clipboard
Copied
no, it doesn't need a this.stop(), but it indicates you have something on-stage that looks like star's frame 0 and you're mistaking that for the one added by testInit(). ie, if your code where adding star (and only the goto were failing), star would be cycling through its 3 frames.
create a new fla
drag star from your problematic library to the new library
copy and paste your code into the new fla
test
any problem?
Copy link to clipboard
Copied
Give me a sec, I'll let you know.
Copy link to clipboard
Copied
Well that worked, so I'm going to try something different.
Copy link to clipboard
Copied
Perfection. I broke apart the symbol and I was able to change the fill color. Thing works perfectly now. Bizarre.
Copy link to clipboard
Copied
all's well that ends well.