A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Can I target frame labels with a variable?

  1. #1
    I want to know if it's possible to target a Frame Label as the output of a variable in the gotoAndPlay(expression) action. I'm trying to do just that and having some dificulty. I want some feedback as to whether or not this might be my problem.

    I have five diferent target MCs which each have eight labeled frames in them ( A - H ). On comand I need to target one of those MCs to go to one of those Labeled frames. The frame to go to depends on Mouse Placement, And the labeled frames have a diferent placement in each MC so my target has to be a frame label reprsented by a variable. And the problem is that my MC's frame is not changing. I've checked my variable (that is inserted into the gotoAndPlay(expression) action) and it is changing it's value acordingly. My targets are good.

    I've done quite a bit of troubleshooting already and found that I am not even sure if what I'm trying to do is possible. I then read that the gotoAndPlay(expression) action wants to target frame numbers as opposed to labels. So now I want a second oppinion. How can I target frame labels with a variable?

  2. #2
    Senior Member
    Join Date
    Sep 2001


    Should work ok...



  3. #3

    Post still troubleshooting

    So I'm wondering if it's possible.

    You're saying it is and giving me the same code I'm using as an example of what works.

    Great I hope I know now that my problems are elsewhere.


    How does Flash know if you want to target a frame number or label with a variable that outputs as a number?

  4. #4
    Senior Member
    Join Date
    Sep 2001
    If you are still having problems, post some of your code.



  5. #5

    Code AND all

    I am trying to get a button that represents the view from a panorama (and acts to trigger it initially) to turn with the panorama. But it is not responding to the turn command. I think I've narrowed the problem to an issue with the gotoAndStop(expression) action at the end of my script. BUT I'm not sure. When I replaced it with a gotoAndStop(frame) and had my CurrentFrame variable generate it's output as a number. it still didn't work, so I must be overlooking something. (but I do need the gotoAndStop() to reference a relative frame label with a relative Target Path)

    This is code the from one of my Panorama SWFs
    // At this point an MC called "pano" is on this timeline it holds two identical panorama
    //strips. the second is necessary to cover the ends of the first.
    //The strips are labeled "strip" and "strip2"
    // Enter FOV as Degrees of View in Panorama
    FOV = 360;
    // LeftFace is a Number from 1 to 8.x
    // representing the Turning Animal's relationship
    // to the Left edge of the Panorama strip.
    // (counting clockwise from the back face)
    LeftFace = 7.5;
    //TurnRange calculates how many 45 faces the panorama has.
    TurnRange = FOV/45;
    //AnglePixels calculates the number of Pixels in each 45 face.
    AnglePixels = pano.strip._width / TurnRange;
    loadMovie ("BF_PanoDriver.swf", "Driver");
    stop ();

    This is the pertinent script from the SWF called PanoDriver
    // Turn Animal to one of eight steps Clockwise from Back. ( Back = 1 )
    //calculate frame position on one of two pano strips.(whichever is visible)
    //CurrentFace which face will be represented by the current position of the pano strip.
    if (_parent.pano.strip._x<0 or _parent.pano.strip._x>_parent.pano.strip._width) {
        CurrentFace = Math.ceil(Math.round(Math.abs(_parent.pano.strip._x /_parent.AnglePixels)) +_parent.LeftFace);
    } else {
        CurrentFace = Math.ceil(Math.round(Math.abs(_parent.pano.strip2._x /_parent.AnglePixels)) +_parent.LeftFace);
    //Limit the counting CurrentFace to a loop from 1 to TurnRange
    if (CurrentFace > _parent.TurnRange) {
        CurrentFace = CurrentFace - _parent.TurnRange;
    //convert the CurrentFace # to a leter  (A - H)to make sure my goto action
    //doesn't send it's info as a frame number.
    CurrentFace = String.fromCharCode( 64 + CurrentFace ); 
    //everything above this line works fine.
    //I've traced all the pertinent info and I'm sending the right values at the right times.
    //my variable _root.PanoPath (bellow) returns the right values.
    //I've tried using "gotoAndStop(CurrentFace)" as well as what you see here.
    tellTarget ([_root.PanoPath]+".CatTurning") {
        gotoAndStop ("\"" + CurrentFace + "\"");
    The target path to the button that triggers my Panorama is relative,so I use tellTarget() cause I don't know how to word it otherwise.(this has not bein a problem before but i'm never sure)

    My turning MC lies at the "hit" frame of an MC that acts as a button. the buttonMC gets to the proper frame and the turning MC ("CatTurning" in this case) has previously bein targeted successfully in this same manner.

    So, given all this info, and a link to the test site:

    I ask anyone to help me figure this out.

    [Edited by mani_sf on 07-15-2002 at 08:41 AM]

  6. #6
    Senior Member
    Join Date
    Sep 2001
    G'Day again,
    The URL you gave does not work.
    Also, might be easier if you are prepared to post the fla or send it to me via email.




  7. #7
    a little typing error. is fixed now.

    I'm not exactly sure where I would upload my fla to.

    But asside from getting into some details in the Main Interface FLA I've posted all the code related to this problem(as I see it), and the Main Interface FLA is 3.7 Mb I can't Upload that right now on this Dialup.

    But that's not a refusal, just a stall tactic.

    Thanks for the help Hilary.

    P.S. when you visit the site know that my TurningAnimal buttons will turn on there own UNTIL you move the Panorama with the mouse. Frome that moment on the Animal is supposed to follow the Panorama.

    P.P.S don't test the Dog. It doesn't stop turning when you start the Panorama. ??? ( same code, but obviously different somehow.)

    P.P.P.S I really dislike posting my problems because it forces my to take stock of just how many bugs I've let accumulate. And it's embarrassing to show an unfinished piece full of bugs.

  8. #8

    Found the solution !!!!!

    A member named Carlson Bull E-Mailed me saying he was having a similar problem. His problem included a syntax eror of having dots in his frame labels as well as the eror which I am (was) facing. Here's his second mail to me :

    Hey Manuel,

    Thanks for the response - I actually did hammer out a work around.

    I was trying to target labels in a movie clip that ran 1.1 to 4.6 using
    something like

    _root.Index_action.gotoAndStop(_root.Chapter_no+ "."+_root.Page_no);

    But was getting nowhere (similar to what you were trying right!?!)

    So I relabeled the frames with an "i_" in front of the numbers and rather
    than a "." used a "_" ( so the labels are now i_1_1 to i_4_6) and the
    expression now reads

    _root.Index_action.gotoAndStop("i_"+_root.Chapter_ no+ "_"+_root.Page_no);

    And this works like a charm - For some reason starting the expression/label
    with a quotes of some kind seems to get it back on the right track. A
    little counter intuitive but it works!

    Hope this helps!



    NOW THIS GOT ME THINKING and I tried two things.
    FIRST I put a character "_" in front of all my label names. THEN at the same time I preceded my variable in the gotoAndStop() action with "this." (example: gotoAndStop(this.CurrentFace))

    It WORKS !!!

    THEN just to see why, I did each of those changes one at a time. The second is the only one that made a diference.

    If you need to have a VARIABLE pointing to a FRAME LABEL in a goto comand precede it with the target to that variable !!!!

    I hope others can lern from this.
    feel free to mail me (anyone) for more details.


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