A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Button inside a Movie Clip

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    4

    Button inside a Movie Clip

    Hi

    Ok, so i have a button inside a movie clip.

    I want the button, when i click it, to go to a web page in a new window.

    I have put my script on the top layer of the main timeline, in a layer called 'controls'

    Here is the script:

    Code:
    function openPhotomore(yourEvent:MouseEvent):void {
    navigateToURL(new URLRequest("http://anarkiuk.deviantart.com/gallery/#Photograph"),"_blank"); 
    };
    photomore_btn.addEventListener(MouseEvent.CLICK, openPhotomore);
    I have given the button an instance name of 'photomore_btn', but it seems to be inside a tween aswell?

    When running the swf i get the error:

    1120: Access of undefined property photomore_btn.

    I'm new to flash / im confused.

    How come it cant find the photomore_btn?

    Any help is greatly appreciated, thanks!

  2. #2
    Junior Member
    Join Date
    Sep 2008
    Posts
    4
    Anybody have a clue? I can supply the .fla file if needed.

  3. #3
    Designs Required ask BlymMedia
    Join Date
    Jan 2008
    Posts
    55

    re: Button inside a Movie Clip

    I created an invisible button inside a movieclip and used the code below which if clicked would take you to a web page in a new window


    URLVisions_but.addEventListener (MouseEvent.CLICK, URLVisions_butFunction);
    function URLVisions_butFunction(event: MouseEvent)
    {
    var request:URLRequest = new URLRequest("http://INSERT WEBSITE HERE");
    navigateToURL(request);
    }


    Can't promise this will work for you but give it a try and let me know.

    Alan

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Posts
    1
    I'm also having problems with a button (well, two buttons) inside a movie clip. I tried applying BlymMedia's solution, but it wouldn't work.

    Quick description: I'm making a Flash-site/movie/whatever with content in 2 languages. The user is presented with the language selection in the first frame.

    The first frame has a movie clip and inside it are two buttons for the languages.
    So: Main timeline --> language_select_mc --> english_btn AND finnish_btn

    I have this code inside the movie clip:

    this.finnish_btn.addEventListener(MouseEvent.CLICK , finnishListener);
    this.english_btn.addEventListener(MouseEvent.CLICK , englishListener);

    function finnishListener(event:MouseEvent):void {
    ...and so on.

    I'm getting error #1010: A term is undefined and has no properties. It refers to the movie clip, but doesn't give more specific info.

    I'm trying to make two things happen when either button is clicked:
    1) Modify a variable "lang" on the main timeline to have a corresponding string value (either "fin" or "eng")
    2) Continue playin the main timeline.

    Any help would be greatly appreciated.

    Does it matter if the code is in the movie clip or on the main timeline? I've tried both (modyfying where the code points to, obviously) but no luck. I think the problem stems from the functions... but what's wrong?

  5. #5
    Junior Member
    Join Date
    Sep 2008
    Posts
    4
    I just tried this but i still get the undefined error

    =(

  6. #6
    Junior Member
    Join Date
    Sep 2008
    Posts
    12
    Hi Its very silly problem(at least for me)
    just give the instance name to movieclip in which you have put your button and access that button with this name.... dont get confused I ll show you how to do it....
    Give an instance name to your movieclip as "btnHolder_mc" and now replace your code photomore_btn.addEventListener(MouseEvent.CLICK, openPhotomore); with btnHolder_mc.photomore_btn.addEventListener(MouseE vent.CLICK, openPhotomore);

  7. #7
    Junior Member
    Join Date
    Oct 2004
    Location
    Toronto
    Posts
    4
    Hi, I haven't practise Flash in a long time = a beginner. Please bare with me on a silly question, any help is much appreciated.

    I'm using Flash 8

    I have a similar problem but much simpler. I've created a pull down menu (created a movie clip, and have submenus created in it + rollout closer button). It works great.

    Problem is when i apply basic actionscript to the submenu buttons (on release/go to and stop/ 'scene' 'label name') and it doesn't work.

    Please help. I would be forever grateful.
    Thanks in advance,
    Chuston

  8. #8
    Senior Member
    Join Date
    Oct 2009
    Posts
    112
    Quote Originally Posted by vasu.kondapally View Post
    Hi Its very silly problem(at least for me)
    just give the instance name to movieclip in which you have put your button and access that button with this name.... dont get confused I ll show you how to do it....
    Give an instance name to your movieclip as "btnHolder_mc" and now replace your code photomore_btn.addEventListener(MouseEvent.CLICK, openPhotomore); with btnHolder_mc.photomore_btn.addEventListener(MouseE vent.CLICK, openPhotomore);
    i'm having this same problem and i think the point is to have TWO SEPARATE INSTANCE NAMES. one for the movie clip, and one for the button inside.
    i don't even know if this is possible. for me the button inside the moveie clip is invisible until you mouse-over.

    but i don't want the EventListener to be applied if you click anywhere on the movie clip, only on the area where the button is.
    has anyone found anything on this?

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