making a swf a clickable link with the pointer icon - html

I have a swf embedded into a site, and I want the swf to be clickable so when you click on it it goes to another page. I tried wrapping the whole flash object in tags, and that makes it clickable but the biggest problem I'm having is when you roll over it with the mouse the pointer icon doesn't come up, it just looks like the regular arrow. I tried playing with the css and doing cursor:pointer, but it still doesn't work. Any suggestions? I can edit the .fla file and add some actionscript 2.0 to it, but I'm not sure what to add or where. I'd rather do it through html or css, but if I have to do it in flash that's ok too.
Also, I have an invisible button over the whole thing called, MYbtn

i think that the best solution is to add some code in your fla. Open it with Flash and locate the timeline. Right-click on the first frame, "Actions" and you can enter your code.
You can divide your problem in two point:
Display a link cursor when the mouse
is over
Move your browser to your
url when the user press the mouse
button
For the first problem this code should do the work:
this.buttonMode = true;
For the second problem:
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
this.addEventListener(MouseEvent.CLICK, function(evt:MouseEvent):void{
ExternalInterface.call("window.location.href = 'http://www.google.com'");
});
I haven't checked with Flash but this should work

If you have access to the .fla file, why don't you just edit it so that clicking anywhere on the screen redirects you to a new page? You can create an invisible button or something and use some actionscript to make it move people to a new page. I'm not exactly sure how you do it, but I've definitely made links in SWF files before and it's definitely possible.

The cursor should come up on most browsers , although I still haven't managed to get it to work on Chrome for Mac.
this.mouseEnabled = true;
this.buttonMode = true;
addEventListener(MouseEvent.CLICK , mouseClickHandler );
function mouseClickHandler(event:MouseEvent):void
{
navigateToURL( new URLRequest("your location"));
}
Check the docs for more info on navigateToURL
http://www.adobe.com/livedocs/flex/2/langref/flash/net/package.html

Related

Movieclip in Front of include .flv

I made a .swf Application which goes automatic to the fullscreenmode with the functions
stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
stage.scaleMode = StageScaleMode.NO_SCALE;
So what i wanted to do is to start a .flv video and in front of this .flv include, i want to have a Movieclip, which is in front of the .flv Video.
That doesn't work, in the Fullscreen mode. If i minimize the windwow. The Movieclip goes in front of the flv- included video.
So what i need is, to have something like a z-index function in the fullscreenmode.
Can anybody help me
Thanks
Flash Player: 11.4
Assuming you have a reference to every Display Object, you could use swapChildren to swap the depth or the z index:
var index1=this.getChildIndex(child1);
var index2=this.getChildIndex(child2);
this.swapChildren(index1,index2)
where child1 & child2 could be any display object including video player.
I'm not in front of Flash right now so I can't test the problem but I'm sure its considered bad practice to have an app that goes auto-fullscreen by itself on loading. Adobe considered it a security risk and they may have taken security steps that conflict with what you're doing... just a guess though.
"That doesn't work, in the Fullscreen mode. If i minimize the windwow.
The Movieclip goes in front of the flv- included video."
My advice is to make a button somewhere on the screen for going in/out of fullscreen. So when it looks okay in the window mode, click that button to go fullscreen again and then tell me if its okay now or is the problem still happening?
A) If its okay then you need to lose auto-fullscreen and just start with a button on stage. Give it text label like "Start App" or something like that so users know what to do (much better than just throwing them in fullscreen with some unexpected loud video etc).. Anyway when in fullscreen thats when your function should addChild the flv container MC and then your other MC. Use removeChild commands when F.S mode is exited. Make the "Start" button visible or hidden depending on screen mode (F.S is hidden, Window is visible etc).
B) If its not okay you have other problems.. I'm off to sleep but will check later if there's a reply. Peace..
I made my own solution :
var container:Sprite = new Sprite();
container.addChild(logo);
container.addChild(startVideo);
container.swapChildren(logo, startVideo);
this.addChild(container);
Whith this Sprite object it works fine.

How to ENTIRELY remove an flvplayback from stage when going to another flvplayback on another frame?

