A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Movieclip.gotoAndPlay

  1. #1
    Member
    Join Date
    Sep 2005
    Posts
    50

    Movieclip.gotoAndPlay

    Hi,

    I have a number of buttons which are inside an mc called img and am using this code (thanks NTD) in the main timeline to determine the instance name of the button which is pressed.

    Button.prototype.onRelease=function(){
    country = this._name
    countryname="img."+country
    nextFrame()
    }

    this all works fine.

    However in the nextframe i convert the buttons into a movieclips and then depending on which button is pressed the corresponding movieclip needs to play.

    When i use the code:

    countryname.gotoAndPlay(2)

    in this second frame on the maintime line, nothing happens, the movie remains stopped at the first frame.

    When i trace countryname i get (eg) "img.England" and if i edit the code so that it just says img.England.gotoAndPlay(2) it all works fine.

    Can some one explain why this is and how i can solve it. I've been searching for hours and this is really starting to bug me!
    cheers

  2. #2
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    well, i would guess that it works when you use img.England.gotoAndPlay(2) because you are targeting the mc correctly. The Button.prototype creates a reference for countryname. But then you are trying to use that name for a MovieClip. You can't do that. A MovieClip and Button are different types of symbols. And you can't tell a button to gotoAndPlay()

    I'd need to take a look at your file to tell you any more.. i'm not quite sure what you're doing...
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  3. #3
    Member
    Join Date
    Sep 2005
    Posts
    50
    Here's the .fla, thanks for the help
    Attached Files Attached Files

  4. #4
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    WEll... i made a lot of changes... everything is movieclips now, the tooltip is created dynamically. The countries fade into and out of their 'over' or 'selected' state. A large portion of the country mc's still need to set up properly... I only changed a few. Just edit the keyframe structure of the remaining mcs to match one of the completed mcs. I commented the code as well....

    your 'engine' mc's code could use some updating and refining... the syntax is old, it's not formatted well... and it's unnecessarily taxing to the player/processor which effects the performance. I just didn't have time to get into that....

    hope this helps.
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

  5. #5
    Member
    Join Date
    Sep 2005
    Posts
    50
    Wow. That is actually brilliant. Thanks so much for your help. Am a bit of a beginner at flash, and thought i was getting the hang of it but now i see there is a lot more i need to learn!

    Thanks again madzigian.
    John

  6. #6
    Can't Re-Member madzigian's Avatar
    Join Date
    Apr 2004
    Location
    Boston MA
    Posts
    2,662
    LOL.. there's always more to learn!!! I learned a few things while i was working on your file! I often find that the way i think something may work is different than what actually needs to be done. Flash gets confusing sometimes (at least for me) because there are at least 3 different ways to accomplish the same exact thing. Hopefully you understand what's going on in the code i wrote you.

    As i mentioned.. you should really update/rewrite that code for the "engine" mc you have.... for example, use of the word 'and' was deprecated in favor of using '&&'... as well as many more changes.. for example 'setProperty'... you can just use my_mc._x = 60;, my_mc._height = 90; etc...

    let me know if you need any more help....
    Please DO NOT PM me simply for individual help. Post in the public forums...that's what they are for, and they allow others to benefit as well. - Thx
    OS X 10.3.9 || Flash MX04 Pro
    | del.icio.us || furl || Helpful Source Files || Free Pixel Fonts |

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