Solved

play movie event at click location cs3 flash

Posted on 2009-05-13
4
467 Views
Last Modified: 2013-11-11
New to flash,

I am creating a menu with buttons. The buttons will be linked to URL's with a second and a half delay for sound within the button located on the 'down' keyframe.

What I want is for a short (1 second) movie event to load, in the exact location of any click on any of the buttons in the menu. In other words, if the user clicks the upper left hand corner of the Contact Us button, I want my movie event to play in the upper left hand corner of the Contact Us button, a two second delay, and then redirect to a URL in the same window.

I am not even sure if I have been going about this the right way. I have created instances for the button and the movie event. I have been trying to insert in the first frame of an 'action script' layer, code that would direct the button to load the movie. Am I way off on the wrong track using combinations of the following commands (where btn is my button, and gunshot is my movie event):  
btn.addEventListener(onPress, gunshot.addASCuePoint);
onRelease.findCuePoint (gunshot);
gunshot.play
0
Comment
Question by:shemp609
  • 2
  • 2
4 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24379675

well you are using AS 3.0, but a bit wrong...

try the below instead...


and I am just assuming the following from the way you have it written..

- you have a function called findCuePoint, and you pass in the MovieClip "gunshot"
- gunshot has a function inside of it called "addASCuePoint" and it is called on click
- then you want the gunshot movieclip to play from the keyframe of where it is currently located

if any of this is wrong, then please explain a little better as to what you are trying to do...

and just an FYI... don't use buttons... only use movieclips, and controll everything with code from there...



rp / ZA





import flash.events.*;
 
btn.addEventListener( MouseEvent.CLICK, btn_OnClick);
 
function btn_OnClick( evt:MouseEvent ):void
{
  findCuePoint( gunshot );
  gunshot.addASCuePoint();
  gunshot.play();
}

Open in new window

0
 

Author Comment

by:shemp609
ID: 24401095
rascal-
thank you.
After a lot of trial and error I got the movie clip to load using the following script where cycle is my button, and gunshot is the movieclip that i want to load when the button is clicked:

cycle.onPress = function(){
            _root.attachMovie(gunshot, gunshot, _root.getNextHighestDepth());
            gunshot._x = 358;
            gunshot._y = 103;
            gunshot.play ();
            getURL("javascript:gunFire('http://**************.html')");
}

there are two things I still need to figure out:
1) I currently have the getURL directed to a javascript which creates a 2 second delay to allow for the gunshot movieclip to complete and then allows the page to redirect to the new URL associated with the cycle button.
I would like to use 'getURL("http*******", "_self", "GET") but I cannot figure out how to incorporate a 2 second delay in the actionscript 2 above.

2) I currently have X,Y cooridnates for the placement of the movieclip, gunshot. I would prefer for these coordinates to be generated by the location of the mouse-click. My best guess was to use the trace command, but it did not work:
gunshot._x = trace("X:"+cursor_mc._x);
gunshot._y = trace("Y:"+cursor_mc._y);

Any ideas on either of those two points?

Thanks!

0
 
LVL 22

Accepted Solution

by:
rascalpants earned 500 total points
ID: 24401381

for the delay...

you can setup a function that gets run after a setInterval()...  something like the below...

I wasn't able to get it tested, but it should work for you...


for the mouse coordinates...  use this instead....

gunshot._x = _xmouse;
gunshot._y = _ymouse;


BTW...  trace(); is used to just show data in the output panel.

rp / ZA




function callGetUrl( clip:MovieClip )
{
    clearInterval( clip.intID );
    getURL("javascript:gunFire('http://**************.html')");
}
 
cycle.onPress = function(){
            _root.attachMovie(gunshot, gunshot, _root.getNextHighestDepth());
            gunshot._x = 358;
            gunshot._y = 103;
            gunshot.play ();
            cycle.intID = setInterval( callGetUrl, 2000, cycle );
}

Open in new window

0
 

Author Comment

by:shemp609
ID: 24401515
Rascal P-
Youre the man!
Thank you. That works like a charm. I was so close but sometimes you just have to see it!

0

Featured Post

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Rotating Adobe pdf document 4 311
Flash player 17 install script .bat or .vbs 9 542
bandwidth 5 71
How to block online streaming via TMG2010 ? 2 132
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

770 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