Reply LinkBack Thread Tools Search this Thread
Old 29-05-2003, 12:33   #1 (permalink)
pixelpyro
Senior Member
 
Join Date: May 2003
Posts: 658
Importing an swf into an swf file

hi Guys,

Flash newbie so not sure if this has been answered somewhere before.

Basically I wanted to know if it is possible to load an external.swf file into another .swf file. For example say I have a flash site and I wanted to import a banner ad that has been created in flash. I have a predifined size 200x60 pixels and the external banner.swf matches that size. Can I call it into the flash site. Basically i want to have an ad that can be changed or provided by a client that can be replaced on a regular basis without having to edit the main flash site.

Any ideas??

Cheers

PP
__________________
feel the heat.
  Reply With Quote
Old 29-05-2003, 14:00   #2 (permalink)
dan
Iris Folder
 
dan's Avatar
 
Join Date: Apr 2003
Location: smokey
Posts: 2,672
you most certainly can.

You need to place an empty (or not) movieClip instance on the stage, and then target it with

loadMovie ("somepath/file.swf", "target movie clip");

or

somepath. loadMovie ("file.swf");

We'll use the second method here. For your Banner you could use a movie clip instance of the required size on the stage (we'll call it banner_mov), enter this on the time line of banner_mov

onClipEvent(load) {
this.loadMovie("Banner.swf");
}

This could just as easily be triggered by a button press or other event.

That should work, shout if it doesn't
  Reply With Quote
Old 30-05-2003, 07:00   #3 (permalink)
pixelpyro
Senior Member
 
Join Date: May 2003
Posts: 658
Thanks for the Dan.

i have one last question, you know what its like once you start down a path things start to grow. How would I create a random selection when importing the swf.

For instance I have the site with a movieclip instance (sized and positioned as required) that will import the external swf into it when it reaches a specific frame. Rather then importing just one could i create an action that randomly picks a file from say six swf files. So that each time the frame is reloaded it displays a different swf. i appreciate that the law of averages will mean that on occasion some will be displayed twice but that is not a problem.

Thanks again.
__________________
feel the heat.
  Reply With Quote
Old 30-05-2003, 07:20   #4 (permalink)
lucidcreations
Part of the 3 out of 4
 
lucidcreations's Avatar
 
Join Date: Feb 2003
Location: cheshire
Posts: 2,081
try this:-
-----------------------------------------------------------------

var randomNumber // will contain a random number

// pick a random number betweeen 0 & 5, then add 1 cos flash never
// gives highest number cos its zero based i.e. random(6) will randomly
// give 0,1,2,3,4,5 adding 1 will give 1,2,3,4,5,6
randomNumber = random(6) + 1;

// load the movie bannerX.swf into the target movie mytarget_mc or _root
// where X is replaced by randomNumber
_root.loadMovie("banner" + randomNumber + ".swf");

------------------------------------------------------------------

that should do the trick
__________________
Jase
  Reply With Quote
Old 30-05-2003, 07:29   #5 (permalink)
lucidcreations
Part of the 3 out of 4
 
lucidcreations's Avatar
 
Join Date: Feb 2003
Location: cheshire
Posts: 2,081
just done a trace on random(6)+1 this is the traced results giving you an indictaion of how random this will be:-

4,1,3,5,1,5,4,4,1,4,1,1,4,2,2,1,5,2,1,4,5,5,4,3,1, 2,3,3,4,2,1,4,3,2,5,3,1,4,1,5,3,1,3,3,4,3,4,1,1,3, 5,4,1,3,3,4,2,4,1,5,2,1,1,5,2

not bad really.
__________________
Jase
  Reply With Quote
Old 30-05-2003, 07:43   #6 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,625
I dunno, there's too many ones and fours...
  Reply With Quote
Old 30-05-2003, 07:46   #7 (permalink)
lucidcreations
Part of the 3 out of 4
 
lucidcreations's Avatar
 
Join Date: Feb 2003
Location: cheshire
Posts: 2,081
you could add this to stop repitition:-

-----------------------------------------------------------------

lastNumber = randomNumber;

