| Home | Register | FAQ | Members List | Search | Today's Posts | Mark Forums Read |
|
|
#1 (permalink) |
|
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.
|
|
|
|
|
|
#2 (permalink) |
|
Iris Folder
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 |
|
|
|
#3 (permalink) |
|
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.
|
|
|
|
#4 (permalink) |
|
Part of the 3 out of 4
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
|
|
|
|
#5 (permalink) |
|
Part of the 3 out of 4
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
|
|
|
|
#7 (permalink) |
|
Part of the 3 out of 4
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
|
|
|
|
#8 (permalink) |
|
Part of the 3 out of 4
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
|
|
|
|
#13 (permalink) |
|
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. |
|
|
|
#14 (permalink) |
|
Iris Folder
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 |
|
![]() |