开发者

Flash action Script 3- Click to go to Webpage only execute once

开发者 https://www.devze.com 2023-03-30 03:18 出处:网络
I created a flash slideshow with pictures of events and link each picture with its own event (ie. each pictures has its own links to the website). I created the fade in and fade out effect using the c

I created a flash slideshow with pictures of events and link each picture with its own event (ie. each pictures has its own links to the website). I created the fade in and fade out effect using the class motion tween. With the link, I created a layer with a MovieClip butoon that has alpha= 0 (so the user don't see it) and then I used code snippet to make another layer with the action script "click to go to url."

When the slideshow goes to the last picture I made it fade out and the first picture of the slideshow would show up and then the slideshow would replay itself. My goal is to make a continuous slideshow.

When I tested the swf file, the first time it runs, everything is right. The urls and the pictures are in correct order. However when the slideshow replays itself automatically, I notice that the links are incorrect. In the first play, when I click the picture of the event it would open the url of that event. However when the sldieshow replays, clicking the pictures would only open the url of the first event picture.

To be more exact, I noticed that after the first loop, the file replays and whenever I click on an image it would automatically direct me to the last link in the timeline instead of directing me to the link pertains to that image.

I'm using flash CS5 and action script 3.0

The code i'm using is from Code Snippet

Link_btn.addEventListener(Mo开发者_StackOverflowuseEvent.CLICK, fl_ClickToGoToWebPage_15);

function fl_ClickToGoToWebPage_15(event:MouseEvent):void
{
    navigateToURL(new URLRequest("http://www.adobe.com"), "_blank");
}

It seems to me that the above code only execute once. I had done these kind of slideshow with AS 2 where I just simply put the gotoUrl code in the button itself. But AS3 makes everything so complicated!

Anyway I can make the click to go to URL code execute continuously (and endlessly) in AS3?

Thank you!


The way you are doing it is pretty horrible. (sorry) Create an array with the urls. Have a function in your class that looks for urlArray[pictureNo] and opens that. This is much simpler to maintain.

Use document class to add your pics to stage and give each their id and picture. Also set buttonMode to on so the cursor changes.

It may seem that this takes more time at first, but you will only need to add a element to a array tio add a picture.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号