Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Target a specific frame in an MC for display

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default Target a specific frame in an MC for display

    If my mc has a number of frames, each with a different graphic or movieclip.

    the first question -is do I want each object in the frame to be a movieclip -think so

    The second question would be initially getting the mian MC to stop
    (should i just instert stop actions in each frame)

    This would be the psuedo code I think:
    var myClip:MovieClip = new MyClip ();
    addChild (myClip);
    --which spawns the main mc frame 1

    but to access frame 2 with it's respective frame labeled "second"

    would I call it like this?

    var myClip.second:MovieClip = new MyClip.second ();
    addChild (myClip.second);
    I am not sure if this is doable-this way

    I can use myclip.gotoAndstop(2) or ("second");
    in a function -I know that which is 1/2 of it

    Mendyman showed me an example of using it in AS2 with an array.

    I would like to know how to call up parts of a movieclip as instances.
    Last edited by evan; 06-16-2008 at 06:44 PM.

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    the first question -is do I want each object in the frame to be a movieclip -think so
    If you want actions applied to the graphics on each frame, yes. Otherwise, no.

    The second question would be initially getting the mian MC to stop
    (should i just instert stop actions in each frame)
    You only really need stop functions on the first frame. After that you'll be using gotoAndStop() so the stop action is implied.

    Mendyman showed me an example of using it in AS2 with an array.
    Where did I show you this? I can show you how to do it in AS3 if I know what the original code was.

  3. The Following User Says Thank You to Medyman For This Useful Post:

    evan (06-18-2008)

  4. #3
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    The example you gave was here

    I looked at it again and I think I need something else

    I have an MC with a timeline, 2 frames

    I am creating interfaces with buttons -so each mc frame contains a different set of buttons. The mc would the called "interface.mc".

    Fame 1 and Frame 2 are labeled "group1" "group2" there is a stop action in frame 1

    I placed "inteface_mc" in the main timeline (is that ok -is there a greater advantage in creating an instance of it.)

    The first problem I had is it isn't recognizing my buttons.

    I set up and EventListener with a button -button"doIt" inside the mc.

    doIt.addEventListener(MouseEvent.CLICK, makeIthappen);

    function makeIthappen(e:MouseEvent):void{
    trace(Dynamicdrive.com is cool);
    }
    I get an error that says:
    ReferenceError: Error #1065: Variable doIt_btn is not defined.
    at inteface_fla::MainTimeline/inteface_fla::frame1()
    Here is a working example -only I used the MAIN timeline to "change" buttons
    even though they look identical. This is the "messy" way.
    Last edited by evan; 06-19-2008 at 08:19 PM. Reason: Update

  5. #4
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Hey Evan…

    First, let me say that I’m thoroughly confused by what you’re doing (i.e. your setup). I think I know what you’re trying to do though. So, here is a little example I just created to demonstrate what I think you’re looking for. Before I explain it though, let me just confirm some things.

    As I understand it, your dilemma is the following:
    You have one movieclip each on one of two frames within a larger container movieclip (interface_mc). You’re trying to access the movieclip on frame 2 of interface_mc and notice that Flash says it doesn’t exist. Correct?

    The issue here is that the movieclip doesn’t exist – at least not within the scope that you’re assigning to it. Actionscript added to a frame of a movie only has purview over that particular frame. So, if you add actions on frame 1 to control a movieclip that doesn’t exist until frame 3, that won’t work. Why? Because, when Flash assigns actions to all the clips at frame 1, the movieclip at frame 3 didn’t yet exist so no actions were applied. In other terms, think of a workplace. The boss of a company assigns tasks to his employees at 8:00 AM. So,Employee X (ever the slacker), who wasn’t at that meeting doesn’t know what to do when he comes in at noon. That’s the first issue.

    The second issue is that the main timeline doesn’t really have jurisdiction over the timeline of constituent movieclips. So, if your interface_mc has two movieclips inside it (button1 on frame 1 and button2 on frame2), you can’t call these clips directly.

    You can call button1 via a relative path to button1 (interface_mc.button1). That gets rid of the problem with the main timeline’s jurisdiction. But, how do you access button2? Interface_mc.button2 doesn’t seem to work! Well, think about what I said earlier. Button2 didn’t exist when that ActionScript ran. Button2 was late to work, or more appropriate in this case, in another room.

    You might think that it’s possible to write a gotoAndStop() call and then right after it attach a function to something within the container. But, this again isn’t the solution. Flash’s internal parsing order denies this from happening. As it turns out, by the time Button2 leaves the other room to come into the meeting, the boss finishes assigning the tasks.

    So, how is it possible to add events or reference movieclips contained on frames other than frame 1 in constituent movieclips? Well…there are 2 ½ solutions:

    1) Write your actionscript within the right scope. This means, put your actionscript that you want attached to a certain movieclip in a layer that has direct access to it. In your example, you would write ActionScript written about Button2, on frame 2 of interface_mc.

    2) In a similar vein, you can create object-oriented programming techniques. Then, the viewpoint of coding shifts from a global view of the entire application to a local view of how one object interacts within the application. You still have an issue with calling objects that appear on frame 2 of a certain “object”, but that’s fixed by using some secret flash techniques. If you’re a serious Flasher, you’ll know about the undocument AS3 method called addFrameScript(). This method allows you to attach functions from one frame to another. So, I can dynamically attach AS3 code to movieclips that I’m building dynamically.

    2 ½) Write ActionScript so that it calculates what’s on the stage dynamically. This is what I’m demonstrating with my example.

    The example has a simple application. It cycles through some cultural icons and shows a small “quote” from them or something they’re associated with. All of the icons are separate movie clips contained within a container movieclip (instance name “icons”). The next button is referencing the icons movieclip and increasing the frame by one each time. If you’re at the end of that timeline (frame 6 in that case), it goes back to one. Clicking on the little icon itself, shows an image of the person in question. The name for the image is derived from the instance name of the icon. If you open up the icons movieclip, you’ll see that I’ve named each icon something different. I then dynamically reference that in my showImage() function.

    Again, I was confused by your post. But maybe this example will come to some use. The fully commented code is added to the example page. As always, it’s all released under Creative Commons NC.

    Let me know if you have any questions

  6. The Following User Says Thank You to Medyman For This Useful Post:

    evan (06-20-2008)

  7. #5
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    that is very usefull, in the sense that it shows how to display frames, of a movieclip.

    This offers more flexibilty than just using the timeline.

    What I was trying to mention in my earlier post was, what if I did that AND then the targeted frame in the movie clip had interractivity assigned to it's objects.

  8. #6
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    What I was trying to mention in my earlier post was, what if I did that AND then the targeted frame in the movie clip had interractivity assigned to it's objects.
    Right...
    You can do that as well. Just like I'm pulling the names.

    Using the getChildAt() method.

    So, if you were trying to attach a CLICK mouse event to a movieclip on frame 2 of another movieclip (instance name interface), you might do something like this:

    Code:
    instance.gotoAndPlay(2);
    instance.getChildAt(0).addEventListener(MouseEvent.CLICK, onClick);
    Of course, this doesn't guarantee that you're accessing the right movieclip. If the gotoandPlay doesn't complete on time, it will add the actions to the child at level0 on the first frame.

    You could also use addFrameScript():

    Code:
    interface.addFrameScript(2, frame2);
    function frame2() {
       interface.buttonOnFrame2.addEventListener(MouseEvent.CLICK, onClick);
    }

  9. The Following User Says Thank You to Medyman For This Useful Post:

    evan (06-26-2008)

  10. #7
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    check this out

    this is a cleaner version of what I'm working on. I resorted to putting the interface for the markers into a second frame.

    at a first glance, can do you have any suggestions.
    The code is pretty long for it to be intelligible here.

  11. #8
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Seems good so far. Without looking at what's under the hood, I can't really make any suggestions.

    But everything seems to be running smoothly and functioning properly. Seems like you're on the right track. It's good to see the result of all of these threads

    Keep it up.

  12. The Following User Says Thank You to Medyman For This Useful Post:

    evan (06-30-2008)

  13. #9
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    Let me see if I can post it for you meanwhile, I think I figured it out.

    The bug here is that after you use the markers and go back to the pencils, it clears the screen when I don't want it to.

    in this version, I have an API drawing board that contains the drawing, I borrowed that from the Flash, and Math paintool -I can also use a library mc and set the alpha to "0" but that has dissadvantages. so, apparently there is no way to get around coding it this way.

    I think the bug is caused because I work with two frames, frame 1 has the pencils, Frame 2 has the markers. The user starts drwing with pecils, then goes to frame 2 and draws with the markers, then clicks the button to use the pencils again and then:POOF
    the whole drawing is erased!


    why? because it goes back to frame 1 where the code instructs it to draw an API drawing board! in other words the "program" restarts because frame 1 is the place where the code tells flash to draw an artboard!

    I can fix this(I Think) by toggling the tools between frames, 2 and 3 not 1, and 2

    I just tested the theory and here it is -bug fixed

    OR I can implement what you are showing me here. The lesson learned here is Yes, using fames is an easy quick and dirty way to get things done, but I think keeping stuff in Frame 1 is better, and using frame by frame with intercativity is better served for flash docs imported in to the main doc, and either coding animation, or changing tweens into actionscript.

    Thankyou for your effort and help, I have learned much sensie master
    Last edited by evan; 06-30-2008 at 04:52 PM.

  14. #10
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default Error messages in the source you showed me

    1172: Definition caurina.transitions could not be found. lines 1,3
    1120: Access of undefined property Tweener. lines 72,77


    --SCRATCH THAT I impoted the class from the Corina folder the comment pointed the link. OK brain fart
    Last edited by evan; 06-30-2008 at 10:35 PM.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •