Solved

How do I show a "visited" link in Flash?

Posted on 2002-07-01
25
397 Views
Last Modified: 2008-01-16
I have a software demo movie with a 10 item index page (text converted to Symbols) and a corresponding number of scenes where I would like the index to indicate which scene(s) the viewer has already looked at.

It could be either through changed font colour or, more elegant(?), with tick boxes showing the visited index items.

The movie is set up to automatically revert back to the index after a scene has played to the end but the viewer can view the items in any order he/she wishes.

I do not want to mix my movie with an HTML index page which (I think) would have been a simple solution to the problem.

The answer should (preferably) work both on the Internet and on a demo CD.
0
Comment
Question by:viggo_g
  • 11
  • 8
  • 4
  • +1
25 Comments
 
LVL 23

Expert Comment

by:Zeffer
ID: 7123126
assuming that you already have an empty box for checking next to each item you could do the following..

insert a new movie symbol..call it..tick

in frame 1 put a stop action.

in frame 2 put a tick..also a stop action

drag an instance from the library and place it in the
check box..(if you want help with positioning, copy and
paste the tick from frame 2 into frame 1..when all the
instances of the movie are positioned..remove the tick from
frame 1. You won't need to do this if the tick is the
right size and it is centered on the cross-hair on the
movie stage..as in authoring the movie instance is represented by a small circle )

in the instance panel..give this instance the name.. a

select the button on the menu that corresponds to this
check box..add the code..

on (release){
  with (_root.a){
  gotoAndStop (2);
 }
}

give instance names..b,c,d,e,f..etc to each new instance
and repeat.

on clicking a menu item ..the 'tick' movie advances one frame and the tick appears.


Z






0
 

Author Comment

by:viggo_g
ID: 7123259
What will happen to a tick when the movie comes back from another scene and replays the index page again???
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7123419
I just tried it ..and you're right..the tick is not
persistent..dang
back to drawing board..

Z
0
 

Expert Comment

by:Priestex
ID: 7126388
Ok, heres what I figure your question is:
You have a list of links that each point to a movie.
When you click on a link the respective movie plays and when it ends, you go back to the links page. Right?
What we are trying to do here is mark the visited links without using some HTML.

If what I have understood of the question is right then I think you should do the following:

A very obvious solution will ofcourse be to use different frames instead of one for the index page.
I mean use one index page where all links show unvisited. And then insert different frames at the end of each movie showing that movie as visited. This way you can add whatever fancy graphic efects you want to show the visited links.
You will have to make the animation go to the respective index pages instead of the same index page now(obviously).  
This will no doubt increase the movie size but its the easiest way out.

All the best
Priestex
0
 

Author Comment

by:viggo_g
ID: 7126448
Hi Priestex,

I see what you mean and had thought about a similar thing. The only thing is that I would have to have a great number of frames to cover all the options that a random combination of visited links can offer. I also don't know how I would make the movie load the frame that shows for instance that items 1, 5, 6 and 9 have been visited and then, after visiting item 3, go to the index frame showing that 1,3,5,6 and 9 have been visited and so on...
0
 

Expert Comment

by:Priestex
ID: 7126554
Ok, yeah I know what you mean, I forgot to take into account the permuatations possible.

Heres what I now suggest:

You could try to define onclick events for the index frame.
I am sure you already have one event getting triggered by the click of a link i.e the loading of the respective movie.
Another thing you could do is to convert the links (which are already symbols) into buttons.Edit the button and change the frame corresponding to "down" and make the button look like you want your visited link to look.

I think this should solve your problem.

-Priestex
0
 

Author Comment

by:viggo_g
ID: 7126644
Don't know if I have got you right but i don't think there is any way of making the Down State permanent, i.e. the next time the Index scene is played, all of the "buttons" will start from the Up Stage again.
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7126647
like my suggestion..this is all lost when the scene is re-loaded..what is needed is a global variable(a global variable can be referenced by any movie, in any scene).. that holds the scenes played ..(the value(s) in the variable) and displays the changed values (in a movie)..in the menu..

