loading swf files to buttons all on same page in flash - actionscript-3

Good day to everyone!Here is my problem to all that is familiar with Flash. I am creating a portfolio using Flash. It has been sometime since using actionscript and can't figure out this. I have 6 different jpeg that I turned into buttons on 1 project page.What I need is to add different swf files to each button and play in seperate window.The code I used first loaded 1 swf file in same window. I am unable to figure out the code to make all 6 buttons show their individual swf file in a seperate window. Please help I am using trial version of the new Flash CC.

Usually, here on StackOverflow we like to see some code indicating you actually tried something, but let me see if I can help anyway.
Sounds like you are asking how to click a button and have the response be to load another swf into a new window.
To do so, you need to reference an html file with a swf embedded in it, since to see a swf in the browser it needs to be in an html page.
So you would do something like the following:
import flash.events.MouseEvent;
import flash.external.ExternalInterface;
var myUrl = 'http://www.someSiteWhereMyFilesAre.com/myNewSwf.html';
myButton.addEventListener( MouseEvent.CLICK, onClick );
function onClick( e:MouseEvent ):void
{
if( ExternalInterface.available )
{
ExternalInterface.call( 'window.open', myUrl, '', 'width=400,height=300' );
}
}
That method will only work while you have it online. It will not load the file locally.
If you do not care about the size of the window that is opened:
Remove the ExternalInterface import.
add imports:
import flash.net.URLRequest;
import flash.net.navigateToUrl;
Change your onClick function to:
function onClick( e:MouseEvent ):void
{
navigateToURL( new URLRequest( myUrl ), '_blank' );
}

Related

AddChild to use external SWF has disabled my buttons I had on original Flash file

I have a Flash file (a website header with 5 buttons for 5 links to webpages).
On my actions layer, I added an external SWF file using the addChild object.
Note that I have very basic knowledge of ActionScript and I had to take some help from Google to setup above script.
The external SWF I have brought in using adChild code is working as an overlay on top of my original flash animation but all the buttons I have on original Flash file as website links have now become disabled. Even the mouseOver effects I applied to those 5 buttons are not responding. Below is my AS3 code:
import flash.net.navigateToURL;
import flash.net.URLRequest;
stop();
var swfRequest:URLRequest = new URLRequest("movie/txtOverlay.swf");
var swfLoader:Loader = new Loader();
swfLoader.load(swfRequest);
addChild(swfLoader);
button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.example.com/link1.asp"), "_self");
}
For the sake of brevity, I have placed just one button's code but you get the idea. Any solution to avoid this?
Thanks ... Syed

making changes to a file i didn't create and now the button wont function

im a simple User interface designer with a bit of knowledge in Flash. I was asked to resize another person's flash file. So i opened the file in ANimate CC. I changed the file dimensions but didn't change the actions of the button. So after i exported it the button function no longer worked. Not sure why since it worked before and now it doesn't. Any ideas how to get the button to work. i need it to go to the url google.org
here is the AS3
import flash.external.ExternalInterface;
// =========================== CLICKTAG STUFF ==================================
// ========================================================================= ====
ct.addEventListener(MouseEvent.CLICK, handleClick);
ct.addEventListener(MouseEvent.ROLL_OVER,handleMouseOver);
ct.addEventListener(MouseEvent.ROLL_OUT,handleMouseOut);
function handleClick(e:MouseEvent):void {
ExternalInterface.call("ctaClick");
trace("clicktag clicked...");
/*var flashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
if (flashVars.clickTag) {
navigateToURL(new URLRequest(flashVars.clickTag),"_blank");
}
trace("clicked");*/
}
function handleMouseOver(e:MouseEvent):void {
cta.cta.gotoAndPlay("OVER");
cta.gotoAndPlay("over");
}
function handleMouseOut(e:MouseEvent):void {
cta.gotoAndPlay("out");
}
The code that's called when the button is clicked is external in JavaScript:
ExternalInterface.call("ctaClick");
Make sure you test the newly created flash file embedded in the HTML file it is supposed to be embedded in. The flash file is used like an image, it doesn't do much on its own except for some visuals on mouse over.
The functionality is in JavaScript. Without embedding the flash file, the JavaScript is missing and it doesn't do much.

