Search code examples
flashactionscriptlabelflash-cs5uiloader

Flash Component(label, uiloader & etc) Content Preserved on Other Frames?


My movie has 5 frames, all set as key frame. Frame 1 contains a label called lblMyname and a uiloader called uiMypic and then some buttos when press will go to selected frame. I then copy them and paste in place onto frame 5. When the movie start, lblMyname will be set to a name say Robert and uiMypic will load an image by the code of uiMypic.source = "http://localhost/test.jpg".

Here comes my problem, when i click the button to go to frame 5 i would expect to see both lblMyname and uiMypic to display same value as at frame 1 but it didn't! lblMyname display it's default text while uiMypic display nothing/blank.

Why and how do i make them display the same content as frame 1? I don't want to reload their value again at frame 5...


Solution

  • Instances of components and movieclips are only exists within their tween span/key frame. So if you have multiple tween spans or a key frame that is a 1 frame tween span, then components in frame 1 are totally different than the components in frame 5 and will not carry values from frame 1 to 5.

    You can make your component persist across frames by making its tween span encompass all the frames. More commonly now, something like this is set up in the first frame where you use code to switch the image and content component.

    So, your "go to frame 5" button simply tells your code to load the image and display the component labels for the content that would be in frame 5. If you do want to have the images in the timeline, you can place them all in the first frame, but turn them on and off depending on which "frame" you are on.