Substrings
This gets the fifth character out of myName. The first number is the beginning, the second is the end. It is sort of like selecting text from a start point to an end point.
myName.substring(4, 5)
This gets the fifth character out of myName. The first number is the beginning, the second is the end. It is sort of like selecting text from a start point to an end point.
myName.substring(4, 5)
Posted by Matt Maxwell at 11:02 AM 0 comments
Here's how to take nested x and y and convert them to global x and y:
//these nested coordinates...
var myPoint:Object = {x:theClip.nestedclip._x, y:theClip.nestedclip._y};
theClip.nestedclip.localToGlobal(myPoint);
//
//are now root coordinates...
trace(myPoint.x)
trace(myPoint.y)
Posted by Matt Maxwell at 2:57 PM 1 comments
Here is a good article on reducing the file size of FLVs. My FLVs are now half the size but actually look better. The main secret was lowering the data rate to 250, having the frame rate between 12 and 15, letting the software automatically choose the keyframes, and using a mono audio track.
http://www.communitymx.com/content/article.cfm?cid=EBD77&print=true
Posted by Matt Maxwell at 3:26 PM 0 comments
All these little widgets on my site use these variables, they are all in the Captivate help filebut I guess not many people can find them due to the amount of questions on the Captivateforum
rdcmndPrevious = 1 Is used to go back one slide in a captivate movie
rdcmndNextSlide = 1 Is used to go forward one slide in a captivate movie
rdcmndPause = 1 Is used to pause a captivate movie
rdcmndResume = 1 Is used to play a captivate movie
rdcmndRewindAndStop rewind and stop the movie
rdcmndRewindAndPlay Is used to restart and play a captivate movie
rdcmndGotoFrame Is used to go to a specific frame, note this is Frame not a Slide (see rdinfoFrameCount)
rdcmndExit does what is say's exit's the movie
rdcmndInfodisplay the information window (Yep that little Info box that everyone moans about
rdinfoFrameCount total number of swf frames in the movie (this is not the number of frames in the main Timeline, but the sum of all slide frames)
rdinfoSlidesInProject number of slides in the movie (including hidden slides)
rdinfoCurrentFrame current frame (goes from 1 to rdinfoFrameCount when you play the movie)
rdinfoCurrentSlide slide currently playing (zero based)
rdinfoSlideCount number of slides in the movie (not including hidden slides)
rdIsMainMovie can be used to identify a Captivate movie
And a couple of unpublished variables
rdcmndHidePlaybar =
is used to hide or show the playbar 1= hide 0=show
rdcmndCC =
is used to show or hide Closed Captions 1= show 0=hide
rdcmndMute =
is used to mute or unmute the audio 1= mute 0=unmute
I do not use flash as I am not clever enought to understand it, instead I use Swishmax a nice little app.
To create an external playbar in swish I would create a set of buttons then add the following script to each
Restart buttonon (release) {this._parent._parent.rdcmndRewindAndPlay = 1;}
Rewind buttonon (release) {this._parent._parent.rdcmndPrevious = 1;}
Pause buttonon (release) {this._parent._parent.rdcmndPause = 1;}
Play buttonon (release) {this._parent._parent.rdcmndResume = 1;}
Forward buttonon (release) {this._parent._parent.rdcmndNextSlide = 1;}
Exit button on (release) {fscommand("Quit","true");}
Posted by Matt Maxwell at 3:20 PM 3 comments
Old Version:
http://www.google.com/support/googleanalytics/bin/answer.py?answer=74979
New Version:
http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer=55520
its very easy:
1. Get a Google analytics account
2. Give it a URL
3. Google Analytics gives you a little bit of code to embed in the HTML
4. Paste the code into your html
5. Use one line of code in flash for every click
This is a great way to do path analysis in a Flash site.
Posted by Matt Maxwell at 4:17 PM 3 comments
I wrestled for about an hour because the XML from Blogger was coming up blank whenever I ran my project on the web server. This article saved me:
http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16520
Basically I need to have "proxy.php" in the same directory as the site - with the Atom XML URL inside it. Then, in Flash I need to use "proxy.php" for the path. I think the way this works is that the PHP file reads the XML and stores it, then Flash gets the XML text from the PHP file. This code is in the Nitro Circus project in proxy.php and the "if the planet==3" area of planets.as file.
-------------
Text from Adobe:
Loading data across domains
For security reasons, a Macromedia Flash movie is not permitted to load data from a different Internet domain. Attempts to access cross-domain data or data returned to Macromedia Flash Player from another domain will be ignored by the Macromedia Flash Player. SeeAdditional information to find specific information on domain comparison.
Note: Macromedia Flash Player release 6r47 did not allow an HTML page on the web to load a SWF file that was stored on the local machine (for example on a CD-ROM or local hard drive). This functionality has been restored in Macromedia Flash Player 6 release r65 (6,0,65,0) and above. For SWF files accessing internet based content these rules still apply.
If a Flash web application needs to access information from a different domain, a developer can use one of two recommended methods on the server-side to give Flash access to this data. See the table below for an overview of each method.
Server-side proxy method
-Requirements: You must be able to upload and run a server-side script on a server in the same domain as the Flash movie.
-In this method, the Flash movie accesses the script, which loads the information, retrieves it, and returns the information back to the Flash movie.
-This method is best if the server hosting the data is not under your control (for example, a public XML feed).
1. Download and unzip or unstuff one (or all of) the following example files:
ColdFusion Example:
Windows ZIP
Macintosh SEA
PHP Example:
Windows ZIP
Macintosh SEA
ASP Example:
Windows ZIP
Macintosh SEA
Java Servlet Example:
Windows ZIP
Macintosh SEA
The above code example must be hosted from a server in the same domain as the Macromedia Flash document.
Note: Other server-side scripts can be used. Developers using other types of files can use one of the above examples as guideline.
2 . Replace the URL in the example with the URL that you want Macromedia Flash to load data from.
3 . In the Macromedia Flash movie, in the action that loads the data, point to the URL where you will post the above code example.
4 . Publish and upload both documents.
Posted by Matt Maxwell at 9:30 PM 1 comments
//transform color +500 is blown out to white, -500 is solid black, 0 is normal
import flash.geom.ColorTransform;
import flash.geom.Transform;
var colorTrans:ColorTransform=new ColorTransform();
colorTrans.redOffset = 100;
colorTrans.greenOffset = 100;
colorTrans.blueOffset = 100;
this.transform.colorTransform = colorTrans;
Posted by Matt Maxwell at 12:35 PM 0 comments
Make two movieclips:
1. The "maskee" which is just a regular MovieClip containing a picture.
2. The "mask" which is also a movieClip but contains some blends that fade to a solid color to clear
maskee.cacheAsBitmap=true
mask.cacheAsBitmap=true
mask.setMask(maskee)
Posted by Matt Maxwell at 1:06 PM 0 comments
mc.getDepth();
Remember the parens
Posted by Matt Maxwell at 11:07 AM 1 comments
This Flash function calls a Javascript and sends a string to be displayed in an alert window.
import flash.external.*;
btn.onPress = function() {
ExternalInterface.call("playmovie", "hi Matt");
};
function playmovie(theMessage){
alert(theMessage)
}
Posted by Matt Maxwell at 9:38 PM 2 comments
This tool uses css, flash, and Javascript to embed non-web fonts in a browser.
http://www.mikeindustries.com/sifr/
Posted by Matt Maxwell at 6:14 AM 0 comments
String.prototype.replace = function(str, rep) {
return this.split(str).join(rep);
};
//use it like this
var myStr:String = "Hello earth!"
trace(myStr.replace("earth","world")
Posted by Matt Maxwell at 6:02 AM 0 comments
displayTime = 10;
countDown = function () {
displayTime--;
if (displayTime == 0) {
clearInterval(timer);
}
};
timer = setInterval(countDown, 1000);
Posted by Matt Maxwell at 6:02 AM 0 comments
colorTo = function (theHex, theMc) {
colorful = new Color(theMc);
colorful.setRGB(theHex);
};
colorTo(0x00FFFF, theMc);
Posted by Matt Maxwell at 5:56 AM 2 comments
this._y += (newPos - this._y) * .5;
Posted by Matt Maxwell at 1:34 PM 0 comments
GEN_get3DDistance = function (ax, ay, az, bx, by, bz) {
dx = ax-bx;
dy = ay-by;
dz = az-bz;
theDistance = Math.sqrt(dx*dx+dy*dy+dz*dz);
return theDistance;
};
trace(GEN_get3DDistance(5,0,0,10,0,0))
Posted by Matt Maxwell at 9:40 PM 0 comments
GEN_get2DDistance = function (ax, ay, bx, by) {
dx = ax-bx;
dy = ay-by;
theDistance = Math.sqrt(dx*dx+dy*dy);
return theDistance;
};
this.onEnterFrame = function() {
trace(GEN_get2DDistance(thing._x, thing._y, _xmouse, _ymouse));
};
Posted by Matt Maxwell at 9:22 PM 0 comments
//HIGH SCORE SHARED OBJECT =======================================
// create a new shared object named "healthfirstdental"
my_so = SharedObject.getLocal("healthfirstdental");
// set a new variable (alreadyvisited) to 0
if (my_so.data.alreadyvisited == undefined) {
my_so.data.alreadyvisited = 1;
// this saves the shared object immediately as opposed to when the swf shuts down
my_so.flush;
} else {
gotoAndStop("skipped");
}
//zeroalreadyvisited.onRelease = function() {
//my_so.clear();
//};
Posted by Matt Maxwell at 11:23 AM 0 comments
GEN_positionInParallax = function (thisMovieClip, theBoundsMovieClip, theLeaderMovieClip) {
//
// X...
//get offset % by comparing theLeaderMovieClip with theBoundsMovieClip
extraXSpace = (theLeaderMovieClip._width)-(theBoundsMovieClip._width);
westGap = (theBoundsMovieClip._x)-(theLeaderMovieClip._x);
leaderWestGapXPercentage = westGap/extraXSpace;
//set position
followerExtraXSpace = (thisMovieClip._width)-(theBoundsMovieClip._width);
thisMovieClip._x = (-(followerExtraXSpace*leaderWestGapXPercentage))+theBoundsMovieClip._x;
//
// Y...
//get offset % by comparing theLeaderMovieClip with theBoundsMovieClip
extraYSpace = (theLeaderMovieClip._height)-(theBoundsMovieClip._height);
northGap = (theBoundsMovieClip._y)-(theLeaderMovieClip._y);
leaderWestGapYPercentage = northGap/extraYSpace;
//set position
followerExtraYSpace = (thisMovieClip._height)-(theBoundsMovieClip._height);
thisMovieClip._y = (-(followerExtraYSpace*leaderWestGapYPercentage))+theBoundsMovieClip._y;
};
Posted by Matt Maxwell at 1:09 AM 0 comments
if (Key.isDown(39)) {
//LEFT;
}
if (Key.isDown(37)) {
//RIGHT;
}
if (Key.isDown(40)) {
//UP;
}
if (Key.isDown(38)) {
//DOWN);
}
if (Key.isDown(65)) {
//A;
}
if (Key.isDown(83)) {
//S;
}
Posted by Matt Maxwell at 6:50 PM 0 comments
GEN_PlotItemsOnCircle = function (numberOfItems, theRadius, startDegree) {
sliceSize = (360/numberOfItems);
theCoordinates = [];
for (i=0; i<(numberOfItems); i++) {
angle = startDegree*(Math.PI/180);
xPlot = theRadius*Math.cos(angle);
yPlot = theRadius*Math.sin(angle);
startDegree += sliceSize;
theCoordinates[i] = [xPlot, yPlot];
}
return theCoordinates;
};
Posted by Matt Maxwell at 6:14 PM 1 comments
GEN_putObjectIn3dScene = function (theClip, cameraDistanceFromTracerPlane, x, y, z, vanishingPointX, vanishingPointY) {
if (z<0) {
theClip._alpha = 0;
} else {
theClip._alpha = 100;
}
var zfactor = cameraDistanceFromTracerPlane/z;
theClip._x = x*zfactor+vanishingPointX;
theClip._y = y*zfactor+vanishingPointY;
theClip._xscale = 100*zfactor;
theClip._yscale = 100*zfactor;
theClip.cacheAsBitmap();
theClip.swapDepths(Math.floor(100000-z));
};
Posted by Matt Maxwell at 6:12 PM 0 comments
Fuse Kit is a very nice set of classes, that when added to Flash, add a way to easily tween movieclips in tons of ways. The description below is the beginners "simpleSetup" mode only. There are a number of ways to use Fuse Kit. This is the easiest-to-understand way.
You need to first install Fuse Kit. Installing this MXP installs new classes into Flash.
Next use this code to import the classes into your code:
import com.mosesSupposes.fuse.*;
ZigoEngine.simpleSetup(Shortcuts, PennerEasing, FuseFMP);
my_mc.Blur_blur=20;
my_mc.slideTo(300, 300, 2);
my_mc.rotateTo(180, 2);
my_mc.colorTo("#ffffff", 10)
my_mc.scaleTo(10, 4)
my_mc.Blur_blurXTo(50, 1, "easeInOutElastic", 2);
Posted by Matt Maxwell at 5:51 PM 3 comments