A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [CS3] AS2.0 Attachedmovie's buttons wont work

  1. #1
    Junior Member
    Join Date
    Oct 2008
    Posts
    12

    Question [CS3] AS2.0 Attachedmovie's buttons wont work

    Hello all!

    Newb with actionscript here.. and im having a problem with my attachmovie, I created an empty movie clip and inside there is an attached movie and there is a button, and it won't work..

    button works well if i test the scene where the button is, but when i test the main scene/movie it won't work.

    anyone help please?

    i also tried attaching the button.. but i can't position the button? it's suppose to jump to another movie clip? im trying to create a web page with purely actionscript.

    Code:
    container.attachMovie("btn1","btn1",1);
    btn1._x=250;
    btn1._y=250;
    Last edited by kerco; 10-15-2008 at 10:43 AM.

  2. #2
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    try:

    PHP Code:
    var b:MovieClip container.attachMovie("btn1","btn1",1);
    b._x=b._y=250
    Or you could write it

    PHP Code:
    container.attachMovie("btn1","btn1",1);
    container.btn1._x=250;
    container.btn1._y=250
    you're attaching btn1 inside of container, so you must reference it there from the timeline. That is why it is easier to create a new var like my first example and use that var to reference the attached button. then you could add the onPress
    PHP Code:
    v.onPress = function(){
    someOtherMC.gotoAndPlay(framenumber);

    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  3. #3
    Junior Member
    Join Date
    Oct 2008
    Posts
    12
    ok thanks a lot! that worked, but why won't the buttons work if i attach it with the said movie clip?

  4. #4
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    It works just fine when you attach it the way you did. You notice I attach it the same way. All I did was then assign the attachment to a new movieclip/object that I made right then. That is the var v:Movieclip = part. Then I can reference that v variable anytime within the scope and it will actually refer to container.btn1. And, your only problem was actually just not putting container in front of btn1. When you attached the clip you attached it inside of container, so the path of the button from where you are is container.btn1. If container was inside of another movieclip called tempMovie then the path would be tempMovie.container.btn1. Make sense?
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  5. #5
    Junior Member
    Join Date
    Oct 2008
    Posts
    12
    attaching the button was my second option..

    the first one was, just a single movieclip attached with the button inside that movie clip. but it wont work..

    Code:
    this.createEmptyMovieClip("container",1);
    container.attachMovie("page","page_mc",0);
    container.onEnterFrame = function (){...................
    and inside the page movie clip is the button, the button works ok when i test the "page", but it won't worked if the page was attached..?

  6. #6
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    I think it's where you have your code. I wish I knew of a good article that talks about paths. You might try searching for information of flash levels and paths. I'd put money on it that that is your problem.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  7. #7
    Junior Member
    Join Date
    Oct 2008
    Posts
    12
    ok thanks mneil..
    so it aint that easy to create a page that loads with a single container?
    i think i found it, but i dont think i can post links here?

    without paths your swf will stay in one place..
    Last edited by kerco; 10-16-2008 at 02:17 AM.

  8. #8
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    you can post links in here as long as they're not spam type links. If you see something you like and are trying to re-create then posting a link to it so we can see it and help is fine. Or, if you have something up and you need us to take a look you can post the link too. It isn't hard to do what you want, it just isn't as easy as you maybe thought it was.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  9. #9
    Junior Member
    Join Date
    Oct 2008
    Posts
    12
    ok after reading this article about paths..
    Code:
    http://www.actionscript.org/resources/articles/17/1/Paths-to-Objects-and-Variables/Page1.html
    i managed to make it work i gave a wrong path to the button itself..

    thanks a lot mneil really generous of you..

  10. #10
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    YES!!!! That's pretty much what I was trying to explain but it's hard to do without some examples. Most people struggle with this, if only for a bit, at some point in time. Glad you got it sorted
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

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