A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: ahh help please with Functions

  1. #1
    Junior Member
    Join Date
    Nov 2001
    Posts
    4
    hello:

    Is it that difficult to call a function? Ok here goes, I have a movie clip that has a loadmovie(url) like this:
    function mySong(){
    loadmovie("/whatever.swf",_root.movieclipName);mySound = new Sound(); mySound.attachSound(whateversong);mySound.start. Ok thats the movieclip code I add the movie clip to my main stage and I have a button that I want to call the function...how can I do that Help please...thanks in advance

  2. #2
    Senior Member
    Join Date
    Nov 2001
    Posts
    254
    all you have to do is call the function by adding the code to the button

    on (release) {
    mySong();
    }

    make sure that the function is played or passed (in a frame before you call it)

    that should play your song also make sure you put the ./ int the "./whatever.swf"


    hope this helps

    you can also save your function in a *.as file by copying and pasting the code in notepad and saving it as filename.as under *allfiles option

    then in the first timeline of the movie put

    #include "filename.as"

    cheers,
    jimi mudgett

  3. #3
    Junior Member
    Join Date
    Nov 2001
    Posts
    4

    I did that still nothng my friend

    I have the movie clip with the code that you seen...now in the main timeline I have on a button on(release){ myFunction();} it doesn't play...do I need a parameter or agurment in my function?

  4. #4
    Senior Member
    Join Date
    Nov 2001
    Posts
    254
    if the movie clip that you are loading with sound is just a blank clip with sound then all you have to do is make a function like this ---

    function mysound(){
    loadMovie("./sound.swf","movieclip");
    }

    make sure you have sound.swf in the same directory as your main movie. and movieclip can just be a blank movie clip somewere on the same level. just call it by using mysound();

    you do not need a parameter unles you wanted to be able to choose different sounds to play and make your function more reusable you could do this---

    function mysound(sound) {
    loadMovie(sound,"movieclip");
    }

    then to call it you would use

    mysound("./filename");

    hope this helps

    If you need additional help on this topic email me at preston_m_us@yahoo.com i will put an example together and email it back to you if you email me.


    cheers,
    jimi mudgett


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