External SWF loads, but does not display - actionscript-3

So this is similar to a problem I had a few days ago, but not quite the same. If I try to load an external SWF, it loads all right, but I can't see anything! There are buttons in this external SWF, and I can click the buttons and they work, so the SWF is there and functional, I just can't see any of it (the screen is completely white). Also if I click the button, IT appears (with the active frame of its animation) but nothing else does. The audio also plays on its cue. Everything seems to work except that it's invisible.
This is the relevant code:
private var myLoader:Loader = new Loader();
private var url:URLRequest = new URLRequest("../lib/Introduction.swf");
private var introdummy:Sprite;
(different method)
introdummy = new Sprite();
addChild(introdummy);
myLoader.load(url);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, introLoaded);
function introLoaded(event:Event):void
{
introdummy.addChild(myLoader.content);
}

OK, you all are going to laugh your butts off when you see what was wrong...
My main SWF has a white background. My external SWF has a black background, and all the text on it was white. When I imported the SWF in, the background showed the main SWF's background. So all the text showed as white on a white background, so it was invisible. :/

add your swf file like this:
introdummy.addChild(myLoader);

Related

Flash var Loader issue - animation changing

So, I've use a loader action script for a few banners I've been working on, and usually things go relatively smoothly (for Flash). However, the animation changes once I guide the image to the code. Has this happened to any one else? Below is the code I am using:
var imageLoader:Loader = new Loader();
var image:URLRequest = new URLRequest("http://972b6ac7e316515e1890-2848ccf658e0edc35f614dd3380d9fcb.r27.cf2.rackcdn.com/Background_othersizes.png");
imageLoader.load(image);
addChild (imageLoader);
I assume you have created animation in the Flash IDE with static image (linked from the library), and now you try to add image in runtime. Loading of the image is asynchronous process, so I would recommend account it in your animation and logic.
Also place in your MovieClip where image will be loaded, transparent shape as a background, of the same size as image, so environment will be aware of display object size, and all your transformations over MovieClip will be accounted accordingly. Also check placement and scaling of the image.

as3 Air - AddChild works but is slooooooooooow

I am creating an app where when a button is pressed a very large picture is added to the stage (it is larger than the screen but can be dragged around by the user)
When the button is pressed the picture (well, movieClip) does come up and it able to be dragged fine, buttons inside it work.
The problem though is that there is a pause of about 6 seconds between the button press and the image appearing. I am using one .fla file for publishing and compiling (let's just call it Main.fla for now), and another one to hold all the graphics. The graphics are then added with this embed command:
[Embed (source = "assets/graphic.swf", symbol = "Content")]
private var Content:Class;
private var _content:*;
I have these lines where all the variables are declared (in between the class definition and the constructor function) I was under the impression that embedding it like this was equivalent to loading it at compile time. Is this true? What could be causing this lag when the button is pressed?
If I can't cut out the lag, another idea I had was to make some spinning circle or something to tell the user, "hey, don't worry. It's loading!"
If the slowness is at addChild you can add the asset to the stage much earlier and set it's visiblility to false, then when the button is clicked set it back to true. Obviously this is a small hack but might be sufficient for what you are doing.
var asset:MovieClip;
private function init():void
{
asset = new Content();
assset.visible = false;
addChild(asset);
button.addEventListener(MouseEvent.CLICK, onMouseClick);
}
private function onMouseClick(e:MouseEvent):void
{
asset.visible = true;
}
Embedding your SWF is probably not what is causing the delay.. or rather it would not likely be better if you imported the SWF into your FLA. Is this on a device? Chances are you would either have to devise a different way of loading your asset, or be satisfied with a loading animation.
If the main K size is coming from a large image, you could consider loading it in segments, starting with the part that is initially visible.

AS3 loading external swf on button click

In AS3 (Flash), I want an external swf-file to load when I click a specific menu button. I also want the swf to disappear when I click another button, so that another swf can load. This code shows my swf, but it just "loops". And also it covers my menu (on the top of the page) so I can't click anywhere. What could I change in the code to fix this?
var loader_mc : Loader = new Loader();
addChild(loader_mc);
bilder_btn.addEventListener(MouseEvent.CLICK, buttonClick)
function buttonClick(e:MouseEvent):void
{
try{
loader_mc.unloadAndStop();
} catch(e:Error) {
}
var urlRequest : URLRequest = new URLRequest("flickr.swf");
loader_mc.load(urlRequest);
}
Change loader_mc's X and Y so that the loaded SWF does not cover your menu.
You could do better with reinitializing that loader_mc to load another SWF, that is, create a new Loader(), removeChild() the old loader, addChild() the new one, then load.

making a swf a clickable link with the pointer icon

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

AS3 How do I stop sound and video when clicking a menu button to go to another frame?

I have a problem with my slideshow script.
I have embedding a flash video file into my website with this slideshow called monoslideshow, and everything seems to work perfectly. Trouble is, when I am clicking on another menu button that should jump to another frame, it still keeps playing the video and sound while displaying the new menu data.
So I will probably need some code that stops the video instantly, when another menu button is clicked. But how do I write it and where do I put it?
Here is my actionscript for the video file to show:
var loaderSlide:Loader = new Loader();
var monoslideshow:Object;
loaderSlide.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
addChild(loaderSlide);
loaderSlide.load(new URLRequest("monoslideshow.swf"));
function onLoadComplete(event:Event):void {
monoslideshow = event.target.content;
monoslideshow.showLogo = false;
monoslideshow.setViewport(new Rectangle(730, 20, 700, 660));
var xml:XML =
<album title="TITLE" itemPath="photography/makingoff/" thumbnailPath="thumbnails/">
<contents>
<video source="VIDEO.flv" />
</contents>
</album>
monoslideshow.loadXML(xml);
}
It would be great to get a solution to this problem, otherwise my website will be kinda messy ;)
THANK YOU!!
Ok, I found the answer now.
Just for people who might be having the same problem.
I put in some code for the new menu button.
flash.media.SoundMixer.stopAll();
monoslideshow.visible = false;
This stops all sounds and makes the slideshow invisible.
Quick and simple :)