A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: as3 noob: starting the main timeline with a button

  1. #1
    Junior Member
    Join Date
    Feb 2009
    Posts
    5

    as3 noob: starting the main timeline with a button

    OK, I am just about to give up on this whole as3 thing altogether. It is so complex that it is becoming prohibitive for designers, event technical ones ike me (I program easily in perl/php/javascript/sql). this whole having to "import" standard functionality is stupid.

    I have tried to read the Adobe as3 documentation: cryptic and useless for learning

    I have searched the internet and this forum: all I get is code snipets that don't go through the whole process and I end up with useless error messages

    I've tried tutorials: they don't link the concepts together enough

    So here's the issue:

    All I am trying to do start the main timeline from a button. The button's "up" state is also a movie clip.

    Here's the process I am looking for:

    1) the main timeline progresses until a certain point where I have inserted a stop();

    2) I then display a "continue" button (which is an animated movie clip).

    3) the user will "click" the button and the main timeline continues.

    My simple Code:

    this.stop();

    function closeIt(event:MouseEvent):void
    {
    this.play();
    }

    closeItButton_btn.addEventListener(MouseEvent.CLIC K, closeIt);

    My problem: when the button is clicked it just starts the button over again.

    How do I access the main timeline?

  2. #2
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    here's a start
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Feb 2009
    Posts
    5
    Thanks for the post and fla. I understand the way to do it via static-graphic buttons. Which is what your fla covers.

    But, m problem is, when I add a movie clip as the UP state of the button, when the button is clicked it passes the "play()" to the up state of the movie clip instead passing the play() to the main timeline. So, the button essentially does nothing.

  4. #4
    lolligator
    Join Date
    Jan 2008
    Location
    Canada
    Posts
    8
    Mkay, I did some research quickly and dug up this:
    http://www.kongregate.com/forums/4/topics/3935
    It seems to be a similar sort of problem to what we're discussing here.

    I'm an AS3 nub(an AS nub in general, actually) as well, so what I say should probably be disregarded, but if you simply want to pass play() to the main timeline, wouldn't it be as simple as changing "this" to "root" in this.play()? So, root.play()?
    Not sure if people frown upon that, though...or if it even works for that matter.

  5. #5
    Senior Member
    Join Date
    Jan 2007
    Location
    Nottingham, England
    Posts
    263
    is there any reason your using button symbol? ( for a button as daft as that sounds...)

    i have used the button symbol in donkeys years - i've always using a movieclip as my button

    the mc your adding in the over state of the button - is it for anything other than a role-over effect?

  6. #6
    Junior Member
    Join Date
    Feb 2009
    Posts
    5
    Haha!! Actually, there is no over state. It's just an animated button.

    So, I just use the movieclip as the button. Presto! It works.

    @inquizard Thanks a bunch.

    Here's the very simple code.

    // start code

    this.stop();

    function closeIt(event:MouseEvent):void
    {
    MovieClip(root).play();
    }

    closeItButton_mc.addEventListener(MouseEvent.CLICK , closeIt);
    closeItButton_mc.mouseEnabled = true;
    closeItButton_mc.buttonMode = true;

    // end code

    Question: is there a way to group the action script with the movieclip so that when I place the movieclip/button I don't have add:
    // code
    closeItButton_mc.addEventListener(MouseEvent.CLICK , closeIt);
    closeItButton_mc.mouseEnabled = true;
    closeItButton_mc.buttonMode = true;
    // code

    to my "actions" actions layer each time? Something like a "persistent listener"?

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