I'm trying to create an EXE projector using flash 5.5 AS3 where I have a few videos (FLVs) to show (their location is right next to the exe file in the same directory) - each load in a different frame, and all of those videos should also have a full screen option to them. Those are original videos that people WILL want to watch in full screen. It's essential for the experience...
The problem(s) I currently have (after fixing the sound that didn't stop after going to a different video) are hard to describe, but I'll try really hard.
Ok, so when I click the full screen button on a video and watch it in full screen, I will eventually want to exit the full screen, so I click on the same icon at the bottom to exit full screen (or ESC button, it's the same) and then click the navigation button to go to the SECOND FLV's frame to watch the other video. After watching the second video in full screen and then exiting full screen, flash takes me to the FIRST video's frame and that is a big problem. Also, now the button that takes me BACK to the second video's frame won't work. It's like flash is stuck.
I use the Components --> FLVPlayback 2.5 from the componant menu (I don't really know AS3 programming) and I fix its properties in the component parameters.
Also, I don't think that any of the followings are the reason for the bug, but I use these 3 scripts to stop all sound when navigating away from one frame (with an FLVplayback) to
another frame with another FLVplayback:
MyFLV.stop();
SoundMixer.stopAll();
MyFLV.addEventListener(Event.REMOVED_FROM_STAGE,xyz);
function xyz(e:Event):void{
MyFLV.stop();
}
I've found these online where people asked help for the sound bug I described.
The third script was suppose to remove the FLVplayback from the stage before going to another frame, but it works only when NOT GETTING INTO FULL SCREEN. I need something that will COMPLETELY remove the previous video from the stage so after exiting the SECOND viewed video, flash won't take me to a video that from some reason is still in its memory. I have something like 30 videos in my project and I need to remove each and every one of them off of the stage before navigating to the next frame to open a new FLVPlayback.
I tried to add a link to a demo I made with the problem so you can look at it, but it triggered a "oops, something went wrong" error, probably anti spam mechanism...
I would recommend using only one frame and only one flvplayback instance. Otherwise you have to deal with weird bugs like the one you are getting (usually caused by misplaced or forgotten code). Of course, using only one frame requires using more code, but with the number of hard-fixes it looks like you were making for the bugs, you may end up with less code.
Don't worry, I'll walk you through everything!
Reasons to use code (as opposed to multiple frames):
Easier to keep track of:
Know where all your code is so you can easily find and fix any problems.
Make changes more easily
You want to switch an existing video? edit a file reference and you are done.
Want to add a video? no more dragging a new flvplayback instance onto a new frame just add some very simple code and a button and you're done.
More customization
Reasons to use multiple frames (and multiple flvplayback instances):
easier to place visually
Some people find it easier when they have an actual movieclip that they can visually place on the stage
Less code
Here we go:
//import flv library
import fl.video.*;
This allows you to use ActionScript to manipulate the flv player
//video playback code-----------------------//
var myVideo:FLVPlayback = new FLVPlayback();
this creates an instance of FLVPlayback called myVideo (referenced from now on in the code as myVideo)
this next chunk shows many of the customizable features of the flv player. It is not necessary to include them.
//places the video player on stage at x,y
myVideo.x = 115;
myVideo.y = -10;
//uses SkinOverPlayFullscreen.swf for controls
myVideo.skin = "SkinOverPlayFullscreen.swf";
//color of controls
myVideo.skinBackgroundColor = 0x333333;
//hide controls and time it takes controls to fade and reappear (milliseconds)
myVideo.skinAutoHide=true;
myVideo.skinFadeTime=300;
//add the player to the stage
addChild(myVideo);
And now comes the important part. I have made buttons and added them to the stage. I gave each of the buttons a different instance name (box1_btn, box2_btn, and box3_btn). When someone clicks on a button, an "event" will occur.
//button listener code-------------------------//
//when button 1 is clicked throw button 1 event
box1_btn.addEventListener(MouseEvent.CLICK, clicked1);
//when button 2 is clicked throw button 2 event
box2_btn.addEventListener(MouseEvent.CLICK, clicked2);
//when button 3 is clicked throw button 3 event
box3_btn.addEventListener(MouseEvent.CLICK, clicked3);
//play different videos for different buttons---------//
//when button 1 event is thrown
function clicked1($e:MouseEvent):void
{
//play video 1.flv
myVideo.source = "1.flv";
}
//when button 2 event is thrown
function clicked2($e:MouseEvent):void
{
//play video 2.flv
myVideo.source = "2.flv";
}
//when button 3 event is thrown
function clicked3($e:MouseEvent):void
{
//play video 3.flv
myVideo.source = "3.flv";
}
This code will not have any sounds that keep playing because two videos cannot play at the same time in one instance of the player. Nor will it have any mess-ups when you come out of fullscreen because there is only one frame for the video to go back to.
Some possible problems you may run into:
It doesn't work at all:
Make sure you have added an instance of FLVPlayback to the library by adding an instance to the stage from the components menu (window>>components or ctrl+F7) and then deleting it from the stage (it should still appear in the library).
The playback buttons I want aren't showing up:
There is a great explanation of how to use As3 to manipulate FLVPlayback here:
http://www.republicofcode.com/tutorials/flash/as3flvplayback/
find the section about "Applying a Skin to the FLVPlayback Component" and follow it to use an adobe playback skin. If you want to make your own unique skin I would recommend opening and editing one of the pre-made skins. I found mine in
C:\Program Files (x86)\Adobe\Adobe Flash CS6\Common\Configuration\FLVPlayback Skins\FLA\ActionScript 3.0
I hope this helps!
Below would be simplest way to unload the FLVPlayback
removeChild(MyFLV);
it works fine for me
flvPlayBack.stop();
removeChild(flvPlayBack);
stops the sound and removes the playback.

Button that only works once in flash actionscript 3.0

I have this collecting item game which u have to collect enough "stars" in order to acess a button. After I clicked the "star" button, it suppose to disappear and never appear again. However, when using this script, although the button disappear once I clicked it, when I returned to the frame after going to another frame, it appeared again! pls help!
star1.addEventListener(MouseEvent.CLICK,gotstar);
function gotstar(event:MouseEvent){
stars++;
star1.x = -500;
}
Are you coding on the frames themselves? If so every time you enter a frame it will run every piece of contained code, even if it has already ran once. A solution to this would be to use a document class to track the progress of the game.
you need to remove it from the stage if I understand.
try this instead of star1.x = -500;
stage.removeChild(star1);
star1.removeEventListener(MouseEvent.CLICK,gotstar);
star1.parent.removeChild(star1); in the click handler code (gotstar) should help
however posting your .fla file might be useful for better understanding

actionscript 3 popup window - not js

Im doing a program in AS3 and, i'm trying to do the following:
Lets say I have a button, which have onClick event, and when the event is triggered, the popup window will appear.
And in this popup window there is going to be an animation (countdown) of 2020 (this is just an example).
Is there a way to do this without javascript. Because i'm not doing this for website, its going to be a animation.
Hope i was clear.
Thanks
In Flash,create a movie clip, give it an instance name of "countdown_mc", put the countdown animation inside it.This will be your "alert" type window.
Now, in the movieclip containing "countdown_mc", add a new layer and on the same frame bring up the action editor(F9) and write the following: countdown_mc.visible=false;
When you push the button it should make countdown_mc.visible=true and maybe do an optional growing animation;
Also on this frame add a listener for countdown_mc so that when the user clicks on the window it disappears(countdown_mc.visible=false);
For animations add download tweenmax from http://www.greensock.com/tweenmax/, extract the archive in the folder that contains your fla and add the following to your code:
import com.greensock.*;
TweenMax.from(countdown_mc,0.5,{scaleX:0,scaleY:0});

How to make a flash file a link (clickable to go to a URL)

I am new to Flash.
I am using Adobe Flash CS3 to create simple animations (images moving between keyframes).
It produces a SWF file that I put on a website.
I want the SWF file to be a link to a URL. How do you do that?
Thank you in advanced!
The same answer using AS3:
in the 1st frame that the invisible button appears, you should paste the following code:
myButton.addEventListener(MouseEvent.CLICK, linkToPage);
function linkToPage(e:MouseEvent):void{
var request:URLRequest = new URLRequest("your page here");
navigateToURL(request);
}
You should name the button instance 'myButton' (in the properties bar - the bottom-left input dialog). That should do the trick.
1st you have to create an invisible button. An invisible button is a button with only the HIT frame. Create a button that covers all your stage. It will appear in your stage as a blue-transparent shape. Just click it and press F9 to bring the 'actions' window.
After that, just paste the following code into the window:
on(release){
getUrl("here you put your url");
}
After that, just compile your code as AS2. I think that's the easiest way of doing this.