don't ask me for the code I'm still learning..

Z

0
 

Author Comment

by:viggo_g
ID: 7126956
I know the feeling - so am I... :)
0
 

Expert Comment

by:strudejbob
ID: 7127741
Hi viggo,

i mostly read all of the possible solutions and I right away i had the answer i will propose.  It obviously may not work but lets see.

This can all be done in one frame.

For each button or text, i assume you dupicated the movie clips or if not have a variable ie. visistedLink for each movie clip.  Initially set to false.  When the button is pressed set the value to true before redirecting the user.  Have a condition statement,

if _root.movieClipButton.visitedLink = true {
     //call a different button that looks clicked OR
     //change colour of text!
}

to change colour in this case orange (set rgb in last line to any colour):
**********************************************************
var orange = new Color(_root.documentMC.skillsMC.skillsDocMC.skillsTxtBar2MC);
     var colorTrans = new Object();
     orange.setRGB(0xff9900);
**********************************************************

The first time through it will draw it normally the next time it will looked modified!

Hope this helps!

0
 

Expert Comment

by:strudejbob
ID: 7127745
oops!

Ignore what is in the brackets of new Color()

_root.buttonMovieClip.theTextMC  <-----better

oh yeah, to do that make sure the text is a movie clip on its own inside the buttonMovieClip
0
 

Author Comment

by:viggo_g
ID: 7129836
I'm sure you know what you are talking about but this goes quite a bit over my head. Are you suggesting that the text which is now a button should be made into a movie clip instead? I need quite a bit more detailed instructions to have any chance to do this.

Say I have a scene called "Index page" and in that scene I have text saved as a button (named "basecase") with blue text as Up State and red text for Over State. The following action is attached to that button:
On (release) {
go toAndPlay ("build basecase", 1);
}

If I wanted (upon return to the Index page) to show the same text in grey colour as a button called "basecase_grey", what would the whole code look like for that and where should the code be put in relation to the existing code?

Sorry to be so slow to take this up...
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Expert Comment

by:strudejbob
ID: 7130560
Sorry dude, i do not explain myself well.

Keep the button as a button. But put the button in a movieClip.  

_root.but1MovieClip.textButton - make sense?

to make it easier put a new colour of text button on frame 2.

code on movieClip:

**********************************

onClipEvent(enterFrame) {
   if this.visited = true {
       goToAndStop(frame 2) <-- i do not know the code exactly
   }else{
       goToAndStop(frame 1)
   }
}
**********************************


code on button:
**********************************
on (release) {
   _parent.visited = true
   //plus your other code
}
**********************************


Code on first frame:
**********************************
_root.but1MovieClip.visited = false
//repeat for all buttons
**********************************

This should help!

Herb

0
 

Author Comment

by:viggo_g
ID: 7132070
Herb,

I did give it a try with one index item only and encountered the following error messages.

***************************************************
Scene=Index page, Layer=index, Frame=15: Line 2: '(' expected
          if this.visited = true {

Scene=Index page, Layer=index, Frame=15: Line 3: ')' or ',' expected
               goToAndStop(frame 2)

Scene=Index page, Layer=index, Frame=15: Line 4: 'else' encountered without matching 'if'
          }else{

Scene=Index page, Layer=index, Frame=15: Line 5: ')' or ',' expected
               goToAndStop(frame 1)

Scene=Index page, Layer=index, Frame=15: Line 4: Statement must appear within onClipEvent handler
          }else{

Scene=Index page, Layer=index, Frame=15: Line 6: Unexpected '}' encountered
          }
**************************************

Have you tried the code yourself? Being a novice in action scripting, It may just be my fault for not applying it correctly. Would have been so much easier if it was possible to send the whole solution, like in html or asp.

Sorry, but even if your answer may be workable, I am going to reject it to unlock the question for more Comments. I have doubled the points so if you still feel you have the answer, come back again but please submit it as a Comment unless you are 100% sure it works.
0
 

