Home Tutorials Forums Articles Blogs Movies Library Employment Press

<< Prev 5 | Next 5

flash webcam script

Oke, this is a raw script for dynamic updating an image that is
uploaded by your own webcam software. Script presumes the following:

1)You have a webcam
2)You upload your webcam-images too folder yourserver/webcam
3)You have selected an update every 60 seconds
4)You upload with the same name and erase the previous uploaded
5)you have created in the maintimeline a movieclip with the instance name jpg
6)you have some knowledge with flash, else visit www.marcelvandervliet.net

Script maintimeline
keyframe1:
delay = 60; //frames

jpgnum = delay + 1;

function update() {
        timer=new Date();
        timerstart=59
        timerend=timer.getSeconds();
        progres.gotoAndStop(timerend);
        if (timerend==timerstart){
                randNum = Math.random() * 1000000;
                url="webcam/cam.jpg?"+randNum;
                newmovie = "jpg" + jpgnum++;
                duplicateMovieClip("jpg", newmovie, jpgnum);
                loadMovie(url, newmovie);
        }}
// this will delete the images that are more than (delay) frames old
unloadMovie("jpg"+(jpgnum - delay));

script keyframe 2 maintimeline
update.call();
script keyframe 3 maintimeline
gotoAndPlay(2);

Posted by: marcelvandervliet | website http://www.marcelvandervliet.net
FlashAJAXBridge
/**
* @author: Eric Feminella
* @url: http://www.ericfeminella.com
* @project: FlashAJAXBridge
* ---------------------------------------------------------------------
* @usage: example javaScript methods: add functions to a .js include
* ---------------------------------------------------------------------
*    function setDivDataProvider(selectedDIV, dataProviderString)  {
*       var div = document.getElementById(selectedDIV);
*       div.innerHTML = dataProviderString + "<br />";
*    }
*
*    function setTagDataProvider(documentElement, dataProviderString) {
*       var tag = document.getElementsByTagName(documentElement);
*       tag.innerHTML = dataProviderString;
*    }
* ---------------------------------------------------------------------
*/


class com.dataProviders.FlashAJAXBridge
{
        
        private var methodObject:Object;
        
        
        public function FlashAJAXBridge()
        {
                this.methodObject = {};
        }
        
        public function setMethod(methodName:String):Void
        {
                this.methodObject[methodName];
        }
        
        public function setElementDataProvider(methodName:String, elementID:String, dataProviderObject:Object):Void
        {
                getURL("javascript: " + String(this.methodObject[methodName]) + " ('" + elementID + "', '" + dataProviderObject + "');");
        }
        
}

Posted by: Eric Feminella | website http://www.ericfeminella.com
History back - for HTML page
//Use all lines!!! (to make it work in NS)
on (release) {
        getURL ("javascript:history.back()");
}
on (press) {
        getURL ("javascript:history.back()");
}

//Or:
http://www.robertpenner.com/experiments/backbutton/backbutton.html


Posted by: Evgueni Strok | website http://www.actionscript.org
HTMLInterface
/**
* @author: Eric Feminella
* @url: http://www.ericfeminella.com
* @class HTMLInterface
* @usage: Public class which serves as a bridge between AS 3.0 and JavaScript
* create a new javascript pop-up window instance called from ActionScript 3.0
*/

package com.dataProviders {
        
        import flash.external.ExternalInterface;
        import mx.controls.TextArea;
        import flash.util.StringBuilder;
        import mx.controls.Alert;
        import com.utils.CheckFormItems;
        
        
        public class HTMLInterface
        {
                
                public static var label:String = "FLEX 2.0 | ActionScript 3.0 JavaScriptInterfaceAPI:";
                public var tf:TextArea;
                private var strBuilder:StringBuilder;
                private var scrollable:String = "no";
                private var resizeable:String = "no";
                private var toolbar:String = "no";
                
                
                public function HTMLInterface(tf:TextArea)
                {
                        this.strBuilder = new StringBuilder();
                        this.tf = tf;
                        this.main();
                }
                
                
                private function main():void
                {
                        if (!ExternalInterface.available)
                        {
                                this.addText("ExternalInterface is not available in html container");
                        }
                        else
                        {
                                try
                                {
                                        ExternalInterface.addCallback("addText", addText);
                                        this.addText("ExternalInterface is available in html container, added callback");
                                        ExternalInterface.call("init");
                                }
                                catch(error:SecurityError)
                                {
                                        this.addText("Security error encountered. Exception Handled");
                                }
                        }
                }
                
                
                public function setFeatures(type:String):void
                {
                        switch(type)
                        {
                                case "scrollable" :
                                this.scrollable == "no" ? this.scrollable = "yes" : this.scrollable = "no";
                                break;
                                case "resizeable" :
                                this.resizeable == "no" ? this.resizeable = "yes" : this.resizeable = "no";
                                break;
                                case "toolbar" :
                                this.toolbar == "no" ? this.toolbar = "yes" : this.toolbar = "no";
                                break;
                        }
                }
                
                
                public function createWindow(name:String, width:String, height:String):void
                {
                        if (!CheckFormItems.isValid(name, width, height))
                        {
                                this.addText("<b>An Error occured. You must correctly fill out all fields<b>");
                        }
                        else
                        {
                                var specs:String = "width=" + width + ",height=" + height + ",scrollable=" + this.scrollable + ",toolbar=" + this.toolbar + ",resizeable=" + this.resizeable;
                                this.openWindow(name, specs);
                        }
                }
                
                
                private function openWindow(name:String, specs:String):void
                {
                        ExternalInterface.call("openNewWindow", "invoke.html", name, specs);
                        this.addText("JavaScript function: openNewWindow(); invoked");
                }
                
                
                public function addText(str:String):void
                {
                        this.strBuilder.append(str + "\n");
                        this.tf.htmlText = strBuilder.toString();
                }
        }
}

Posted by: Eric Feminella | website http://www.ericfeminella.com
Install the plug-in Flash
//put the script between <body> & </body>


<script language="JavaScript">
<!--
function checkForShockwave()
{
        navigator.plugins.refresh();
        if ( navigator.plugins["Shockwave Flash"] ){
                parent.location.reload();
        } else {
                setTimeout( "checkForShockwave()", 1000 );
        }
}
var ShockMode = 0;
if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] && navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin) {
        if (navigator.plugins && navigator.plugins["Shockwave Flash"])
        ShockMode = 1;
}
if (!ShockMode && navigator.appName && navigator.appName.indexOf("Netscape") != - 1 && navigator.appVersion.indexOf("4.") != - 1
&& navigator.javaEnabled() && netscape.softupdate.Trigger.UpdateEnabled() && document.cookie.indexOf("StartedShockwaveInstall") == -1) {
        var jarPath = new String("");
        if (navigator.platform.indexOf("Win32") >= 0 )
        jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash32.jar"
        else if (navigator.platform.indexOf("Win16") >= 0 )
        jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflash16.jar"
        else if (navigator.platform.indexOf("MacPPC") >= 0 )
        jarPath = "http://download.macromedia.com/pub/shockwave/jars/english/silentflashppc.jar"
        if (jarPath.length) {
                netscape.softupdate.Trigger.StartSoftwareUpdate (jarPath, netscape.softupdate.Trigger.FORCE_MODE);
                document.cookie='StartedShockwaveInstall;path=/;'
                setTimeout("checkForShockwave()", 1000);
        }
}
//-->
</script>

Posted by: Becker | website http://www.arkonide.com/pageshtml/flash.html

<< Prev 5 | Next 5

Copyright 2000-2010 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.