Skip navigation
Currently Being Moderated

How do you force instances with the same name on the same layer to update?

Jul 3, 2008 12:48 PM

Maybe someone can tell me why flash doesn’t redraw components’ x,y positions if they have the same instance name and are on adjacent frames? (movieclips work fine, just not components) If I have a button on frame 1 and a button on frame 2 both with the same instance name but different locations on the stage, frame 2’s button doesn’t show up in the position I placed it, it stays at the position of frame 1 but still has the properties of frame 2’s button. The label changes and everything. If I stick a button on a frame in between and give it a different instance name there is no problem. I thought it might be the style manager bug http://www.gskinner.com/blog/archives/2007/12/cs3_component_b.html but it didn’t seem to affect. This happens for textareas too and probably all components although I haven’t tried them. I’ve tried using drawNow() and validateNow() with no luck either http://www.adobe.com/devnet/flash/articles/creating_as3_components_pt3 _05.html

Thank you!

// put this on frame 1 along with a button on the stage with instance name: b
function doit(event) {
if (currentFrame == 1)
gotoAndStop(2);
else
gotoAndStop(1);
}
b.addEventListener(MouseEvent.CLICK, doit);
stop();

// put another button on frame 2 along with this code and also make it’s instance name: b but move it so it’s not in the same x,y coordinates as the button on frame 1
stop();


Something possibly related. I have a movieclip on a layer, one instance with name “a” on frame 1 and one instance with name “a” on frame 2 and it has event listeners inside it that update something on the movieclip. Unless I put the movieclips on separate layers the event listeners won’t reset each frame. (example: a button with a tooltip onmouseover that you want to change the text of from frame 1 to frame 2) You’d think if they were on separate keyframes at least but no, they need to be on separate layers too.

I want the movieclip to update each frame. Any ideas?
 
Replies
  • kglad
    72,227 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 4, 2008 9:26 AM   in reply to Cine-Med
    instances (whether components or not) with the same name may or may not be the same instance. it depends upon how they were created.

    for example, if you create an instance on frame 1 of your main timeline, give it an instance name and then create a keyframe on frame 2, the two instances will be the same.

    but if you create an instance on frame 1 of your main timeline, give it an instance name and then create a blank keyframe on frame2 and create another, what you think is a duplicate, instance and give it the same name, it will be a different instance.
     
    |
    Mark as:
  • kglad
    72,227 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 7, 2008 9:53 AM   in reply to Cine-Med
    then you're doing something wrong. a blank keyframe removes the previous instance and any code that affected it will have no affect on any subsequent movieclips/components.
     
    |
    Mark as:
  • kglad
    72,227 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 7, 2008 12:49 PM   in reply to Cine-Med
    as expected, i see a button component at the top of the stage followed by an empty stage followed by a button component at the bottom of the stage etc.
     
    |
    Mark as:
  • Currently Being Moderated
    Jul 7, 2008 4:03 PM   in reply to Cine-Med
    you can explicitly set the x and y properties of the button in script in each frame, and therefore make the button appear wherever you want it to be.

    That solves the problem, but doesn't explain why the behavior that you describe occurs. (I did see what you described.)
     
    |
    Mark as:
  • kglad
    72,227 posts
    Jul 21, 2002
    Currently Being Moderated
    Jul 7, 2008 4:23 PM   in reply to Cine-Med
    yes, i inserted a blank keyframe after the first button was to be removed and yes, i was describing an empty stage for several frames.

    if you don't want an empty stage at any frame in the timeline, put the buttons in different layers.
     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points