Expert Comment

by:strudejbob
ID: 7132891
well. do not cut and paste!
it is elaborate pseudo code!  

First off to compare in actionScript oyu use ==, and surround it with brackets!  I had know idea you were gonna cut and paste my answer


more like this!

******************************************
onClipEvent(enterFrame) {
  if (this.visited == true) {
      goToAndStop(frame 2) <-- i do not know the code exactly
  }else{
      goToAndStop(frame 1)
  }
}


0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7134368
Here is an accepted answer from a previously asked question on the same subject..The .fla file he mentions is still available from his site.

......................

From: jeffbeasley  Date: 07/03/2001 11:38AM PST
 
I created an example file for you name...visited_link.fla

http://www.jeffbeasley.com/downloads

noted below

Scene1 : Frame 1
button1 = 1;
button2 = 0;
button3 = 0;
color_change();
function color_change () {
   if (button1 == 1) {
        var button_color = new Color(_root.mc1);
        button_color.setRGB(0x999999);
   }
   if (button2 == 1) {
        var button_color = new Color(_root.mc2);
        button_color.setRGB(0x999999);
   }
   if (button3 == 1) {
        var button_color = new Color(_root.mc3);
        button_color.setRGB(0x999999);
   }
}

buttons where as "scene3" is your scene and "button3" is scene 3's button variable
on (press, release) {
   gotoAndPlay ("scene3", 1);
   _root.button3 = 1;
}

Scene 2 : Frame 1
_root.button2=1;
color_change();

Scene 3 : Frame 1
_root.button3=1;
color_change();

...........................

This should do what you want:)

Z

 


0
 

Author Comment

by:viggo_g
ID: 7156512
Sorry guys - have been away for some days.

Zeffer - the code you are referring to works fine if the buttons are a "permanent feature" of the scene but if you jump to another scene (without these buttons) and then back again, the buttons will reload and start from Frame 1 again, right?
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7156816
hmmm...yes right.

I have modified that .fla so that the scenes run and then return to scene 1..and the clicked buttons change and stay changed.
Do this..

in scene 1..delete button 1

in scene 2..delete all the buttons..
delete the actionscript in frame 1
put a keyframe in 25 (to simulate the running of your scene.
in that keyframe put the script..
...........
gotoAndPlay ("scene1", 2);
color_change();
button2=1;
............
hit F6 in layer 4, frame 25..so you can see the text.. scene 2.

in scene 3..
repeat the above but change the script to..
...............
gotoAndPlay ("scene1", 2);
color_change();
button3=1;
.............

test..

button 1 does not need to be declared in the variable..(scene 1 frame 1)..as you are auto-returning each time to scene 1.

ps ..damn pleased with myself :)

Z
0
 

Author Comment

