dcsimg
A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: loadMovie and variables...

  1. #1
    Member
    Join Date
    Feb 2005
    Posts
    31

    loadMovie and variables...

    ok, forgive the lack of syntax...I am a drawer, not a coder =)

    I have 50 frames of animation on the timeline...on each frame I need a keyframe that says something to the effect of:

    var1=pic1


    then, on keyframe two, it would need to say var1=pic2 and so on and so forth on each of the 50 frames.


    I want to have a single action frame that then says something to the effect of:

    if var1=pic1, then:
    mainpic.loadMovie("/images/gallery1/pic1.jpg");
    loadVariables("/images/gallery1/text/info1.txt","_level0.gallery1");

    if var1=pic2, then:
    mainpic.loadMovie("/images/gallery1/pic2.jpg");
    loadVariables("/images/gallery1/text/info2.txt","_level0.gallery1");

    if var1=pic3, then:
    mainpic.loadMovie("/images/gallery1/pic3.jpg");
    loadVariables("/images/gallery1/text/info3.txt","_level0.gallery1");

    and so on till we cover all 50 variables (and their respective pic and text info)

    Help...please?

    Many thanks in advance!

  2. #2
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    Well that seems like it's lot of messy code. How is this thing supposed to work? When does the frames change and what makes it goto another frame?

    Where are the if-staments located?

    /Mirandir

  3. #3
    Member
    Join Date
    Feb 2005
    Posts
    31
    the frame changes on a button click which tells it to goto (1-50) and stop, or from the next/previous buttons which use the nextframe and previous frame.

    I need it to be flexible like this because I ned to use it in different sites and for many galleries.

    if statements need to be on a keyframe of the timeline

  4. #4
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    Well don't use keyframes. Just set the variable directly on the button.

    Or even better and if possible put the load actions directly on the button. That way you can alter it whitout needing to change code att a dozen places. That assumes that the movieclip you wish toload the picture into is available on stage when button is being pressed.

    To make this simple and automated you can give each button an instancename. In the following fashion:

    btn1
    btn2
    btn3
    ... [cut] ...
    btn50


    Then on the first frame with the buttons put this code:
    Code:
    var counter = 1;
    var tmp = null;
    while(tmp = this["btn" + counter])
    {
        tmp.num = counter;
        tmp.onRelease = function()
        {  
            mainpic.loadMovie("/images/gallery1/pic" + this.num + ".jpg");
            loadVariables("/images/gallery1/text/info" + this.num + ".txt","_level0.gallery1");
        }
        counter ++;
    }

    /Mirandir

  5. #5
    Member
    Join Date
    Feb 2005
    Posts
    31
    thanks for the help!

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