// pick a random number betweeen 0 & 5, then add 1 cos flash never
// gives highest number cos its zero based i.e. random(6) will randomly
// give 0,1,2,3,4,5 adding 1 will give 1,2,3,4,5,6
randomNumber = random(6) + 1;

//check whether randomNumber is = to lastNumber and keep randomly
// selecting a number until it different
while(randomNumber == lastNumber) {
randomNumber = random(6) + 1;
}

// load the movie bannerX.swf into the target movie mytarget_mc or _root
// where X is replaced by randomNumber
_root.loadMovie("banner" + randomNumber + ".swf");

-----------------------------------------------------------------
__________________
Jase
  Reply With Quote
Old 30-05-2003, 07:48   #8 (permalink)
lucidcreations
Part of the 3 out of 4
 
lucidcreations's Avatar
 
Join Date: Feb 2003
Location: cheshire
Posts: 2,081
that gives:-

3,6,2,3,4,3,5,6,5,3,2,6,4,5,6,4,3,1,6,4,3,2,3,2,1, 3,2,5,3,2,3,2,6,3,5,3,2,3,4,5,2,4,1,3,4,2,3,6,1,5, 6,4,2,6,1,4,1,5,1,4,1,4,6,2,5,3,6,2,6,2,4,3,4

bit better
__________________
Jase
  Reply With Quote
Old 30-05-2003, 07:55   #9 (permalink)
Stickman
Dr. Lucien Sanchez
 
Stickman's Avatar
 
Join Date: Mar 2003
Location: UK
Posts: 5,625
I was only joking

Fair play though, that's perfect coding for what pixelpyro wanted.
  Reply With Quote
Old 30-05-2003, 08:58   #10 (permalink)
lucidcreations
Part of the 3 out of 4
 
lucidcreations's Avatar
 
Join Date: Feb 2003
Location: cheshire
Posts: 2,081
yeah i know u were mate

I was just typing that script as I saw your reply and was just thinking to myself "hmm, to many 1's and 4's"
__________________
Jase
  Reply With Quote
Old 30-05-2003, 09:58   #11 (permalink)
pixelpyro
Senior Member
 
Join Date: May 2003
Posts: 658
Cheers guys I will give it a go
__________________
feel the heat.
  Reply With Quote
Old 06-06-2003, 18:09   #12 (permalink)
roto
This is it - ground zero.
 
roto's Avatar
 
Join Date: Apr 2003
Location: Paper St.
Posts: 4,200
Send a message via AIM to roto Send a message via Yahoo to roto
I'm curious...can we see the final result?
__________________
fun: HGC v.4 | last.fm: DT | me | oi! f*ck u roto: ...via meebo!

New to interweb design? Your friends at dt can help.
  Reply With Quote
Old 12-06-2003, 13:00   #13 (permalink)
ewarwoowar
Registered User
 
Join Date: Apr 2003
Posts: 33
you really shouldn't use random(x), as it's not very random!

you want to be using Math.random(), which generates a properly random number between 0 and 1, so you just have to multiply it by whatever your range is

ie. titsOgledInTheSummerSun = Math.random() * 8000;

good luck.
  Reply With Quote
Old 12-06-2003, 15:47   #14 (permalink)
dan
Iris Folder
 
dan's Avatar
 
Join Date: Apr 2003
Location: smokey
Posts: 2,672
The man does make a good point, but as Math.random generates a number from 0.0 and 0.999999.... you must remember to convert your end number (for the above example anyway).

ie. titsOgledInTheSummerSun = Math.floor(Math.random() * 8000) + 1;

will give you a number between 1 and 8000 tits

  Reply With Quote
Old 12-06-2003, 18:13   #15 (permalink)
roto
This is it - ground zero.
 
roto's Avatar
 
Join Date: Apr 2003
Location: Paper St.
Posts: 4,200
Send a message via AIM to roto Send a message via Yahoo to roto
I wouldn't want random in the case of tits...I'd want all 8000
__________________
fun: HGC v.4 | last.fm: DT | me | oi! f*ck u roto: ...via meebo!

New to interweb design? Your friends at dt can help.
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8