A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Why this code doesn't work

  1. #1
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    Why this code doesn't work

    I have the following in the first frame of a simple movie

    on ClipEvent (load) {
    this.createTextField("coords_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
    coords_txt.autoSize = true;
    coords_txt.selectable = false;
    }
    on ClipEvent (mouseMove) {
    coords_txt.text = "X:"+_root._xmouse+",Y:"+_root._ymouse;
    }

    It doesn't work, I tired moving it to a second frame just in case that was the issue but it still doesn't work.

    I cannot get any on ClipEvents to work however I can if I assing them as functions

    This works:

    this.onLoad=function(){
    txt1.text="testing";
    }

    This Does not
    on ClipEvent(Load){
    txt1.text="Testing"
    }
    Last edited by blanius; 09-15-2005 at 09:48 AM.

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    What is going on with on ClipEvent? I cannot get it to work at all

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Awww jez it's all lowercase!!!!!

    onclipevent which is NOT consistant with AS1 nor the any other commands.

  4. #4
    Some dude, says hi Ultra Pulse's Avatar
    Join Date
    Jun 2005
    Posts
    262
    when you said on ClipEvent(Load){
    txt1.text="Testing"
    }

    you left a space between on and ClipEvent

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Quote Originally Posted by Ultra Pulse
    when you said on ClipEvent(Load){
    txt1.text="Testing"
    }

    you left a space between on and ClipEvent
    Actually I had it without the space and thought maybe that was the problem. Turns out it has to be all lowercase onclipevent which is not correct but is the only way it would work.

  6. #6
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by blanius
    Turns out it has to be all lowercase onclipevent which is not correct but is the only way it would work.
    There should have been another problem. I worked with onClipEvent using the right syntax without problems. If I'm not mistaken onClipEvent isn't compiled as text like most actionscript and therefore also works when the casing is wrong but with other actionscript you will get problems. It's best to always accustom yourself to use the right syntax.

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    yea yea whatever all I know is this code doesn't work:

    onClipEvent(enterFrame){
    txt1.text="hi"
    }

    Now I just put the
    txt1.text="hi" it works

    I'm not crazy I could not for the life of me get the correct syntax for onClipEvent to work with any event. Now I trying it right now and I can't get it to work regardless of case....... I must be losing my mind. I know I was having this problem and when I looked at one of the examples it was lowercase so I tried that even knowing it was wrong and what I had been working on worked. Now no.... Arg.

  8. #8
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Here is a bit of code directly from Macromedia site
    onClipEvent (load) {
    this.createTextField("coords_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
    coords_txt.autoSize = true;
    coords_txt.selectable = false;
    }
    onClipEvent (mouseMove) {
    coords_txt.text = "X:"+_root._xmouse+",Y:"+_root._ymouse;
    }

    Doesn't work for me. Remove the onClipEvents and just leave the instructions it works.... Someone explain that to me. This is v5.0.2
    Last edited by blanius; 09-18-2005 at 09:42 PM.

  9. #9
    Senior Member
    Join Date
    Dec 2002
    Location
    Netherlands
    Posts
    1,632
    Quote Originally Posted by blanius
    Someone explain that to me. This is v5.0.2
    I can't explain it.
    I copy and paste the code you posted using 5.0.2 and it works fine.

    Are you sure your export settings aren't set to flash 5 ?

  10. #10
    Senior Member
    Join Date
    Jun 2000
    Posts
    3,512
    Are you also sure that the flash plugin on Internet Explorer is 6 or greater?

  11. #11
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    yep Lowest player version I have around here is 7 and thats in IE, in Firefox it's 8 and standalone it's 7......

    See it yourself here:
    http://bretlanius.com/flash/onclipproblem_player.htm

    I screen captured it

  12. #12
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Ok here's the deal....... For those that didn't know this (like me) onClipEvent is ONLY for movie clips NOT the root timeline......

    This is the kind of basic stuff NOT in the help files.

    So the problem was totaly my error. Bob figured it out. How was I suppose to know this is the real question.

    Any way at least I can stop thinking my computer was out to get me.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center