Remove old Hotspot library - refs #7705
parent
478b14d7f7
commit
bfb797c5a4
@ -1,455 +0,0 @@ |
||||
/* |
||||
Macromedia(r) Flash(r) JavaScript Integration Kit License |
||||
|
||||
|
||||
Copyright (c) 2005 Macromedia, inc. All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this |
||||
list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation and/or |
||||
other materials provided with the distribution. |
||||
|
||||
3. The end-user documentation included with the redistribution, if any, must |
||||
include the following acknowledgment: |
||||
|
||||
"This product includes software developed by Macromedia, Inc. |
||||
(http://www.macromedia.com)."
|
||||
|
||||
Alternately, this acknowledgment may appear in the software itself, if and |
||||
wherever such third-party acknowledgments normally appear. |
||||
|
||||
4. The name Macromedia must not be used to endorse or promote products derived |
||||
from this software without prior written permission. For written permission, |
||||
please contact devrelations@macromedia.com. |
||||
|
||||
5. Products derived from this software may not be called "Macromedia" or |
||||
"Macromedia Flash", nor may "Macromedia" or "Macromedia Flash" appear in their |
||||
name. |
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, |
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MACROMEDIA OR |
||||
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
||||
DAMAGE. |
||||
|
||||
-- |
||||
|
||||
This code is part of the Flash / JavaScript Integration Kit: |
||||
http://www.macromedia.com/go/flashjavascript/
|
||||
|
||||
Created by: |
||||
|
||||
Christian Cantrell |
||||
http://weblogs.macromedia.com/cantrell/
|
||||
mailto:cantrell@macromedia.com |
||||
|
||||
Mike Chambers |
||||
http://weblogs.macromedia.com/mesh/
|
||||
mailto:mesh@macromedia.com |
||||
|
||||
Macromedia |
||||
*/ |
||||
|
||||
/** |
||||
* Create a new Exception object. |
||||
* name: The name of the exception. |
||||
* message: The exception message. |
||||
*/ |
||||
function Exception(name, message) |
||||
{ |
||||
if (name) |
||||
this.name = name; |
||||
if (message) |
||||
this.message = message; |
||||
} |
||||
|
||||
/** |
||||
* Set the name of the exception.
|
||||
*/ |
||||
Exception.prototype.setName = function(name) |
||||
{ |
||||
this.name = name; |
||||
} |
||||
|
||||
/** |
||||
* Get the exception's name.
|
||||
*/ |
||||
Exception.prototype.getName = function() |
||||
{ |
||||
return this.name; |
||||
} |
||||
|
||||
/** |
||||
* Set a message on the exception.
|
||||
*/ |
||||
Exception.prototype.setMessage = function(msg) |
||||
{ |
||||
this.message = msg; |
||||
} |
||||
|
||||
/** |
||||
* Get the exception message.
|
||||
*/ |
||||
Exception.prototype.getMessage = function() |
||||
{ |
||||
return this.message; |
||||
} |
||||
|
||||
/** |
||||
* Generates a browser-specific Flash tag. Create a new instance, set whatever |
||||
* properties you need, then call either toString() to get the tag as a string, or |
||||
* call write() to write the tag out. |
||||
*/ |
||||
|
||||
/** |
||||
* Creates a new instance of the FlashTag. |
||||
* src: The path to the SWF file. |
||||
* width: The width of your Flash content. |
||||
* height: the height of your Flash content. |
||||
*/ |
||||
function FlashTag(src, width, height) |
||||
{ |
||||
this.src = src; |
||||
this.width = width; |
||||
this.height = height; |
||||
this.version = '7,0,14,0'; |
||||
this.id = null; |
||||
this.bgcolor = 'ffffff'; |
||||
this.flashVars = null; |
||||
} |
||||
|
||||
/** |
||||
* Sets the Flash version used in the Flash tag. |
||||
*/ |
||||
FlashTag.prototype.setVersion = function(v) |
||||
{ |
||||
this.version = v; |
||||
} |
||||
|
||||
/** |
||||
* Sets the ID used in the Flash tag. |
||||
*/ |
||||
FlashTag.prototype.setId = function(id) |
||||
{ |
||||
this.id = id; |
||||
} |
||||
|
||||
/** |
||||
* Sets the background color used in the Flash tag. |
||||
*/ |
||||
FlashTag.prototype.setBgcolor = function(bgc) |
||||
{ |
||||
this.bgcolor = bgc; |
||||
} |
||||
|
||||
/** |
||||
* Sets any variables to be passed into the Flash content.
|
||||
*/ |
||||
FlashTag.prototype.setFlashvars = function(fv) |
||||
{ |
||||
this.flashVars = fv; |
||||
} |
||||
|
||||
/** |
||||
* Get the Flash tag as a string.
|
||||
*/ |
||||
FlashTag.prototype.toString = function() |
||||
{ |
||||
var ie = (navigator.appName.indexOf ("Microsoft") != -1) ? 1 : 0; |
||||
var flashTag = new String(); |
||||
if (ie) |
||||
{ |
||||
flashTag += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '; |
||||
if (this.id != null) |
||||
{ |
||||
flashTag += 'id="'+this.id+'" '; |
||||
} |
||||
flashTag += 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this.version+'" '; |
||||
flashTag += 'width="'+this.width+'" '; |
||||
flashTag += 'height="'+this.height+'">'; |
||||
flashTag += '<param name="movie" value="'+this.src+'"/>'; |
||||
flashTag += '<param name="quality" value="high"/>'; |
||||
flashTag += '<param name="bgcolor" value="#'+this.bgcolor+'"/>'; |
||||
if (this.flashVars != null) |
||||
{ |
||||
flashTag += '<param name="flashvars" value="'+this.flashVars+'"/>'; |
||||
} |
||||
flashTag += '</object>'; |
||||
} |
||||
else |
||||
{ |
||||
flashTag += '<embed src="'+this.src+'" '; |
||||
flashTag += 'quality="high" ';
|
||||
flashTag += 'bgcolor="#'+this.bgcolor+'" '; |
||||
flashTag += 'width="'+this.width+'" '; |
||||
flashTag += 'height="'+this.height+'" '; |
||||
flashTag += 'type="application/x-shockwave-flash" '; |
||||
if (this.flashVars != null) |
||||
{ |
||||
flashTag += 'flashvars="'+this.flashVars+'" '; |
||||
} |
||||
if (this.id != null) |
||||
{ |
||||
flashTag += 'name="'+this.id+'" '; |
||||
} |
||||
flashTag += 'pluginspage="http://www.macromedia.com/go/getflashplayer">'; |
||||
flashTag += '</embed>'; |
||||
} |
||||
return flashTag; |
||||
} |
||||
|
||||
/** |
||||
* Write the Flash tag out. Pass in a reference to the document to write to.
|
||||
*/ |
||||
FlashTag.prototype.write = function(doc) |
||||
{ |
||||
doc.write(this.toString()); |
||||
} |
||||
|
||||
/** |
||||
* The FlashSerializer serializes JavaScript variables of types object, array, string, |
||||
* number, date, boolean, null or undefined into XML.
|
||||
*/ |
||||
|
||||
/** |
||||
* Create a new instance of the FlashSerializer. |
||||
* useCdata: Whether strings should be treated as character data. If false, strings are simply XML encoded. |
||||
*/ |
||||
function FlashSerializer(useCdata) |
||||
{ |
||||
this.useCdata = useCdata; |
||||
} |
||||
|
||||
/** |
||||
* Serialize an array into a format that can be deserialized in Flash. Supported data types are object, |
||||
* array, string, number, date, boolean, null, and undefined. Returns a string of serialized data. |
||||
*/ |
||||
FlashSerializer.prototype.serialize = function(args) |
||||
{ |
||||
var qs = new String(); |
||||
|
||||
for (var i = 0; i < args.length; ++i) |
||||
{ |
||||
switch(typeof(args[i])) |
||||
{ |
||||
case 'undefined': |
||||
qs += 't'+(i)+'=undf'; |
||||
break; |
||||
case 'string': |
||||
qs += 't'+(i)+'=str&d'+(i)+'='+escape(args[i]); |
||||
break; |
||||
case 'number': |
||||
qs += 't'+(i)+'=num&d'+(i)+'='+escape(args[i]); |
||||
break; |
||||
case 'boolean': |
||||
qs += 't'+(i)+'=bool&d'+(i)+'='+escape(args[i]); |
||||
break; |
||||
case 'object': |
||||
if (args[i] == null) |
||||
{ |
||||
qs += 't'+(i)+'=null'; |
||||
} |
||||
else if (args[i] instanceof Date) |
||||
{ |
||||
qs += 't'+(i)+'=date&d'+(i)+'='+escape(args[i].getTime()); |
||||
} |
||||
else // array or object
|
||||
{ |
||||
try |
||||
{ |
||||
qs += 't'+(i)+'=xser&d'+(i)+'='+escape(this._serializeXML(args[i])); |
||||
} |
||||
catch (exception) |
||||
{ |
||||
throw new Exception("FlashSerializationException", |
||||
"The following error occurred during complex object serialization: " + exception.getMessage()); |
||||
} |
||||
} |
||||
break; |
||||
default: |
||||
throw new Exception("FlashSerializationException", |
||||
"You can only serialize strings, numbers, booleans, dates, objects, arrays, nulls, and undefined."); |
||||
} |
||||
|
||||
if (i != (args.length - 1)) |
||||
{ |
||||
qs += '&'; |
||||
} |
||||
} |
||||
|
||||
return qs; |
||||
} |
||||
|
||||
/** |
||||
* Private |
||||
*/ |
||||
FlashSerializer.prototype._serializeXML = function(obj) |
||||
{ |
||||
var doc = new Object(); |
||||
doc.xml = '<fp>';
|
||||
this._serializeNode(obj, doc, null); |
||||
doc.xml += '</fp>';
|
||||
return doc.xml; |
||||
} |
||||
|
||||
/** |
||||
* Private |
||||
*/ |
||||
FlashSerializer.prototype._serializeNode = function(obj, doc, name) |
||||
{ |
||||
switch(typeof(obj)) |
||||
{ |
||||
case 'undefined': |
||||
doc.xml += '<undf'+this._addName(name)+'/>'; |
||||
break; |
||||
case 'string': |
||||
doc.xml += '<str'+this._addName(name)+'>'+this._escapeXml(obj)+'</str>'; |
||||
break; |
||||
case 'number': |
||||
doc.xml += '<num'+this._addName(name)+'>'+obj+'</num>'; |
||||
break; |
||||
case 'boolean': |
||||
doc.xml += '<bool'+this._addName(name)+' val="'+obj+'"/>'; |
||||
break; |
||||
case 'object': |
||||
if (obj == null) |
||||
{ |
||||
doc.xml += '<null'+this._addName(name)+'/>'; |
||||
} |
||||
else if (obj instanceof Date) |
||||
{ |
||||
doc.xml += '<date'+this._addName(name)+'>'+obj.getTime()+'</date>'; |
||||
} |
||||
else if (obj instanceof Array) |
||||
{ |
||||
doc.xml += '<array'+this._addName(name)+'>'; |
||||
for (var i = 0; i < obj.length; ++i) |
||||
{ |
||||
this._serializeNode(obj[i], doc, null); |
||||
} |
||||
doc.xml += '</array>'; |
||||
} |
||||
else |
||||
{ |
||||
doc.xml += '<obj'+this._addName(name)+'>'; |
||||
for (var n in obj) |
||||
{ |
||||
if (typeof(obj[n]) == 'function') |
||||
continue; |
||||
this._serializeNode(obj[n], doc, n); |
||||
} |
||||
doc.xml += '</obj>'; |
||||
} |
||||
break; |
||||
default: |
||||
throw new Exception("FlashSerializationException", |
||||
"You can only serialize strings, numbers, booleans, objects, dates, arrays, nulls and undefined"); |
||||
break; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Private |
||||
*/ |
||||
FlashSerializer.prototype._addName= function(name) |
||||
{ |
||||
if (name != null) |
||||
{ |
||||
return ' name="'+name+'"'; |
||||
} |
||||
return ''; |
||||
} |
||||
|
||||
/** |
||||
* Private |
||||
*/ |
||||
FlashSerializer.prototype._escapeXml = function(str) |
||||
{ |
||||
if (this.useCdata) |
||||
return '<![CDATA['+str+']]>'; |
||||
else |
||||
return str.replace(/&/g,'&').replace(/</g,'<'); |
||||
} |
||||
|
||||
/** |
||||
* The FlashProxy object is what proxies function calls between JavaScript and Flash. |
||||
* It handles all argument serialization issues. |
||||
*/ |
||||
|
||||
/** |
||||
* Instantiates a new FlashProxy object. Pass in a uniqueID and the name (including the path) |
||||
* of the Flash proxy SWF. The ID is the same ID that needs to be passed into your Flash content as lcId. |
||||
*/ |
||||
function FlashProxy(uid, proxySwfName) |
||||
{ |
||||
this.uid = uid; |
||||
this.proxySwfName = proxySwfName; |
||||
this.flashSerializer = new FlashSerializer(false); |
||||
} |
||||
|
||||
/** |
||||
* Call a function in your Flash content. Arguments should be: |
||||
* 1. ActionScript function name to call, |
||||
* 2. any number of additional arguments of type object, |
||||
* array, string, number, boolean, date, null, or undefined.
|
||||
*/ |
||||
FlashProxy.prototype.call = function() |
||||
{ |
||||
|
||||
if (arguments.length == 0) |
||||
{ |
||||
throw new Exception("Flash Proxy Exception", |
||||
"The first argument should be the function name followed by any number of additional arguments."); |
||||
} |
||||
|
||||
var qs = 'lcId=' + escape(this.uid) + '&functionName=' + escape(arguments[0]); |
||||
|
||||
if (arguments.length > 1) |
||||
{ |
||||
var justArgs = new Array(); |
||||
for (var i = 1; i < arguments.length; ++i) |
||||
{ |
||||
justArgs.push(arguments[i]); |
||||
} |
||||
qs += ('&' + this.flashSerializer.serialize(justArgs)); |
||||
} |
||||
|
||||
var divName = '_flash_proxy_' + this.uid; |
||||
if(!document.getElementById(divName)) |
||||
{ |
||||
var newTarget = document.createElement("div"); |
||||
newTarget.id = divName; |
||||
document.body.appendChild(newTarget); |
||||
} |
||||
var target = document.getElementById(divName); |
||||
var ft = new FlashTag(this.proxySwfName, 1, 1); |
||||
ft.setVersion('6,0,65,0'); |
||||
ft.setFlashvars(qs); |
||||
target.innerHTML = ft.toString(); |
||||
} |
||||
|
||||
/** |
||||
* This is the function that proxies function calls from Flash to JavaScript. |
||||
* It is called implicitly. |
||||
*/ |
||||
FlashProxy.callJS = function() |
||||
{ |
||||
var functionToCall = eval(arguments[0]); |
||||
var argArray = new Array(); |
||||
for (var i = 1; i < arguments.length; ++i) |
||||
{ |
||||
argArray.push(arguments[i]); |
||||
} |
||||
functionToCall.apply(functionToCall, argArray); |
||||
} |
||||
|
Binary file not shown.
@ -1,199 +0,0 @@ |
||||
/* |
||||
JavaScriptProxy.as |
||||
|
||||
Part of the Flash / JavaScript Integration Kit |
||||
http://www.macromedia.com/go/flashjavascript |
||||
|
||||
Created by: |
||||
|
||||
Mike Chambers |
||||
http://weblogs.macromedia.com/mesh/ |
||||
mesh@macromedia.com |
||||
|
||||
Christian Cantrell |
||||
http://weblogs.macromedia.com/cantrell/ |
||||
cantrell@macromedia.com |
||||
|
||||
---- |
||||
Macromedia(r) Flash(r)./ JavaScript Integration Kit License |
||||
|
||||
|
||||
Copyright (c) 2005 Macromedia, inc. All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this |
||||
list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation and/or |
||||
other materials provided with the distribution. |
||||
|
||||
3. The end-user documentation included with the redistribution, if any, must |
||||
include the following acknowledgment: |
||||
|
||||
"This product includes software developed by Macromedia, Inc. |
||||
(http://www.macromedia.com)." |
||||
|
||||
Alternately, this acknowledgment may appear in the software itself, if and |
||||
wherever such third-party acknowledgments normally appear. |
||||
|
||||
4. The name Macromedia must not be used to endorse or promote products derived |
||||
from this software without prior written permission. For written permission, |
||||
please contact devrelations@macromedia.com. |
||||
|
||||
5. Products derived from this software may not be called "Macromedia" or |
||||
“Macromedia Flash”, nor may "Macromedia" or “Macromedia Flash” appear in their |
||||
name. |
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, |
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MACROMEDIA OR |
||||
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
||||
DAMAGE. |
||||
|
||||
*/ |
||||
|
||||
//import the serializer class |
||||
import com.macromedia.javascript.JavaScriptSerializer; |
||||
|
||||
class com.macromedia.javascript.JavaScriptProxy |
||||
{ |
||||
private var instance:Object; |
||||
private var lcId:String; |
||||
private var receiving_lc:LocalConnection |
||||
|
||||
|
||||
/* |
||||
Constructor for Class |
||||
Public |
||||
|
||||
Takes two arguments. |
||||
|
||||
lcId : REQUIRED : an id passed in from HTML / Javascript that is used to |
||||
communicate with the gateway swf. The same id must be passed into |
||||
the gateway swf. |
||||
|
||||
instance : the object / class instance that function call will be proxied to. |
||||
This is required if function calls will be made from JavaScript |
||||
to Flash |
||||
|
||||
*/ |
||||
function JavaScriptProxy(lcId:String, instance:Object) |
||||
{ |
||||
|
||||
//if either argument is undefined, JavaScript to Flash calls won't work. |
||||
//So we just return. |
||||
// |
||||
//Flash to JavaScript calls will still work |
||||
if(lcId == undefined || instance == undefined) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
this.instance = instance; |
||||
|
||||
this.lcId = lcId; |
||||
|
||||
receiving_lc = new LocalConnection(); |
||||
|
||||
//the incoming function call will occur in the scope of receiving_lc, so we have |
||||
//to set a property to let us get back to the correct scope. |
||||
receiving_lc.controller = this; |
||||
|
||||
receiving_lc.callFlash = callFlash; |
||||
|
||||
//listen for incoming function calls |
||||
receiving_lc.connect(this.lcId); |
||||
} |
||||
|
||||
/* |
||||
callFlash |
||||
Private |
||||
|
||||
This is called by the FlashProxy in JavaScript to make a functon call into |
||||
the Flash content. |
||||
*/ |
||||
private function callFlash(args:Array):Void |
||||
{ |
||||
//get a reference to the correct scope (this method is called in the scope |
||||
//of the local connection object) |
||||
var con:Object = this["controller"]; |
||||
|
||||
var functionName:Object = args.shift(); |
||||
|
||||
var f:Function = con.instance[functionName]; |
||||
|
||||
//call the function in the correct scope, passing the arguments |
||||
f.apply(con.instance, args); |
||||
} |
||||
|
||||
/* |
||||
This proxies function calls to the server, which allows you to call JavaScript |
||||
functions as if they were functions on JavaScriptProxy instance. |
||||
|
||||
i.e. |
||||
|
||||
var j:JavaScriptProxy = new JavaScriptProxy(); |
||||
|
||||
j.jsFunction("foo", [1, 2]); |
||||
*/ |
||||
public function __resolve(functionName:String):Function |
||||
{ |
||||
var f:Function = function() |
||||
{ |
||||
arguments.splice(0,0, functionName); |
||||
var f:Function = call; |
||||
f.apply(this, arguments); |
||||
}; |
||||
|
||||
return f; |
||||
} |
||||
|
||||
/* |
||||
call |
||||
public |
||||
|
||||
This is used to call functions within JavaScript. |
||||
|
||||
functionName : A string of the name of the function being called in JavaScript. |
||||
|
||||
a1, a2 ... an : subsequesnt arguments will be passed to the JavaScript function. |
||||
|
||||
Example: |
||||
|
||||
var j:JavaScriptProxy = new JavaScriptProxy(); |
||||
|
||||
j.call("jsFunction", "foo", [1, 2]); |
||||
*/ |
||||
public function call(functionName:String):Void |
||||
{ |
||||
var len:Number = arguments.length; |
||||
|
||||
var argsString:String = ""; |
||||
|
||||
//Serialize the arguments |
||||
for(var i:Number = 0; i < len; i++) |
||||
{ |
||||
argsString += JavaScriptSerializer.serializeItem(arguments[i]); |
||||
|
||||
if(i != len - 1) |
||||
{ |
||||
argsString += ","; |
||||
} |
||||
} |
||||
|
||||
//Created the javascript URL |
||||
var callString:String = "javascript:FlashProxy.callJS(" + argsString + ");"; |
||||
|
||||
//call out into the HTML / JavaScript environment |
||||
getURL(callString); |
||||
} |
||||
|
||||
} |
@ -1,478 +0,0 @@ |
||||
/* |
||||
JavaScriptSerializer.as |
||||
|
||||
Part of the Flash / JavaScript Integration Kit |
||||
http://www.macromedia.com/go/flashjavascript |
||||
|
||||
Created by: |
||||
|
||||
Mike Chambers |
||||
http://weblogs.macromedia.com/mesh/ |
||||
mesh@macromedia.com |
||||
|
||||
Christian Cantrell |
||||
http://weblogs.macromedia.com/cantrell/ |
||||
cantrell@macromedia.com |
||||
|
||||
---- |
||||
Macromedia(r) Flash(r)./ JavaScript Integration Kit License |
||||
|
||||
|
||||
Copyright (c) 2005 Macromedia, inc. All rights reserved. |
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, |
||||
are permitted provided that the following conditions are met: |
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this |
||||
list of conditions and the following disclaimer. |
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright notice, |
||||
this list of conditions and the following disclaimer in the documentation and/or |
||||
other materials provided with the distribution. |
||||
|
||||
3. The end-user documentation included with the redistribution, if any, must |
||||
include the following acknowledgment: |
||||
|
||||
"This product includes software developed by Macromedia, Inc. |
||||
(http://www.macromedia.com)." |
||||
|
||||
Alternately, this acknowledgment may appear in the software itself, if and |
||||
wherever such third-party acknowledgments normally appear. |
||||
|
||||
4. The name Macromedia must not be used to endorse or promote products derived |
||||
from this software without prior written permission. For written permission, |
||||
please contact devrelations@macromedia.com. |
||||
|
||||
5. Products derived from this software may not be called "Macromedia" or |
||||
“Macromedia Flash”, nor may "Macromedia" or “Macromedia Flash” appear in their |
||||
name. |
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, |
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND |
||||
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL MACROMEDIA OR |
||||
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
||||
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT |
||||
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
||||
DAMAGE. |
||||
|
||||
*/ |
||||
|
||||
class com.macromedia.javascript.JavaScriptSerializer |
||||
{ |
||||
|
||||
/**************** Serialization Methods ****************/ |
||||
|
||||
/* |
||||
Static function that serializes any supported data types. |
||||
|
||||
Returns a String |
||||
*/ |
||||
public static function serializeItem(item:Object):String |
||||
{ |
||||
var type:String = typeof(item); |
||||
var out:String; |
||||
|
||||
switch (type) |
||||
{ |
||||
case "string": |
||||
{ |
||||
out = JavaScriptSerializer.serializeString(String(item)); |
||||
break; |
||||
} |
||||
case "number": |
||||
{ |
||||
out = JavaScriptSerializer.serializeNumber(Number(item)); |
||||
break; |
||||
} |
||||
case "boolean": |
||||
{ |
||||
out = JavaScriptSerializer.serializeBoolean(Boolean(item)); |
||||
break; |
||||
} |
||||
case "null": |
||||
{ |
||||
out = JavaScriptSerializer.serializeNull(); |
||||
break; |
||||
} |
||||
case "undefined": |
||||
{ |
||||
out = JavaScriptSerializer.serializeUndefined(); |
||||
break; |
||||
} |
||||
case "object": |
||||
{ |
||||
if(item instanceof Date) |
||||
{ |
||||
out = JavaScriptSerializer.serializeDate(new Date(item.getTime())); |
||||
} |
||||
else if(item instanceof Array) |
||||
{ |
||||
out = JavaScriptSerializer.serializeArray(item); |
||||
} |
||||
else |
||||
{ |
||||
//treat it as regular Object |
||||
out = JavaScriptSerializer.serializeObject(item); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
} |
||||
|
||||
return out; |
||||
|
||||
} |
||||
|
||||
/* Serializes an Object */ |
||||
public static function serializeObject(o:Object):String |
||||
{ |
||||
var sb:String = "{"; |
||||
|
||||
for(var x:String in o) |
||||
{ |
||||
|
||||
//dont include functions |
||||
if(typeof(x[o]) == "function") |
||||
{ |
||||
continue; |
||||
} |
||||
|
||||
sb += x + ":" + serializeItem(o[x]) + ","; |
||||
} |
||||
|
||||
//remove the trailing "," |
||||
if(sb.substring(sb.length - 1) == ",") |
||||
{ |
||||
sb = sb.substring(0, sb.length - 1); |
||||
} |
||||
|
||||
sb += "}"; |
||||
|
||||
return sb; |
||||
} |
||||
|
||||
/* Serializes an Array */ |
||||
//not typed since I can't cast an object to Array |
||||
public static function serializeArray(o):String |
||||
{ |
||||
var len:Number = o.length; |
||||
|
||||
var sb:String = "["; |
||||
|
||||
for(var i:Number = 0; i < len; i++) |
||||
{ |
||||
sb += serializeItem(o[i]); |
||||
|
||||
if(i != len - 1) |
||||
{ |
||||
sb += ","; |
||||
} |
||||
} |
||||
|
||||
sb += "]"; |
||||
|
||||
return sb; |
||||
} |
||||
|
||||
/* Serializes a String */ |
||||
public static function serializeString(s:String):String |
||||
{ |
||||
return "'" + s + "'"; |
||||
} |
||||
|
||||
/* Serializes a Number */ |
||||
public static function serializeNumber(n:Number):String |
||||
{ |
||||
return String(n); |
||||
} |
||||
|
||||
/* Serializes a Boolean value */ |
||||
public static function serializeBoolean(b:Boolean):String |
||||
{ |
||||
return String(b); |
||||
} |
||||
|
||||
/* Serializes undefined */ |
||||
public static function serializeUndefined(Void):String |
||||
{ |
||||
return "undefined"; |
||||
} |
||||
|
||||
/* Serializes null */ |
||||
public static function serializeNull(Void):String |
||||
{ |
||||
return "null"; |
||||
} |
||||
|
||||
/* Serializes a Date */ |
||||
public static function serializeDate(d:Date):String |
||||
{ |
||||
return "new Date(" + d.getTime() + ")"; |
||||
} |
||||
|
||||
|
||||
/**************** De-Serialization Methods ****************/ |
||||
|
||||
/* |
||||
Static function that de-serializes any supported data types. |
||||
|
||||
Returns a String |
||||
*/ |
||||
public static function deserializeItem(type:String, data:String):Object |
||||
{ |
||||
var out:Object; |
||||
|
||||
switch (type) |
||||
{ |
||||
case "str": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeString(data); |
||||
break; |
||||
} |
||||
case "num": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeNumber(data); |
||||
break; |
||||
} |
||||
case "bool": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeBoolean(data); |
||||
break; |
||||
} |
||||
case "null": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeNull(); |
||||
break; |
||||
} |
||||
case "undf": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeUndefined(); |
||||
break; |
||||
} |
||||
case "date": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeDate(data); |
||||
|
||||
break; |
||||
} |
||||
case "xser": |
||||
{ |
||||
out = JavaScriptSerializer.deserializeXMLSerializedItem(data); |
||||
|
||||
trace(data); |
||||
|
||||
break; |
||||
} |
||||
|
||||
} |
||||
|
||||
return out; |
||||
} |
||||
|
||||
/* Deserializes a String */ |
||||
public static function deserializeString(s:String):String |
||||
{ |
||||
return s; |
||||
} |
||||
|
||||
/* Deserializes a Number */ |
||||
public static function deserializeNumber(s:String):Number |
||||
{ |
||||
return Number(s); |
||||
} |
||||
|
||||
/* Deserializes a Boolean Value */ |
||||
public static function deserializeBoolean(s:String):String |
||||
{ |
||||
return Boolean(s); |
||||
} |
||||
|
||||
/* Deserializes undefined */ |
||||
//returns undefined |
||||
public static function deserializeUndefined(s:String) |
||||
{ |
||||
return undefined; |
||||
} |
||||
|
||||
/* Deserializes null */ |
||||
//returns null |
||||
public static function deserializeNull(s:String) |
||||
{ |
||||
return null; |
||||
} |
||||
|
||||
/* Deserializes a Date */ |
||||
public static function deserializeDate(s:String):Date |
||||
{ |
||||
return new Date(Number(s)); |
||||
} |
||||
|
||||
|
||||
/**************** De-Serialization XML Methods ****************/ |
||||
|
||||
/* |
||||
The methods below are for deserializing data serialized in XML format. |
||||
|
||||
This is used for serializing Objects and Arrays |
||||
*/ |
||||
|
||||
|
||||
/* |
||||
Static function that de-serializes any supported XML serialized data types. |
||||
|
||||
Returns a String |
||||
*/ |
||||
public static function deserializeXMLSerializedItem(data:String):Object |
||||
{ |
||||
var x:XML = new XML(); |
||||
x.ignoreWhite = true; |
||||
x.parseXML(data); |
||||
|
||||
var out:Object = parseNode(x.firstChild.firstChild, new Object); |
||||
|
||||
return out; |
||||
} |
||||
|
||||
/* recursive function that parses the xml tree */ |
||||
public static function parseNode(x:XMLNode, o:Object):Object |
||||
{ |
||||
|
||||
var nodeName:String = x.nodeName; |
||||
var nodeValue:String = x.firstChild.nodeValue; |
||||
var varName:String = x.attributes["name"]; |
||||
|
||||
var children:Array = x.childNodes; |
||||
var len:Number = children.length; |
||||
|
||||
switch(nodeName) |
||||
{ |
||||
case "obj": |
||||
{ |
||||
if(varName == null) |
||||
{ |
||||
o = new Object(); |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = new Object(); |
||||
} |
||||
break; |
||||
} |
||||
case "str": |
||||
{ |
||||
if(varName == undefined) |
||||
{ |
||||
o = String(nodeValue); |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = nodeValue; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case "num": |
||||
{ |
||||
if(varName == null) |
||||
{ |
||||
o = Number(nodeValue); |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = Number(nodeValue); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case "bool": |
||||
{ |
||||
if(varName == null) |
||||
{ |
||||
o = Boolean(nodeValue); |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = Boolean(nodeValue); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case "null": |
||||
{ |
||||
if(varName == null) |
||||
{ |
||||
o = null; |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = null; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case "undf": |
||||
{ |
||||
if(varName == null) |
||||
{ |
||||
o = undefined; |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = undefined; |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case "date": |
||||
{ |
||||
if(varName == null) |
||||
{ |
||||
o = new Date(Number(nodeValue)); |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = new Date(Number(nodeValue)); |
||||
} |
||||
|
||||
break; |
||||
} |
||||
case "array": |
||||
{ |
||||
//this is not typed because the compiler gets confused about |
||||
//the explicit type change for o below. |
||||
var arr; |
||||
if(varName == null) |
||||
{ |
||||
o = new Array(); |
||||
arr = o; |
||||
} |
||||
else |
||||
{ |
||||
o[varName] = new Array(); |
||||
arr = o[varName]; |
||||
} |
||||
|
||||
for(var x:Number = 0; x < len; x++) |
||||
{ |
||||
arr.push(parseNode(children[x], o)); |
||||
} |
||||
|
||||
return arr; |
||||
} |
||||
} |
||||
|
||||
for(var i:Number = 0; i < len; i++) |
||||
{ |
||||
parseNode(children[i], o); |
||||
} |
||||
|
||||
|
||||
return o; |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -1,104 +0,0 @@ |
||||
// in je FORM-tag voor de hotspots: onSubmit="return validateFlashVar('MINIMUM_AANTAL_CLICKS');
|
||||
|
||||
var flashVar = 1; |
||||
|
||||
var lcId = new Date().getTime(); |
||||
//var flashProxy = new FlashProxy(lcId, "JavaScriptFlashGateway.swf");
|
||||
|
||||
function validateFlashVar(counter, lang_1, lang_2) |
||||
{ |
||||
return true; |
||||
//alert(counter);
|
||||
//alert(flashVar);
|
||||
|
||||
if(counter != flashVar) |
||||
{ |
||||
alert(lang_1 + counter + lang_2); |
||||
|
||||
return false; |
||||
} |
||||
else |
||||
{ |
||||
return true; |
||||
} |
||||
} |
||||
|
||||
function updateFlashVar() |
||||
{ |
||||
//alert('updateFlashVar: ' + flashVar);
|
||||
flashVar++; |
||||
} |
||||
|
||||
/* |
||||
* Save the results of the positioning of a point by the user on top of |
||||
* the answer area. |
||||
* @param int Question ID |
||||
* @param int ID of the area (square or ellipse) |
||||
* @param int Whether the answer is correct or not |
||||
* @param int X-coordinate (horizontal) of the answer point |
||||
* @param int Y-coordinate (vertical) of the answer point
|
||||
*/ |
||||
function saveHotspot(question_id, hotspot_id, answer, hotspot_x, hotspot_y) |
||||
{ |
||||
newHotspot = document.createElement("input"); |
||||
newHotspot.type = "hidden"; |
||||
newHotspot.name = "hotspot["+question_id+"]["+hotspot_id+"]"; |
||||
newHotspot.value = hotspot_x + ";" + hotspot_y;
|
||||
document.frm_exercise.appendChild(newHotspot); |
||||
|
||||
newHotspot = document.createElement("input"); |
||||
newHotspot.type = "hidden"; |
||||
newHotspot.name = "choice["+question_id+"]["+hotspot_id+"]"; |
||||
newHotspot.value = answer;
|
||||
document.frm_exercise.appendChild(newHotspot); |
||||
} |
||||
/* |
||||
* Save the results of the positioning of a point by the user on top of |
||||
* the answer area ( for polygons and delineation ) |
||||
* @param int Question ID |
||||
* @param int ID of the area (square or ellipse) |
||||
* @param int Whether the answer is correct or not |
||||
* @param array Coordinates (horizontal+vertical) of the answer points, in an array |
||||
*/ |
||||
function saveDelineationUserAnswer(question_id, hotspot_id, answer, coordinates) |
||||
{ |
||||
newHotspot = document.createElement("input"); |
||||
newHotspot.type = "hidden"; |
||||
newHotspot.name = "hotspot["+question_id+"]["+hotspot_id+"]"; |
||||
newHotspot.value = coordinates; |
||||
document.frm_exercise.appendChild(newHotspot); |
||||
|
||||
newHotspot = document.createElement("input"); |
||||
newHotspot.type = "hidden"; |
||||
newHotspot.name = "choice["+question_id+"]["+hotspot_id+"]"; |
||||
newHotspot.value = answer;
|
||||
document.frm_exercise.appendChild(newHotspot); |
||||
} |
||||
|
||||
function saveShapeHotspot(question_id, hotspot_id, type, x, y, w, h) |
||||
{ |
||||
document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = x + ";" + y + "|" + w + "|" + h; |
||||
document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = type; |
||||
} |
||||
|
||||
function savePolyHotspot(question_id, hotspot_id, coordinates) |
||||
{ |
||||
document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates; |
||||
document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "poly"; |
||||
} |
||||
|
||||
function saveDelineationHotspot(question_id, hotspot_id, coordinates) |
||||
{ |
||||
document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates; |
||||
document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "delineation"; |
||||
} |
||||
|
||||
function saveOARHotspot(question_id, hotspot_id, coordinates) |
||||
{ |
||||
document.frm_exercise["hotspot_coordinates["+hotspot_id+"]"].value = coordinates; |
||||
document.frm_exercise["hotspot_type["+hotspot_id+"]"].value = "oar"; |
||||
} |
||||
function jsdebug(debug_string) |
||||
{ |
||||
alert(debug_string); |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,349 +0,0 @@ |
||||
// javascript Proxy |
||||
import com.macromedia.javascript.JavaScriptProxy; |
||||
var JS_proxy:JavaScriptProxy = new JavaScriptProxy(); |
||||
|
||||
System.useCodepage = true; |
||||
|
||||
// get id from querystring |
||||
myURL = this._url; |
||||
//myURL = "http://localhost/dokeosSVN/main/plugin/hotspot/hotspot_solution.swf?modifyAnswers=1&exe_id=2&from_db=3"; |
||||
tmpAr = myURL.split("?"); |
||||
tmpAr = tmpAr[1].split("&"); |
||||
id = tmpAr[0].split("="); |
||||
id = id[1]; |
||||
exe_id = tmpAr[1].split("="); |
||||
exe_id = exe_id[1]; |
||||
from_db = tmpAr[2].split("="); |
||||
from_db = from_db[1]; |
||||
|
||||
// get URL to load lang and hotspot variables |
||||
|
||||
//myURL = this._url; |
||||
myPos = myURL.lastIndexOf("/"); |
||||
myURL = myURL.substring(0, myPos); |
||||
myPos = myURL.lastIndexOf("/"); |
||||
myURL = myURL.substring(0, myPos); |
||||
myPos = myURL.lastIndexOf("/"); |
||||
myURL = myURL.substring(0, myPos); |
||||
|
||||
// movie properties |
||||
var movieWidth:Number = 380; |
||||
var movieHeight:Number = 400; |
||||
|
||||
// hotspot properties |
||||
var startWidth:Number = 0; // \__ if these values are set, shape will be drawn right and down from the mouse; |
||||
var startHeight:Number = 0; // / |
||||
var pType:String = ""; // possible values: circle, square, poly; |
||||
|
||||
// other settings |
||||
var i:Number = 1; |
||||
var isDrawing:Boolean = false; |
||||
var hotspots_c:Array = new Array('0x4271B5','0xFE8E16','0x45C7F0','0xBCD631','0xD63173','0xD7D7D7','0x90AFDD','0xAF8640','0x4F9242','0xF4EB24','0xED2024','0x3B3B3B'); |
||||
|
||||
// make array with all elements |
||||
var hotspots:Array = new Array(); |
||||
|
||||
// get data from database |
||||
this.createEmptyMovieClip("target_mc", 2000); |
||||
//_answers |
||||
loadVariables(myURL + "/exercice/hotspot_answers.as.php?modifyAnswers="+id+"&exe_id="+exe_id+"&from_db="+from_db, target_mc); |
||||
var param_interval:Number = setInterval(checkParamsLoaded, 100); |
||||
|
||||
// language variables |
||||
var str_choose:String = ""; |
||||
var lang_interval:Number |
||||
|
||||
// counter for language (if language can't be loaded after 2 sec, |
||||
// english will be loaded |
||||
var counter:Number = 0; |
||||
|
||||
// booleans for loading |
||||
var langLoaded:Boolean = false; |
||||
var varsLoaded:Boolean = false; |
||||
var imageLoaded:Boolean = false; |
||||
|
||||
// image preloader |
||||
var loadListener:Object = new Object(); |
||||
loadListener.onLoadComplete = function(){ |
||||
_root.imageLoaded = true; |
||||
_root.showInterface(); |
||||
} |
||||
var mcLoader:MovieClipLoader = new MovieClipLoader(); |
||||
mcLoader.addListener(loadListener); |
||||
var mc:MovieClip = _root.image_mc; |
||||
|
||||
///////////////////////////////////////////////////////////////////////////////// |
||||
// FUNCTIONS |
||||
///////////////////////////////////////////////////////////////////////////////// |
||||
|
||||
// show hotspots, user can't click anymore |
||||
function showHotspots(num){ |
||||
for(j=1;j<=_root.hotspots.length;j++){ |
||||
_root.map_mc["hotspot"+j]._alpha = num; |
||||
} |
||||
} |
||||
|
||||
function showUserpoints(num){ |
||||
for(j=1;j<=_root.hotspots.length;j++){ |
||||
_root["hotspot_answer"+j]._alpha = num; |
||||
if(num==0){ |
||||
_root["hotspot_answer"+j].hotspot_mc._visible = false; |
||||
}else{ |
||||
_root["hotspot_answer"+j].hotspot_mc._visible = true; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function showInterface(){ |
||||
if((_root.langLoaded == true) and (_root.varsLoaded == true) and (_root.imageLoaded == true)){ |
||||
_root.showUserpoints(100); |
||||
_root.showHotspots(100); |
||||
_root.loading_mc._visible = false; |
||||
} |
||||
} |
||||
|
||||
// get language file |
||||
function getLang(){ |
||||
counter++; |
||||
if (_root.lang_mc.done != undefined) { |
||||
_root.show_userPoints_btn.label = _root.lang_mc.showUserPoints; |
||||
_root.show_hotspots_btn.label = _root.lang_mc.showHotspots; |
||||
|
||||
// check if interface can be showed (if everything else is loaded) |
||||
_root.langLoaded = true; |
||||
_root.showInterface(); |
||||
|
||||
// clear interval |
||||
clearInterval(_root.lang_interval); |
||||
}else if(counter==20){ |
||||
// clear interval |
||||
clearInterval(_root.lang_interval); |
||||
|
||||
// set counter to zero |
||||
_root.counter = 0; |
||||
|
||||
// set new interval (get english version) |
||||
loadVariables(myURL + "/lang/english/hotspot.inc.php", _root.lang_mc); |
||||
_root.lang_interval = setInterval(getLang, 100); |
||||
|
||||
} |
||||
} |
||||
|
||||
function checkParamsLoaded() { |
||||
if (target_mc.done != undefined) { |
||||
// once we know the language, get language-variables from language file |
||||
language = target_mc["hotspot_lang"]; |
||||
_root.createEmptyMovieClip("lang_mc", 2001); |
||||
|
||||
//loadVariables(myURL + "/lang/" + language + "/hotspot.inc.php", _root.lang_mc); |
||||
loadVariables(myURL + "/exercice/hotspot.inc.php", _root.lang_mc); |
||||
|
||||
_root.lang_interval = setInterval(getLang, 100); |
||||
|
||||
// start loading external image |
||||
_root.mcLoader.loadClip("../../courses/" + target_mc["courseCode"] + "/document/images/" + target_mc["hotspot_image"], mc); |
||||
|
||||
// make needed array's: filled if hotspot exists, empty if not |
||||
for(m = 1; m <= 12; m++){ |
||||
// make seperate lists |
||||
if(target_mc["hotspot_" + m]=="true"){ |
||||
// add to general list |
||||
tmpAr = Array(); |
||||
tmpAr.push(m); |
||||
tmpAr.push(target_mc["hotspot_" + m + "_type"]); |
||||
_root.hotspots.push(tmpAr); |
||||
|
||||
if (target_mc["hotspot_" + m + "_type"] != 'poly' && target_mc["hotspot_" + m + "_type"] != 'delineation'){ |
||||
// x;y|height|width |
||||
_root["p_hotspot_" + m] = new Array; |
||||
$coordinates = target_mc["hotspot_" + m + "_coord"].split("|"); |
||||
$tmp_xy = $coordinates[0].split(";"); |
||||
$x = $tmp_xy[0]; |
||||
$y = $tmp_xy[1]; |
||||
$height = $coordinates[1]; |
||||
$widht = $coordinates[2]; |
||||
_root["p_hotspot_" + m].push($x); |
||||
_root["p_hotspot_" + m].push($y); |
||||
_root["p_hotspot_" + m].push($height); |
||||
_root["p_hotspot_" + m].push($widht); |
||||
}else{ |
||||
// p1_x;p1_y|p2_x;p2_y|... |
||||
_root["p_hotspot_" + m] = new Array(); |
||||
$coordinates = target_mc["hotspot_" + m + "_coord"].split("|"); |
||||
|
||||
for(k=0;k<$coordinates.length;k++){ |
||||
$tmp_xy = $coordinates[k].split(";"); |
||||
tempArray = Array(); |
||||
tempArray.push($tmp_xy[0]); |
||||
tempArray.push($tmp_xy[1]); |
||||
_root["p_hotspot_" + m].push(tempArray); |
||||
} |
||||
} |
||||
}else{ |
||||
_root["p_hotspot_" + m] = Array(); |
||||
} |
||||
} |
||||
|
||||
// set border around image |
||||
_root.map_mc._width = int(target_mc.hotspot_image_width) + 1; |
||||
_root.map_mc._height = int(target_mc.hotspot_image_height) + 1; |
||||
|
||||
// draw the hotspots |
||||
drawShapes(); |
||||
|
||||
// check if interface can be showed (if everything else is loaded) |
||||
_root.varsLoaded = true; |
||||
_root.showInterface(); |
||||
|
||||
// clear interval |
||||
clearInterval(param_interval); |
||||
} |
||||
} |
||||
|
||||
// draw the shapes that are given from the database |
||||
function drawShapes(){ |
||||
// draw points where user clicked |
||||
_root.drawPoints(); |
||||
|
||||
// draw hotspots |
||||
for (var j:String in hotspots) { |
||||
if(j <> ""){ |
||||
// +1 because array names starts from 1 |
||||
_root.i = int(j) + 1; |
||||
// -1 because array values starts from 0 |
||||
_root.pType = _root.hotspots[_root.i - 1][1]; |
||||
if(_root.pType=="poly" || _root.pType=="delineation"){ |
||||
drawPoly(); |
||||
} |
||||
else{ |
||||
drawShape(true); |
||||
} |
||||
_root.map_mc["hotspot" + _root.i]._alpha = 0; |
||||
} |
||||
} |
||||
} |
||||
|
||||
function drawPoints(){ |
||||
answers = _root.target_mc.p_hotspot_answers.split("|"); |
||||
|
||||
if(answers[0]!=''){ |
||||
j = 1; |
||||
k = 500; |
||||
|
||||
for(var z:String in answers){ |
||||
if(target_mc["hotspot_"+j+"_type"]=="delineation") |
||||
{ |
||||
// trace poly |
||||
delineation_coords = answers[j-1].split("/"); |
||||
drawDelineation(j, delineation_coords); |
||||
} |
||||
else |
||||
{ |
||||
|
||||
xy = answers[j-1].split(";"); |
||||
$x = xy[0]; |
||||
$y = xy[1]; |
||||
|
||||
// create new hotspot |
||||
_root.createEmptyMovieClip("hotspot_answer" + j, k); |
||||
|
||||
// attach correct type of hotspot |
||||
_root["hotspot_answer" + j].attachMovie("numbers", "hotspot_mc", _root["hotspot_answer" + j].getNextHighestDepth()); |
||||
|
||||
_root["hotspot_answer" + j].hotspot_mc._width = 33; |
||||
_root["hotspot_answer" + j].hotspot_mc._height = 22; |
||||
|
||||
_root["hotspot_answer" + j].hotspot_mc._x = int($x) + _root.map_mc._x; |
||||
_root["hotspot_answer" + j].hotspot_mc._y = int($y) + _root.map_mc._y; |
||||
|
||||
_root["hotspot_answer" + j].hotspot_mc.order_txt.text = int(j); |
||||
_root["hotspot_answer" + j].hotspot_mc._visible = false; |
||||
|
||||
_root["hotspot_answer" + j]._alpha = 0; |
||||
} |
||||
|
||||
j++; |
||||
k++; |
||||
} |
||||
} |
||||
|
||||
|
||||
} |
||||
|
||||
function drawShape(userDrawing){ |
||||
// create new hotspot |
||||
_root.map_mc.createEmptyMovieClip("hotspot" + _root.i, _root.i); |
||||
|
||||
// attach correct type of hotspot |
||||
_root.map_mc["hotspot" + _root.i].attachMovie(_root.pType, "hotspot_mc", _root.map_mc["hotspot" + _root.i].getNextHighestDepth()); |
||||
|
||||
_root.map_mc["hotspot" + _root.i].hotspot_mc._visible = true; |
||||
_root.map_mc["hotspot" + _root.i].hotspot_mc.center_mc._alpha = 60; |
||||
_root.map_mc["hotspot" + _root.i].hotspot_mc._x = _root["p_hotspot_"+ _root.i][0]; |
||||
_root.map_mc["hotspot" + _root.i].hotspot_mc._y = _root["p_hotspot_"+ _root.i][1]; |
||||
_root.map_mc["hotspot" + _root.i].hotspot_mc._width = _root["p_hotspot_"+ _root.i][2]; |
||||
_root.map_mc["hotspot" + _root.i].hotspot_mc._height = _root["p_hotspot_"+ _root.i][3]; |
||||
|
||||
colorchange = new Color(_root.map_mc["hotspot" + _root.i].hotspot_mc); |
||||
colorchange.setRGB(_root.hotspots_c[_root.i - 1]); |
||||
} |
||||
// when black lines of hotspots are deleted, draw the exact same poly with coordinates |
||||
// that are saved in the array |
||||
function drawPoly(){ |
||||
// create empty movieclip |
||||
_root.map_mc.createEmptyMovieClip("hotspot" + _root.i, _root.i); |
||||
|
||||
// begin filling the movieclip |
||||
_root.map_mc["hotspot" + _root.i].beginFill(_root.hotspots_c[_root.i - 1], 60); |
||||
|
||||
// set linestyle |
||||
_root.map_mc["hotspot" + _root.i].lineStyle(1, _root.hotspots_c[_root.i - 1], 100); |
||||
|
||||
// move mouse to first coordinate |
||||
_root.map_mc["hotspot" + _root.i].moveTo(_root["p_hotspot_"+_root.i][0][0],_root["p_hotspot_"+_root.i][0][1]); |
||||
|
||||
// draw lines to all coordinates |
||||
v = _root["p_hotspot_"+_root.i].length; |
||||
for (k=1;k<v;k++){ |
||||
_root.map_mc["hotspot" + _root.i].lineTo(_root["p_hotspot_"+_root.i][k][0],_root["p_hotspot_"+_root.i][k][1]); |
||||
} |
||||
|
||||
// attach first and last coordinates |
||||
_root.map_mc["hotspot" + _root.i].lineTo(_root["p_hotspot_"+_root.i][0][0],_root["p_hotspot_"+_root.i][0][1]); |
||||
|
||||
// stop filling the movieclip |
||||
_root.map_mc["hotspot" + _root.i].endFill(); |
||||
} |
||||
|
||||
function drawDelineation(level, coords){ |
||||
|
||||
// create empty movieclip |
||||
_root.map_mc.createEmptyMovieClip("hotspot_delineation" + level, 2000+level); |
||||
|
||||
// begin filling the movieclip |
||||
_root.map_mc["hotspot_delineation" + level].beginFill(0xFFFFFF, 60); |
||||
|
||||
// set linestyle |
||||
_root.map_mc["hotspot_delineation" + level].lineStyle(1,0x000000, 100); |
||||
|
||||
// move mouse to first coordinate |
||||
xy_origin = coords[0].split(";"); |
||||
_root.map_mc["hotspot_delineation" + level].moveTo(xy_origin[0],xy_origin[1]); |
||||
|
||||
// draw lines to all coordinates |
||||
v = coords.length; |
||||
for (k=1;k<v;k++){ |
||||
xy = coords[k].split(";"); |
||||
_root.map_mc["hotspot_delineation" + level].lineTo(xy[0],xy[1]); |
||||
} |
||||
|
||||
// attach first and last coordinates |
||||
_root.map_mc["hotspot_delineation" + level].lineTo(xy_origin[0],xy_origin[1]); |
||||
|
||||
// stop filling the movieclip |
||||
_root.map_mc["hotspot_delineation" + level].endFill(); |
||||
} |
||||
|
||||
function jsdebug(debug_string){ |
||||
_root.JS_proxy.jsdebug(debug_string); |
||||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,86 +0,0 @@ |
||||
// Globals
|
||||
// Major version of Flash required
|
||||
var requiredMajorVersion = 7; |
||||
// Minor version of Flash required
|
||||
var requiredMinorVersion = 0; |
||||
// Minor version of Flash required
|
||||
var requiredRevision = 0; |
||||
// the version of javascript supported
|
||||
var jsVersion = 1.0; |
||||
//
|
||||
|
||||
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; |
||||
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; |
||||
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; |
||||
jsVersion = 1.1; |
||||
// JavaScript helper required to detect Flash Player PlugIn version information
|
||||
function JSGetSwfVer(i){ |
||||
// NS/Opera version >= 3 check for Flash plugin in plugin array
|
||||
if (navigator.plugins != null && navigator.plugins.length > 0) { |
||||
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { |
||||
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; |
||||
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; |
||||
descArray = flashDescription.split(" "); |
||||
tempArrayMajor = descArray[2].split("."); |
||||
versionMajor = tempArrayMajor[0]; |
||||
versionMinor = tempArrayMajor[1]; |
||||
if ( descArray[3] != "" ) { |
||||
tempArrayMinor = descArray[3].split("r"); |
||||
} else { |
||||
tempArrayMinor = descArray[4].split("r"); |
||||
} |
||||
versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; |
||||
flashVer = versionMajor + "." + versionMinor + "." + versionRevision; |
||||
} else { |
||||
flashVer = -1; |
||||
} |
||||
} |
||||
// MSN/WebTV 2.6 supports Flash 4
|
||||
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; |
||||
// WebTV 2.5 supports Flash 3
|
||||
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; |
||||
// older WebTV supports Flash 2
|
||||
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; |
||||
// Can\'t detect in all other cases
|
||||
else { |
||||
|
||||
flashVer = -1; |
||||
} |
||||
return flashVer; |
||||
} |
||||
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
|
||||
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) |
||||
{ |
||||
reqVer = parseFloat(reqMajorVer + "." + reqRevision); |
||||
// loop backwards through the versions until we find the newest version
|
||||
for (i=25;i>0;i--) { |
||||
if (isIE && isWin && !isOpera) { |
||||
versionStr = VBGetSwfVer(i); |
||||
} else { |
||||
versionStr = JSGetSwfVer(i); |
||||
} |
||||
if (versionStr == -1 ) { |
||||
return false; |
||||
} else if (versionStr != 0) { |
||||
if(isIE && isWin && !isOpera) { |
||||
tempArray = versionStr.split(" "); |
||||
tempString = tempArray[1]; |
||||
versionArray = tempString .split(","); |
||||
} else { |
||||
versionArray = versionStr.split("."); |
||||
} |
||||
versionMajor = versionArray[0]; |
||||
versionMinor = versionArray[1]; |
||||
versionRevision = versionArray[2]; |
||||
|
||||
versionString = versionMajor + "." + versionRevision; // 7.0r24 == 7.24
|
||||
versionNum = parseFloat(versionString); |
||||
// is the major.revision >= requested major.revision AND the minor version >= requested minor
|
||||
if ( (versionMajor > reqMajorVer) && (versionNum >= reqVer) ) { |
||||
return true; |
||||
} else { |
||||
return ((versionNum >= reqVer && versionMinor >= reqMinorVer) ? true : false ); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -1,13 +0,0 @@ |
||||
|
||||
Function VBGetSwfVer(i) |
||||
on error resume next |
||||
Dim swControl, swVersion |
||||
swVersion = 0 |
||||
|
||||
set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i)) |
||||
if (IsObject(swControl)) then |
||||
swVersion = swControl.GetVariable(\"\$version\") |
||||
end if |
||||
VBGetSwfVer = swVersion |
||||
End Function |
||||
|
Loading…
Reference in new issue