
Examples and instant time savers library
Flash is not active in a web browser until clicked
![]()
Heres the solution to a new problem introduced from the new Flash activation issues introduced from IE's new wonder security "enhancements".
Sorry, not a fan of external linking but this solution is worth the jump, works perfectly.
<Heres the solution>
Global Variables - Put in any layer on the main timeline
![]()
_global.j = 0;
Clip Hide/Show![]()
on (release) {
clpMenu2.visible = false;
}
Dynamic Loading of External Movies
Notes: Make a blank movie clip(any size) on the main movie and name the instance
"clpEmpty" in the Proporties panel. It helps to set the size of the empty clip to
the size of the movie you plan to import. This makes placement on your main stage
a little easier.![]()
on (release) {
clpEmpty.loadMovie("horiz.swf")
}
--- Lets replace the running movie in place ---
on (release) {
this.loadMovie("horiz.swf")
}
Goto and Play
![]()
on (release) {
clp_Slide.gotoAndPlay(2);
}
![]()
Rollover and move clip
![]()
on (RollOver) {
instanceName._x=300;
instanceName._y=300;
}
Goto and Play, One time and stop!![]()
on (release) {
// else-if statement
if (j<1) {
clp_Slide.gotoAndPlay(2);
txtOut.text = j;
} else {
clp_Slide.gotoAndPlay(10);
txtOut.text = j;
}
j++;
}
Uload & Swapping
![]()
Loading Movies into Levels and Target Movie Clips
Last updated Jun 17, 2004.
There are two ways through which you can load SWF and JPG files: into a level and into a Movie Clip.
Download Based files
Link to the PeachPit article
Loading into a Level
Within Flash you can place difference elements on layers. You see this clearly when you create layers in the Timeline Panel. Movie Clips added in a top level layer will appear to ride on top of Movie Clips on lower layers.
Levels are similar. When you publish a Flash Movie to an SWF file format, Flash defaults all of the visual content to Level 0. You can load SWF/JPG's into their own level above Level 0. For instance, you can load navigation SWF into Level 1. You cannot use Level 0 as this level is restricted, but you can use any number above that. If you use two or more levels, the higher number will appear above the lower number in the same way layers stack on top of each other.
To do all of this you need ActionScript. In the following example you will have a Flash Movie, called mainMovie, that will load an external Navigation SWF into Level 5.
For this demonstration I have already created a movie called navigation.swf. You will find it included with the attached zip file.
Create a new movie.
In the Timeline create a new layer and rename it "actions." Select frame one of the "actions" layer. Open the Actions Panel and add the following ActionScript:
loadMovieNum("navigation.swf", 5);
Save the new movie as "mainMovie" in the same directory as "navigation.swf."
Test the movie. You will see that the navigation.swf movie is loaded into the mainMovie.swf. All movies loaded into a level will load into the top left hand corner of the movie it is being loaded in to.
You can load movies into additional layers, but you cannot load two or more movies into the same layer. If you write something like:
loadMovieNum("navigation.swf", 5);
loadMovieNum("form.swf", 5);
loadMovieNum("picture.jpg", 5);ActionScript will keep loading each movie into the same layer. As a movie is loaded into the same space as another movie, it will force the existing movie out.
There will also be times when you want to unload a movie clip. You can unload a movie loaded in to a level with the following:
unloadMovieNum(5)You can see that you do not need to identify the name of the file you are unloading, only the level. Here it is level 5.
Targeting a Movie Clip
The method I prefer over load movies into level is to target a movie clip and load a movie into that clip.
The method to do this is as follows:
You need to create a movie clip and add it to the stage.
Name your movie clip (I have called it "blank_mc").
Through ActionScript you link the SWF file you want to load to the named Movie Clip on the Stage. Add the following ActionScript to bind the target the external movie to the movie clip:
loadMovie("form.swf", blank_mc);Figure 3
Another method is to create the movie clip with the createEmptyMovieClip ActionScript object. In the following example you will load a movie called "form.swf."
Using the movie mainMovie add the following ActionScript:
this.createEmptyMovieClip("blank_mc", 10);
with (blank_mc){
_x=50;
_y=150;
}
loadMovie("form.swf", blank_mc);
As with the LoadMovieNum you can unload movies posted into the empty movie clip. All you need to do is target the empty movie clip. The following will unload content from the "blank_mc" movie created above:
unloadMovie(blank_mc);
Delay or Pause with Action Script!
![]()
var starttime = Math.floor(getTimer()/150);
var endtime = Math.floor(getTimer()/150);
while (endtime<starttime+10) {
endtime = Math.floor(getTimer()/150);
}
Transparent Flash Movies
![]()
In
Flash:
Choose
File > Publish Settings. Select the HTML tab.
Choose "Transparent" in the WindowMode setting
Publish the document.
In Dreamweaver:
Insert the Flash movie into an HTML page.
Select the Flash movie in the Design View.
In the Properties panel, choose Parameters.
For the Parameter, enter "wmode" (without quotes). For
the Value, enter "transparent".
Save the document. The HTML page is complete.
Preloader
![]()
Make 3 key frames, stick the code below in frame 2 and your stuff
in frame 3
myLoaded = Math.round(getBytesLoaded());
myTotal = Math.round(getBytesTotal());
myPercent = myLoaded/myTotal;
//myBar._width = myPercent*150;
//myText = Math.round(myPercent*100)+"%";
if (myLoaded == myTotal) {
gotoAndStop(3);
} else {
gotoAndPlay(1);
}
Loop - Call an external URL with a delay
Handy to hammer a site for hit count
![]()
function wait() { // a function called 'wait'
trace("The time is now !!"); // the action you want, in this case a trace.
getURL("http://somesite.com/","main");
}
myTimer = setInterval(wait, 30000); // calls the function after 1 second
//main is the named instance of the browser window..