A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: presentation random slide

  1. #1

    presentation random slide

    Hi-

    im using the rpesentatin feature in flash 8 to make visuals to be shown on a laptop. it should be quite easy, ive numbered each slide 1-10 and want it to jump to a random one when the mouse is clicked. it seemed simple but just won't work.

    Code:
    o
    
    onClipEvent (mouseDown){
    	i=Math.ceil(Math.random()*10);
    	_parent.currentSlide.gotoSlide(i);
    	trace(i);
    }
    the trace comes up fine with the random numbers between 1 and 10 but the slide won't change.
    can anyone see where im going wrong or suggest a better way to do this?

    cheers
    [swf width="300" height="40" background="#CCCCCC"]http://www.geocities.com/n_gahagan/footer.swf[/swf]

  2. #2
    Secret Agent
    Join Date
    Sep 2000
    Location
    San Francisco, CA
    Posts
    169
    Maybe it's the "o" at the beginning. Just kidding.

    Perhaps there is a more elegant way of doing this, but I've found it's easier to call things by name than to figure out where they are in the heirarchy.

    Try this:

    Code:
    onClipEvent (mouseDown) {
    	i = Math.ceil (Math.random () * 10);
    	// you need the full name and path of the slide here
    	random_slide = "_root.presentation.slide" + i;
    	// where presentation is the name of the root slide
    	_parent.gotoSlide (eval(random_slide));
    	trace (i);
    	trace (random_slide);
    	trace (_root.presentation.currentSlide);
    }
    Enjoy,
    aldorr

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