![]() |
|
|
|
dynapi.functions - Quick Reference |
Requirements: dynapi |
|
[none]
[none]
Allow() - Enable event bubbling.
Deny() - Disable event bubbling.False() - Returns the boolean false.
True() - Returns the boolean true.Null() - Returns a null value.
Zero() - Returns the value 0.getImage(src,w,h) - Loads and returns a Basic XImage object. An XImage object is an Image object with a few extensions. See Image Functions for more advanced features
src - image source file w - width of image h - height of image
example:
var img=dynapi.functions.getImage('images/src.gif',95,15,params) document.write('My Image: '+img.getHTML());getURLArguments(o) - Returns an array containing the arguments passed to an html document. The parameter "o" can be a string, frame or layer.
example:
var t='myhtml.html?name=value'; var args=dynapi.functions.getURLArguments(t); // args['name'] = 'value';getAnchorLocation(a,lyr) - Returns an object containing the x and y coordinated of the anchor. The lyr argument can be either a frame or DynLayer object. If specified anchor is not found a null value is returned.
var o=dynapi.functions.getAnchorLocation('myanc'); alert(o.x+' / '+o.y); /* o.x - x coor; o.y - y coor; o.anchor - anchor object */removeFromArray(array, index, id) - Removes an index or id from the specified array and returns a new array.
The following methods requires the dynapi.functions library:
Color Functions (dynapi.functions.Color)
DecToHex(value) - Converts a decimal value to hexadecimal.example:
var hex=dynapi.functions.DecToHex(255); // hex = 'FF'getColor(r,g,b) - Returns the hexadecimal color format from the specified RGB color.
example:
var color=dynapi.functions.getColor(255,255,255). //: color = '#FFFFFF'getRandomColor() - Returns a random hexadecimal color.
example:
var rcolor=dynapi.functions.getRandomColor();
createRedPal(pal) - Creates a red palette and stores the values in array pal.
createGrayPal(pal) - Creates a gray palette and stores the values in array pal.createBluePal(pal) - Creates a blue palette and stores the values in array pal.
createGreenPal(pal) - Creates a green color palette and stores the values in array pal.fadeColor(from,to,percent)
Date functions (dynapi.functions.Date)
dateAdd(interval,n,dt) - Returns a date object to which a specified time interval was added.interval: year, month, day, minute, hour, second
example:
var dt=new Date('30/1/2002'); var r=dynapi.functions.dateAdd('day',4,dt); // r = 3/2/2002dateDiff(interval,dt1,dt2) - Returns a numeric value specifying the number of time intervals between two dates.
interval: year, month, day, minute, hour, second
example:
var dt1=new Date('30/1/2002'); var dt2=new Date('3/2/2002'); var r=dynapi.functions.dateAdd('day',dt1,dt2); // r = 4formatDate(date,format) - Returns a formatted date value based on the specified format.
format: dd - Display year as 01 - 31. ddd - Display year as Sun - Sat. dddd - Display year as Sunday - Saturday. mm - Display month as 01 - 12. mmm - Display month as Jan - Dec. mmmm - Display month as January - December. hh - Display hours as 00 - 23. nn - Display minutes as 00 - 59. ss - Display seconds as 00 - 59. ampm - Displays an AM with any hour before noon or PM with any hour between noon and 11:59 PM.
example:
var dt= new Date('20/8/2002'); var r=dynapi.functions.formatDate(dt,'dddd, mmmm dd, yyy'); // r = Tuesday, August 20, 2002
getDayOfYear(dt) - Returns the day of year in the specified date.
dt - (Date) Specified Date
isDate(dt,format) - Returns true if dt is of the specified date format:
format: mm/dd/yyyy dd/mm/yyyy yyyy/mm/dd
Image Functions (dynapi.functions.Image)
captureImageProgress(fn) - Captures Image Loading progress by passing completed, failed and total images to the fn function.
fn - Callback function
dynapi.functions.captureImageProgress(fn) function fn(c,f,t){ var p=parseInt(((c+f)==0)? 0:((c+f)/t)*100); lyr.lyrBar.setWidth(p*3) lyr.lyrBar.setHTML('<font color="white"> '+p+'%</font>') if((c+f)==t) { var a=dynapi.functions.getFailedImages(); for(var i=0;i<a.length;i++){ a[0].reload(); } } }
getImage(src,w,h,params) - Loads and returns an Advance XImage object. The Advanced XImage object includes all the features of the Basic XImage object plus additional parameters.
params: onclick, onmouseover, onmouseout, onmousedown, onmouseup oversrc - Source image when mouse is over image downsrc - Source image when mouse is pressed tooltip - Tip to be displayed when mouse is over image text - text to be displayed with image textdir - direction of text around image: N, E, S, W link - Hyperlink to navigate to when image is clicked alias - Name used to reference image object in the XImage collection name - Name of the <img> object
example:
// very simple mouse down & over setup var params={}; params.tooltip="Click here"; params.oversrc="images/oversrc.gif"; params.downsrc="images/downsrc.gif"; params.onclick=function(){alert('Hello!')}; params.onmouseover="status='Over!'"; params.onmouseout="status='Out!'"; params.onmousedown="status='Down!'"; params.onmouseup="status='Up!'"; var img=dynapi.functions.getImage('images/src.gif',95,15,params) document.write('getImage: '+img.getHTML()); document.write(' '+ img.getHTML({tooltip:"Another Image", onclick:"alert('Hello Again!')"})+'<br><br>'); // using the alias parameter var img; dynapi.functions.getImage('images/src.gif',95,15,{alias:'myimage'}); // some code here.... img=dynapi.ximages['myimage'];
The Advanced XImage Object includes a reload() function to reload failed images.
getFailedImages() - Returns an array of failed images
setImageTTL(ms) - Sets the Time-To-Load timeout in milliseconds for images created using getImage()
Math Functions (dynapi.functions.Math)
radianToDegree(radian) - Converts radians to degrees.degreeToRadian(degree) - Converts a degrees to radians.
sintable(lsin) - Generates a sin table inside array lsin.example:
var lsin=[]; dynapi.functions.sintable(lsin); // lsin now contains sin table valuescostable(lcos) - Generates a cos table inside array lcos.
exmaple:
var lcos=[]; dynapi.functions.costable(lcos); // lcos now contains cos table values
getRandomNumber(n) - Used to generate a Random number not greater than n
n - (Number) Optional. If missing a number not greater than 10000 is returned
getGUID() - Generated a Globally Unique Identifier.
interlacePaths(x,y) - Combines separate [x1,x2],[y1,y2] arrays into a path array [x1,y1,x2,y2]
Numeric Functions (dynapi.functions.Numeric)
formatNumber(n,format) - Returns a formatted numeric value based on the specified format.
format: 0 - Digit placeholder. Display a digit or a zero. # - Digit placeholder. Display a digit or nothing. $ - Currency Character % - Percentage Character
formatting examples:
0 0% 0.00% 0.00 #,##0 #,##0.00 $#,##0 $#,##0.00
isFloat(n,default) - Return true is n is of the float data type.
isInteger(n,default) - Returns true if n is of the integer data type.
toInteger(dt) - Converts the specified value to an integer and return the result.
toFloat(dt) - Converts the specified value to float and return the result.toBoolean(dt) - Converts the specified value to boolean and return the result.
String Functions (dynapi.functions.String)
sprintf(t) -
strRepeat(s,n) - Repeats the specified string n number of times.
example:
var r=dynapi.functions.strRepeat('*',5); //r = '*****';strReverse(s) - Reverses the characters in the specified string.
example:
var r=dynapi.functions.strRepeat('Test',5); //r = 'tseT';strStuff(s,v,index) - Inserts a string into another string and returns the new string.
example:
var a='Thisa test'; var b=' is '; var r = dynapi.functions.strStuff(a,b,4); // r = 'This is a test'
trim(s,dir) - Returns the specified string without leading or trailing spaces. The dir argument is used to control the trimming direction.
dir: > - Trims trailing white spaces < - Trims leading white spaces <> - (Default) Trims both leading and trailing white spaces
example:
var r; var t=' Testing... '; r=dynapi.functions.trim(t) // r = 'Testing...'; r=dynapi.functions.trim(t,'<') // r = 'Testing... '; r=dynapi.functions.trim(t,'>') // r = ' Testing...';
System Functions (dynapi.functions.System)
coalesce(a1,a2,...aN) - Returns the first non-null value of the specified arguments.example:
var a=null,b=null,c='Cool'; var r=dynapi.functions.coalesce(a,b,c); // r = 'Cool'choose(index,a1,a2,...aN) - Returns the value from the arguments list.
example:
var r=dynapi.functions.choose(3,'a','b','c','d'); // r = 'c'cloneObject(src) - Clones a non-intrinsic javascript object.
copyObject(from, to) - Copies the values from a non-intrinsic javascript object into another and returns a new object. If noclone is set to true then the destination object is returned.
example:
var a={red:true}; var b={blue:true}; va r= dynapi.functions.copyObject(a,b); // r = {red:true,blue:true}getElementById(id,parentLyr) - Returns an inline DOM Layer from the specified parent DynLayer. If parent layer is not supplied then DynDocument is used.
example:
var t='<div id="myid" style="position:absolute"></div>'; var lyr=dynapi.document.addChild(new DynLayer(t)); var ilyr=dynapi.functions.getElementById('myid',lyr); // ilyr = inline layer myidisNull(value,default) - Returns a default value if the specified value is null. If the specified value is not null then the value is returned.
lookUp(value,array) - Searches an array for the specified value and returns the index of the value.
example:
var a=['red','blue','green']; var r=dynapi.functions.lookUp('blue',a); //r = 1;nullIf(a1,a2,....aN) - Returns a null value if any of the specified expressions are true.
example:
var a = 1; var r = dynapi.functions.nullIf(a); // r = null;
Library/Module Specific Functions
dynapi.api.EventObject
subClassEvent(type,eobj,fn) - Subclassing allows a user to manipulate, modify, or even discard events bound for other objects within dynapi, and in the process changing the way in which the dynobjects behaves.
type - Event type
eobj - EventObject or id
fn - Callback function
See the Event
SubClassing example for more details
dynapi.util.Cookie
deleteCookie(name)
getCookie(name)
setCookie(name,value,days)
dynapi.fx.GlideAnimation'
getNormalizedAngle(x1,y1,x2,y2) - Returns correct angle in radians between 2 points
[none]
[none]