PHP Data Recovery
Links

Code, Visual Basic, VB Excel, Electronic Surplus Parts, Electronic Circuits, Schematics, Etc.

 

Google
 
Web www.dbelectronic.com

 

 

 

Flash Action Script Files:







 

 

Flash Action Script Code: (Some Javascript also)

If all you want to do is put a link on something, here ya go:

on (release) {
getURL("http://www.yoursite.com","_blank");
}

 

Flash Preloader with a cache workaround. So you want to update your Flash file and have it show up on the net? I went through major pain! Nobody really had what I needed, so I grabbed from multiple sources, as I usually do, and made my own solution. Flash files get cached in your temporary internet files. What is that good for? Great if you do not change your content ever. If you change your content, you are stuck with a cached file where people never see the updated information. Secondly, if you use a Preloader, that may not work either. I can't remember every detail, but I can tell you that it was a work of art in my eyes to see it work!

I embedded this code into the webpage to be able to run script and call the Flash file while generating a random number so the computer will not find it in the temporary internet files. Insert it wherever you want:

<script type="text/javascript">
<!--
document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="366" height="299" align="right" class="par_padding">');
document.write('<param name="movie" value="Your File.swf?r=' + Math.round(Math.random() * 99999) + '">');
document.write('<param name="quality" value="high">');
document.write('<embed src="Your File.swf?r=' + Math.round(Math.random() * 99999) + '" width="366" height="299" align="right" quality="high" class="par_padding" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>');
document.write('</object>');
//-->
</script>

Next, this is placed in the first frame of the Action Script. You have to include the Security code as well, otherwise some message comes up. Then again, it might work just fine for you:

System.security.allowDomain("http://Your Website.com");

loadMovie("http://Your Website.com/Your File.swf?r="+ Math.round(Math.random() * 99999) + getTimer(), _root.Pictures_mc);

The timer is a standard Flash function that gets the amount of time in milliseconds that the file has been running. Thus, you get a pretty darn random number. ENJOY!

 

Now to use the above code in context, the following will give you the steps for actually coding the preloader timeout etc. What happens is that the movie is loaded and variables are initialized. Then I get the total size of the file, and the amount downloaded so far.

Frame#:

  1. The variables are initialized and movie is loaded.
    var Bypass:Number = 0; //Initializing the number which will run a short time
    var Timeout:Number = 0

    System.security.allowDomain("http://Your Website.com");

    loadMovie("http://Your Website.com/Your File.swf?r="+ Math.round(Math.random() * 99999) + getTimer(), _root.Pictures_mc);

  2. Empty

  3. Get the size of the file and the amount downloaded:
    _PicLoaded = _root.Pictures_mc.getBytesLoaded();
    _PicTotal = _root.Pictures_mc.getBytesTotal();

  4. Check the status again:
    _PicLoaded = _root.Pictures_mc.getBytesLoaded();
    _PicTotal = _root.Pictures_mc.getBytesTotal();

  5. Calculate the percentage downloaded and display the value:
    percent = int((_PicLoaded / _PicTotal)*100);
    LoadStatus = percent+"% Loaded";

  6. This frame is labeled "LoadPic", and it is used to keep checking the status. It comes from Frame 8:
    _PicLoaded = _root.Pictures_mc.getBytesLoaded();
    _PicTotal = _root.Pictures_mc.getBytesTotal();

  7. Check the status again:
    _PicLoaded = _root.Pictures_mc.getBytesLoaded();
    _PicTotal = _root.Pictures_mc.getBytesTotal();

  8. Here we get some good stuff:
    percent = int((_PicLoaded / _PicTotal)*100); // Calculate the percentage downloaded and load it on the screen.
    LoadStatus = percent+"% Loaded";

    // Here I check if it is completely loaded. If so it goes to the "Start" Frame, the last one, and the code stops. The loaded movie then starts.
    if (percent == 100) {
    _root.gotoAndPlay("Start");
    } else if (percent == 0 && Bypass > 19) { //If I still have 0% downloaded, thenI look at that Bypass variable setup from the first frame. If this number fails this test greater than 19 times, then I place a message up that is the Win98Text noted above.
    _root.gotoAndPlay("Windows98");
    } else {
    Bypass = Bypass+1; //Increment Bypass if not at 100 and still under 19.
    _root.gotoAndPlay("LoadPic");
    }

  9. What I found in the past is that Windows 98 may not work as well with this Action Script, so I made a built a timer to alert the viewer if this will take a bit longer than expected. The frame has has the text a dynamic text box name Win98Text:
    Win98Text = "If you are seeing this, you may have Windows 98, and the progress will not show. The movie should load in a few moments. Thank you for your patience.";
    LoadStatus = Timeout; //If Timeout has occured, then it will be known.

  10. Here I incremement the Timeout variable every time this frame comes around.
    Timeout = Timeout+1;

    if (Timeout >= 100) { //This looks at the realistic occurrence of the timer going over 100, and thus it goes to the next frame and stops the preloader.
    nextFrame;
    } else {
    _root.gotoAndPlay("Win98"); //Otherwise it kicks out the message again on Frame" Win98", #9.
    }

  11. This frame stops the file and the loaded movie plays:
    stop();

Simple right? Took me a long time to figure it out..... as usual. :o)

 

So want to play an FLV.? You need to add your Mediacontroller and a MedaDisplay :

Frame #:

  1. Put your buttons with code:
    on(release){
    VideoToPlay = "Your File.swf.flv";
    TimePlay = 22.5; //Set your play time in seconds.
    gotoandplay(3);
    }
  2. Here the buttons are still active but the file is stopped:
    //Initialize variables
    var VideoToPlay:String;
    var TimePlay:Number;
    stop();
  3. This frame must have your MediPlayer and the MediaController. Put this code in the MediaDisplay:
    on (complete) { //After the movie is completed it goes to Frame 1.
    //Movieclip GotoAndStop Behavior
    _root.Pictures_mc.gotoAndPlay(1);
    //End Behavior
    }

    on (load) { //When the frame loads, we have to associate the MediaController to the MediaDisplay.
    // AssociateController Behavior
    this.associateController(this._parent.controller);
    // End AssociateController Behavior
    }

    This code gets the movie playing. Put this on the fram code:
    //Play video on enter to frame.
    display.setMedia(VideoToPlay , "FLV");
    display.play(VideoToPlay);
    display.totalTime = TimePlay;
    stop();
  4. Always remember to add this code to a button if you need to return home!:
    // Go Back Home

    on(release){
    gotoAndPlay("Home");
    }

I hope this was useful to you. It took me a long time to do. I am not super code guy though.

 

 

Flash Files With Great Effects:

Ripple Effect.fla: I did not make this, but it is the coolest thing for water effects. Actually very simple.
Tach.fla: Great little tachometer I made up simulating a race car.
Lightening.fla: I could not find any lightening, so I made this up.
Fire.fla: Another great effect I found.
Water.fla: An interesting water example. Good for a blocky look.
 
 

 

Google
 
Web www.dbelectronic.com

PHP Data Recovery
Links


Contact | Copyright 2007 DBElectronics
All Rights Reserved
Some Images used by permission from NASA.