Scene remain on background after navigate to new file

I cant stop the existing SWF after load another SWF. New SWF is run on top of the old SWF. I would like to know the simplest way to link all this up.
Scene 1
File 1: MainMenu.SWF (Consist of 2 Picture File)
- Subject1.JPG (Click and Load Subject1MainMenu.SWF)
- Subject2.JPG (Click and Load Subject2MainMenu.SWF)
Scene 2
File 2: Subject1MainMenu.SWF
Scene 3
File 3: Subject2MainMenu.SWF
Below is my code,
import flash.events.*;
var Subject1 = new Loader();
a.addEventListener(MouseEvent.CLICK,onMouseClick);
function onMouseClick (event:MouseEvent)
{
subject1.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaderComplete);
Subject1.load(new URLRequest("Subject1MainMenu.SWF"));
}
function onLoaderComplete(Event)
{
var mainmenu = subject1;
addChild(mainmenu);
}
There is no one size fits all to all this.
You can hide your main menu swf while you load and show child swf
you can remove your main menu completely while you show your child swf and later in some other flow, you reload your main menu again
you can also use module manager to manage the swf loading and unloading

Change Banner ClickTag Code to AS3?

I have been handed a number of Flash (AS3) banners to add ClickTag codes to them and as the documents have been setup as AS3 it does not allow code added to items!
I need help changing the following code to AS3 asap if anyone can help?
on (release) {
getURL (_level0.clickTag, "_blank");
}
I cannot change the document back to AS2 as they have been created through InDesign and the filters don't work if I change them back!
Thanks,
Thomas.
In AS3, the on(event) workflow has been replaced with the event system; and getURL() as been renamed navigateToURL() witch is more clear about what the function does.
// 'import' the necessary resources : If you don't do this, you'll have error while compiling.
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;
// theBanner is the name of your clickable MovieClip. If you add the code in the MovieClip, use 'this' instead
// this line indicate to call "onClick" if MOUSE_UP occurs on theBanner (ie : the user release the mouse hover the MovieClip
theBanner.addEventListener(MouseEvent.MOUSE_UP, onClick);
// The onClick function, how open the new clickTag URL when called
function onClick(e:MouseEvent):void {
// get the clickTag URL (root.loaderInfo.parameters.clickTag), and send it to navigateToURL.
navigateToURL(new URLRequest(root.loaderInfo.parameters.clickTag), '_blank');
}

ActionScript3 Extrenal Preloader Won't Play Movie Clip

I'm sure this a simple problem and I'm overlooking something obvious.
I have an external pre-loading SWF that contains nothing but a movie clip (loader_graphic) on one layer, in the first (and only) frame; and a loading script on another layer, in the first frame. The movie clip is just a simple loop animation with no progress indicators. If I don't include the script, it works great.
The script loads the external SWF, and by itself, it works just as it should.
When I combine the two, I get the first frame of the movie clip, and then it freezes until the external SWF is fully loaded. Once it's loaded, it plays one time and stops. I'm somewhat new to AS3, and I know that preloading is one of the conventions that has changed, so I probably don't have it coded properly:
loader_graphic.play();
import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.ProgressEvent;
var l:Loader = new Loader();
l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loop);
l.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
l.load(new URLRequest("external.swf"));
function loop(e:ProgressEvent):void
{
var perc:Number = e.bytesLoaded / e.bytesTotal;
}
function done(e:Event):void
{
loader_graphic.stop();
addChild(l);
}
Any help is appreciated.
It turns out that the preloader was playing all along. It was just stalled because the main SWF was overloading the Flash player.
The main SWF it was loading included an F4V video being streamed from a standard web server, and it was too much for the player to handle all at once. I embedded the video, instead, and it all worked perfectly.