Creative COW SIGN IN :: SPONSORS :: ADVERTISING :: ABOUT US :: CONTACT US :: FAQ
Creative COW's LinkedIn GroupCreative COW's Facebook PageCreative COW on TwitterCreative COW's Google+ PageCreative COW on YouTube
ADOBE FLASH:HomeFlash ForumFlash TutorialsFlash Video TutorialsWeb Streaming ForumAdobe FlashPodcast

Re: Importing an interactive .swf file into a full flash site ( AS3 answer)

COW Forums : Adobe Flash

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Share on Facebook
Respond to this post   •   Return to posts index   •   Read entire thread


demetri tashieRe: Importing an interactive .swf file into a full flash site ( AS3 answer)
by on Oct 18, 2011 at 4:59:33 pm

SWFs are imported to other SWFs all the time. They are placed into other SWFs via Loaders. You are using AS2 code, which I don't work with. I recommend you start learning and working with AS3.

in AS3, you first create a Loader by declaring a variable:
var myLoader:Loader = new Loader();
then you can 'load in' the desired external SWF ( this also works for .jpg, .jpeg, .png. .gif files ). like this:
myLoader.load(new URLRequest( "mySWF.swf" ));
then you 'add it to the display list' ( consider this like just placing it on the stage) like so:
addChild(myLoader);
give it some positioning if you want:
myLoader.x=100;
myLoader.y=150;

That's really it. It is a better idea to actually not add the SWF to the 'display list' until it is fully loaded. To do this, we add a 'Listener' to the 'contentLoaderInfo' to signal when it is fully loaded, then it can safely display the SWF.

full working code would be this:
var myLoader:Loader = new Loader();

myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, showMySWF);
function showMySWF(e:Event):void {
addChild(myLoader);
myLoader.x=100;
myLoader.y=150;
myLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, showMySWF);
}

myLoader.load(new URLRequest( "mySWF.swf" ));

as long as your 'flash slideshow maker' outputs a .swf, there should be no reason you can't get it to work inside another swf. it should be self contained ( that is, it should work as a 'module' by itself ), and it should be the same AS version as the swf you are importing it into.

controlling an external swf from the main swf gets more complicated. If you need that, you can google 'external swf communication' or look at this older tutorial here:
http://demetri-media.com/FlashTalker/ExternalSWFCommunication.html

for the other question, to open in a blank page you need to add the parameter "_blank" to the URLRequest ( which is the 'getURL' in your AS2 code). rather than have the code on the button, it is better to give the button an instance name ( like 'myButton'), then place this code on the main timeline:

AS2:
myButton.onRelease = function()
{
getURL("http://www.website.com", "_blank");
}


in AS3:

myButton.addEventListener(MouseEvent.CLICK, openURL);
function openURL(e:MouseEvent):void
{
navigateToURL(new URLRequest("http://www.website.com"));
}


AS3 by default opens the URL in a blank page. If you need it to open in the same, use "_parent" like this

navigateToURL(new URLRequest("http://www.website.com"), "_parent");


hope that helps


Posts IndexRead Thread
Reply   Like  
+1
Share on Facebook


Current Message Thread:




LOGIN TO REPLY



FORUMSTUTORIALSFEATURESVIDEOSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

Creative COW LinkedIn Group Creative COW Facebook Page Creative COW on Twitter
© 2014 CreativeCOW.net All rights are reserved. - Privacy Policy

[Top]