Replay SWF on Mouseover
A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: Replay SWF on Mouseover

  1. #1
    Junior Member
    Join Date
    Feb 2008
    Posts
    4

    Question Replay SWF on Mouseover

    I've been thrown onto a project in full force with no time to learn the program or any scripting. I do not know about buttons, or movies, etc. I just have a file for a banner ad I created with multiple animated layers that I published to a swf. I was able to find a action script for playing the swf 3 times before stopping on the last frame because I do not want to bug people with an animation playing over and over again. I do however want to play the animation on mouseover (as well as go to url on click, but I think that is done through html from the page hosting the banner, please correct me if I am wrong).

    I am having a hard time finding a script to play the swf on mouseover. If possible, I would like it to play once rather than 3 times on mouse over, but with the time frame I have, I will not be picky. Whatever you can offer would be great.

    Thank you in advance for your time on this, I really appreciate it!

  2. #2
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    ... What can I say, a really wise start... I'm just curious, what are you exactly waiting for ? For a complete file, for someone who would create this for you for free ? I'm asking this because you said that you have "no time to learn the program or any scripting", since you have no idea about what Flash is and you are not even willing to spend some time on learning it, would our advices actually matter ?

    A friendly advice, post this in the Freelance Forum instead.
    I'm sure that you'll find someone willing to do this for you, maybe even for free.

    Good luck.

    EDIT: I didn't want to seem a jerk, I'm just amazed by your totally ignorant attitude.
    Regarding you problem, here's a fast explanation, although I'm really not sure if you'll be able to do anything with it: you could create an event listener that would listen for a mouse over event. I'm not sure if you can associate that listener to the stage ( although you should be able to ) but if not, then create an invisible movie clip, that is the same width and height as your stage. Once you have the listener up and working, you only have to tell flash to play the movie from frame 1. something like this.gotoAndPlay(1); you should have a variable that will hold the number of play times. you must increment this variable each time your movie ends ( or once the user rolls over it, it's your choice to set this ). Have a condition inside your stage event listener that says that once your variable reaches 3 it should stop the movie at the last frame and don't rewind.

    It's nothing complex or hard, but since you have no idea what you are doing, I can only hope that you'll manage somehow.

    Good luck.
    Last edited by fx.barrett; 02-21-2008 at 02:54 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  3. #3
    Junior Member
    Join Date
    Feb 2008
    Posts
    4
    Thanks.

    I want to clarify thats its not that I don't want to learn, its that the head of the PR department here told the local paper site admins where the ad is going to be placed that he will have this by tomorrow morning. It is already 3:15 pm here, so I am pressed for time. Searching/trying to learn/figuring it out on my own so far hasn't been productive, I have spent many hours on this over the past few days with no luck. I figured that play on mouseover is probably a simple script, like the play 3 times script I was able to find online in a pinch. I just didn't know where to find it and figured that some folks who have some experience with this would know where to find it or how to do it. From what I recall, lots of ads have this feature, so I thought it might be something very simple like the loop.
    Last edited by nik183; 02-21-2008 at 03:23 PM.

  4. #4
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    are you guys using Actionscript 3 for sure, because this is an AS3 forum and since you don't know scripting I'm just curious?

    I can tell you how to do it in AS3 if you want, in fact, this should get you started:

    Code:
    import flash.events.MouseEvent;
    YOUR_BANNER_MOVIECLIP_NAME_HERE.addEventListener(MouseEvent.ROLL_OVER, playClip);
    
    function playClip(e:MouseEvent):void {
       e.target.gotoAndPlay(1);
    }
    that code should start the movieclip over everytime it's rolled over, which is I think what you want...just make sure your clip is named in the instance name field and that it matches in the above code.

    PS: just remember me in your will, haha!

  5. #5
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    ^ yeah, great, you're quite off track...

    1) you don't have to import the MouseEvent class inside the Flash IDE ; so, using "import flash.events.MouseEvent;" is senseless

    2) you are not doing what he is trying to achieve... in order to listen for "stage mouse over" you'll need a movie clip that has the height = stage.stageHeight; and width of stage.stageWidth; and listen to that movie clip and play the stage and not the movie clip you are listening too...

    3) do not use dynamic tracking ( "e.target" ) when it's not needed because it will only slow down your application.
    Last edited by fx.barrett; 02-21-2008 at 05:18 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  6. #6
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    you're quite chippy, arent' you?

    actually, that code was an elaborate ploy to force your hand into helping, and as you can see, I've achieved my goal!

    1) how do I know where his code is located, he could have this in a class/package for all I know?

    2) where does he state he's detecting for a stage mouse over event, as opposed to a movie clip mouse over event? didn't see that?

    3) I'm curious, can you explain what effect that has? never heard about that? what difference does it make...wouldn't assigning it to another variable before using it just be an alias for "e.target"? what is your alternative?

  7. #7
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    ) how do I know where his code is located, he could have this in a class/package for all I know?
    If that was the case then you would have had an error because you didn't use an access-control modifier when you declared your function as simply "function". We all make mistakes, but few admit they do...

    2) where does he state he's detecting for a stage mouse over event, as opposed to a movie clip mouse over event? didn't see that?
    Hmm, quite true, but where does he say he is not ? The thread title says this: "Replay SWF on Mouseover" ... one mouse over what ? And well, sorry, I might be wrong, maybe because of my English but after reading his post, that's what I understood... Maybe if he would explain it more exactly so that people like me can understand too would really help a lot...

    3) I'm curious, can you explain what effect that has? never heard about that? what difference does it make...wouldn't assigning it to another variable before using it just be an alias for "e.target"? what is your alternative?
    If I'll find my link, I'll post them, I would find it a bit hard to explain everything that is involved in the process in a short thread and I'm not really in the mood of writing a really long thread now...
    Last edited by fx.barrett; 02-21-2008 at 05:39 PM.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  8. #8
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    Quote Originally Posted by PlenaryCreation
    If that was the case then you would have had an error because you didn't use an access-control modifier when you declared your function as simply "function". We all make mistakes, but few admit they do...
    nit-picker!




    Quote Originally Posted by PlenaryCreation
    If I'll find my link, I'll post them, I would find it a bit hard to explain everything that is involved in the process in a short thread and I'm not really in the mood of writing a really long thread now...
    that would be good! of course, you don't seem like you're in the mood to do much of anything right now, except nit-pick =)

    bottom-line:
    the code above does work if you're just trying to detect a mouse over for your banner MC and restart it's animation...it might not be to some's optimization liking, but oh well. I am curious to see the explanation on that though.

  9. #9
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    the code above does work if you're just trying to detect a mouse over for your banner MC and restart it's animation...it might not be to some's optimization liking, but oh well. I am curious to see the explanation on that though.
    To correct you a bit... since nik183 is new to this, I'm 99% sure that he did use a container to store all the stuff that he has in the banner... meaning that he has multiple movie clips on the stage and if that's the case then your code is just partially good. Why ? Because although you could assign the same hander to all of the movie clips on the stage manually, I wouldn't consider that as an efficient solution and it would really be a "brute solution".

    Posting the file or explaining how the whole thing is built and what should exactly be done would really be of great help. Can't really say more until I don't have a clear understanding of the problem.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


  10. #10
    absolutezero3424
    Join Date
    Nov 2006
    Posts
    508
    you're right, unless we know the structure, we can give full specifics...

  11. #11
    Junior Member
    Join Date
    Feb 2008
    Posts
    4
    Thanks so much! I was able to figure it out between your help and this wonderful tutorial which explained a lot:
    http://www.lukamaras.com/tutorials/b...rs-basics.html

    I really appreciate all your help and I am so happy I was able to get this working!

  12. #12
    Junior Member
    Join Date
    Feb 2008
    Posts
    4
    For anyone who may be interested in knowing what I did, I followed the tutorial for creating the invisible button, and in addition to the getURL code, I added

    on (rollOut) {
    gotoAndPlay(1);
    }

  13. #13
    trace("AKA: Biro Barna");
    Join Date
    Oct 2007
    Location
    RO.Timişoara
    Posts
    1,403
    Great to know you figured it out. Just don't forget that your code is AS 2.0 ; in AS 3.0 it would look totally differently and you won't be able to add code right onto the movie clip but only on frames ( as an advice, try never to place code on your objects... place code only on frames, it will be much more organized that way and it will be easier for you to find things once you need to edit a certain behavior ).

    Cheers.



    | Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro |
    WebLog: http://blog.wisebisoft.com/ |
    | Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
    |
    Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/
    | By perseverance the snail reached the ark. |


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

Poll by Flashkit.com