Results 1 to 7 of 7

Thread: onClipEvent from timeline syntax?

  1. #1
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default onClipEvent from timeline syntax?

    Hi all,

    I'm having trouble with using "onClipEvent(load)" from the timeline. If I put the following on a movie clip (instance name is "newOffers") directly, it works:

    Code:
    onClipEvent (load) {
    	trace(this._name);
    }
    But from the timeline, I get the error "Expected a field name after '.' operator" with both of the following:

    Code:
    _root.newOffers.onClipEvent (load) {
    	trace(this._name);
    }
    Code:
    _root.newOffers.onClipEvent (load) = function() {
    	trace(this._name);
    };
    The following does not produce an error, but the trace doesn't run either:

    Code:
    _root.newOffers.onLoad = function() {
    	trace(this._name);
    };
    I have a basic understanding of the differences in onLoad, onClipEvent(load), the movieClipLoader class, and the loader component, and I'm pretty sure onClipEvent(load) is what I want. I just want to run some AS on that MC one time, at the start of the movie, without running into timing issues where the code is executed before the MC is ready to receive it.

    Any help greatly appreciated - this is a frustrating one.

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

    Default

    The onClipEvent(load) syntax only works when attaching actions directly to movieclips. For various reasons, this isn't recommended (Google around for the reasons, or ask ).

    It looks like you're loading in a movieclip using the MovieClipLoader (MCL) class. You didn't provide your code for the MCL class so I'm assuming you haven't called MCL right.

    Watch this tutorial by Lee Brimelow and see if it sheds any light on what you're trying to do. If not, post back.

  3. #3
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    Actually, I'm not using the MovieClipLoader class. The only external content I'm loading is some XML, but I'm not having any issues there.

    The "newOffers" MC was manually dragged out onto the stage and given an instance name. It's not going to have any content loaded into it or anything like that. All I want to do is set its _visible property to false when the movie starts. I think I'm just overcomplicating the whole thing. :\

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

    Default

    Quote Originally Posted by jlizarraga View Post
    Actually, I'm not using the MovieClipLoader class. The only external content I'm loading is some XML, but I'm not having any issues there.

    The "newOffers" MC was manually dragged out onto the stage and given an instance name. It's not going to have any content loaded into it or anything like that. All I want to do is set its _visible property to false when the movie starts. I think I'm just overcomplicating the whole thing. :\
    Hmm...then I'm totally confused as you're trying to do.

    If the MC exists on the stage at the start of the movie, you just need to add this to the first frame:
    Code:
    newOffers._visible = false;

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

    jlizarraga (02-10-2009)

  6. #5
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    I was under the impression that while that works, there are situations where you might encounter timing issues because sometimes the Actionscript is executed before the target instance is ready to receive commands. Is that not the case? Is it totally safe to use your example?

    Like in Javascript, how a script will fail if it tries to access something before it has been rendered.

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

    Default

    Quote Originally Posted by jlizarraga View Post
    I was under the impression that while that works, there are situations where you might encounter timing issues because sometimes the Actionscript is executed before the target instance is ready to receive commands. Is that not the case? Is it totally safe to use your example?

    Like in Javascript, how a script will fail if it tries to access something before it has been rendered.
    If the movieclip is on the stage, it will always work. That slight time lapse occurs when you're programmatically applying actions to movieclip instances that are also programmatically generated. If something is on the stage, it's there from the begging of the SWF to the end (unless you explicitly remove it via AS, of course).

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

    jlizarraga (02-10-2009)

  9. #7
    Join Date
    Apr 2008
    Location
    San Diego, CA
    Posts
    352
    Thanks
    57
    Thanked 6 Times in 6 Posts

    Default

    Thank you very much Medyman. So damn, I really was overcomplicating it quite a bit.

    Edit: Just to be thorough - what if I *had* generated the MC from the library instead of having it on the stage from the get-go? Would one of the things that I was trying then work?
    Last edited by jlizarraga; 02-10-2009 at 12:22 AM. Reason: see above.

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
  •