by:viggo_g
ID: 7157521
Zeffer,
I think we are getting close. Just me being clumsy with the coding again I suppose. Have tried to apply it the way you suggested and got the following error message (the same for all 10 of my menu items but am only showing 1 to save space:
Scene=Index page, Layer=ACTIONS, Frame=1: Line 1: Left side of assignment operator must be variable or property.
     btn-build-base-case = 0;
The code in frame 1 reads:
btn-build-base-case = 0;
btn-prod-profile = 0;
btn-chemical-dosing-rate = 0;
btn-manage-deferments = 0;
btn-build-business-plan = 0;
btn-build-asset-model = 0;
btn-import-from-SAP = 0;
btn-develop-OPEX-model = 0;
btn-assess-additional-income = 0;
btn-compare-base-case = 0;
color_change();
function color_change () {
     if (btn-build-base-case == 1) {
          var btn-build-base-case_color = new Color(_root.mc-build-base-case);
          btn-build-base-case_color.setRGB(0x999999);
     }
     if (btn-prod-profile == 1) {
          var button_color = new Color(_root.mc-prod-profile);
          button_color.setRGB(0x999999);
     }
     if (btn-chemical-dosing-rate == 1) {
          var button_color = new Color(_root.mc-chemical-dosing-rate);
          button_color.setRGB(0x999999);
     }
     if (btn-manage-deferments == 1) {
          var button_color = new Color(_root.mc-manage-deferments);
          button_color.setRGB(0x999999);
If you look at the first instance after "function color_change" you will find that I have changed the "button_color" to the actual name of the button as I thought that might be the problem but it didn't make any difference.
Hence my question, is button a reserved word that has to be used for naming buttons or is there another problem?

The code that you have in frame2 in your example is in frame15 in my code, with some text and images "sliding in" in between. Does that matter? I got another 10 error messages for frame15 as follows:
Scene=Index page, Layer=buttons, Frame=15: Line 3: Left side of assignment operator must be variable or property.
          _root.btn-compare-base-case = 1;
The code in frame15 for the first button is as follows:
on (release) {
     gotoAndPlay ("build basecase", 1);
     _root.btn-build-base-case = 1;
}

Hope that you can find an easy answer to these problems.

Viggo
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7158043
The fundamental problem you have with your code is the ..-..in your names..use _  (an underscore)..

Q1..the 'buttons' here are actually movie clips so they can be referenced by the variable.

Q2..the text and images won't affect the code running but you will have to target frame 15 not 2..to get the color change.

easiest way now is for you to download the .fla and a .swf showing you what I have done...and you can apply the principle (with minor changes )..to your movie.

www.redpearl.co.nz/misc/links.zip

Z
0
 

Author Comment

by:viggo_g
ID: 7159270
Zeffer,
1) Thanks for the info regarding using underscores. That made all the difference to the error messages.
2) By the way, I was looking for a "search/replace" function in Flash but couldn't find one. Is there a hidden one or does it not exist. Did take a lot of time to change from - to _ so it would have been handy.
3) Unfortunately, although the menu now works, it does not change colour when returning and I think I have been targetting the right frame (15) but might have done it the wrong way. Could you please have a look at the file  (http://www.touchstone-it.com/download/test.zip). Resources are only included for the 4 menu items marked with a red dot. Can you please tell me where I have gone wrong and/or amend the file and make it available for download again. This should (hopefully) be the last thing you have to do for a lousy 200 points.
4) Do you never sleep? I seem to get replies from you at all times of day and night. NZ must be a few time zones away from the UK.

Best regards,
Viggo
0
 
LVL 23

Expert Comment

by:Zeffer
ID: 7168383
bit slow replying..been out of the loop..
www.redpearl.co.nz/misc/links2.zip

Z
0
 

Author Comment

by:viggo_g
ID: 7169822
Zeffer, thanks for the sample. It works wonderfully in the abbreviated test version, also when I added the scenes you removed for file size reasons - however...
The code:
----------------------
with (_root) {
     gotoAndStop(50);
}
color_change();
btn_prod_profile = 1;
----------------------
seems to make the movie go back to the first scene of the movie, i.e. when the Index Page scene is the first one, it works well, but when I add the rest of the movie (which has two scenes before the Index Page) it seems to go to the new scene number one.
How can I change the "_root" to point to the correct scene???
Have tried with the following variations:
1) "_Index page"
2) "_root.Index page"
3) "_root.Index_page" (after renaming the scene Index_page)
Various error messages was the result of above trials.

What's next???
0
 
LVL 23

Accepted Solution

by:
Zeffer earned 200 total points
ID: 7171608
replace..

with (_root) {
    gotoAndStop(50);

with....

gotoAndPlay("Index page", 50);

Z
0
 

Author Comment

by:viggo_g
ID: 7172461
Thanks to you all, i.e. Zeffer, Priestex and Strudejbob for all your efforts and, above all, your patience.

First (and only) prize goes to Zeffer for his excellent solution which, after a while, sunk into my thick skull and now works beautifully.

Cheers,

Viggo
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now