Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




How To Make A "save" Function?



Hi everybodyI am a novice and this is my first time to ask hereI have seen a RPG flash game which have a "save" function although it is offlineCould anyone tell me how can it do that please



Adobe > Flash General Discussion
Posted on: 03/18/2007 11:55:13 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Print Function Or Save Function
i was wonderin what was easier for print funcions in flash, i havent done any flash remoting so i guess printing a jpg is better.

http://www.rit.edu/~ast7707/bricks.swf

basically the clips are called from a movieclip already on the stage but is it hidden , is it easier to print from a square like the grey one in the middle?

Function Save As (mx)
is it possible to create a function "save as" in bmp or jpg ?
i want save a clip to the harddisk (in local with a projection) during the animation.
i ve tried with javascript and vb6 with fscommand and it does't work.
if someone has an idea or a tutorial ...
thanks

Save MC To JPG Function ?
Is there a function that will allow me to do this? The only way to save an mc as a jpeg i've found so far is to printAsBitmap() and then instead of choosing an actual printer, choose the adobe acrobat pdf printer and it will save it as a pdf. any ideas?

Add Save Function
I would like to know how to save the drawings made in this app I made, Just like to variables, or even better if someone could somehow send it to a text file were people can select and view it Any saving of the d movieclip's drawing would be great

Save Function
I have an application with a save button in it. When user clicks on the save button, user will be prompted a save popup where user need to enter a filename. So What I would like to do for my application is make the save function same concept as in the Microsoft word. For example, I give a filename as "Document1" and save it. Then I save the file with the same filename again but is in small case "document1". Then when I click a button to save it, it should be only have one file named "Document1". So what should I do to make this happen? Hope someone could give me some idea.


Any help is appreciated.
Thanks in advance.

Save Function
I have an application with a save button in it. When user clicks on the save button, user will be prompted a save popup where user need to enter a filename. So What I would like to do for my application is make the save function same concept as in the Microsoft word. For example, I give a filename as "Document1" and save it. Then I save the file with the same filename again but is in small case "document1". Then when I click a button to save it, it should be only have one file named "Document1". So what should I do to make this happen? Hope someone could give me some idea.


Any help is appreciated.
Thanks in advance.

How Could I Make A Game Where U Can Save?
Im thinking of making a game (Maybe an RPG) and i want to know if it is possible to make save points.

PS. Go to http://www.sfdt.com to see some really funny flash animations of stick figures doing loads of funny stuff.

PPS PPPPLLLLLLLEEEAAAASSSSSSEEEEEE help me

Block The Save Function?
Hi.

Usually on the web, when you right click on a picture you can save it by clicking "save picture as". But on some sites this function is disabled, and you cannot save a picture. How did they do that?

Thanks.
Nate

A Question About The Save Function
How does the save function work in the following flash application(in fact,this is a game)??

Line Rider

How To Make 'save' For Flash Games
hi I will be grateful if you just guide me how to make 'save' for my flash games.
for example I want to save a variable in a external object like a text file or anything else and after reruning it, recall this variable from the external object and how load this.should i use sharedobjects class or sth else.?
Thanks alot.Text

Paint Program With Save Function
Anyone know a way to make a paint program in flash 8 with save function?
The paint area should be quite large so the current jpg saving methods don't seem to work.
Any solutions for this?

Browser Open / Save As Function
Hey,
How can I create a open/ save text file dialog for my program. I am going to eventually compile it using swish, and I want the user to be able to load files off of their hard drive. I'd like to make it so the user can browse their hard drive for the files. As an extra option, I'd like to make it so they can download files from the internet. Once I have the filename and path, how do I assign to a variable? sorry for the length...

Browser Open / Save As Function
Hey,
How can I create a open/ save text file dialog for my program. I am going to eventually compile it using swish, and I want the user to be able to load files off of their hard drive. I'd like to make it so the user can browse their hard drive for the files. As an extra option, I'd like to make it so they can download files from the internet. Once I have the filename and path, how do I assign to a variable? sorry for the length...

How Can I Make My Flash Game Save Data?
I want to make this game, but I need it to be able to save your progress. How can I do this?

Save Picture Function From With In Flash Slideshow...
I'm using Flash 8 as a slideshow to view a picture gallery. It works great except the user community want to be able to 'right click' and save their favorite picture. I know how to enable Contect Menu feature but can't seem to get it to work.
Any help/direction would be greatly appreciated.

Nead A Function To Save Time A Code
is there a way ao doing that automatically whit a function

in frame 2 I have

_root.menu.bt1.gotoAndStop("out");
_root.menu.bt3.gotoAndStop("out");
_root.menu.bt4.gotoAndStop("out");
_root.menu.bt5.gotoAndStop("out");
_root.menu.bt6.gotoAndStop("out");
_root.menu.bt7.gotoAndStop("out");
...

in this particular case excluding the bt2 option

but virying the option that is excluded in diferente frames

In frma 3 I will need somthing like:

_root.menu.bt1.gotoAndStop("out");
_root.menu.bt2.gotoAndStop("out");
_root.menu.bt4.gotoAndStop("out");
_root.menu.bt5.gotoAndStop("out");
_root.menu.bt6.gotoAndStop("out");
_root.menu.bt7.gotoAndStop("out");
...

I weel need to repeat this 10 or 12 times in 10 or 12 diferente frames.

Save Picture Function Using Flash To View.....
I am using Flash 8 & SlideShowPro to create a slide show gallery - it works very well. However, I need the ability to right click on a picture from the gallery and save it / download it to the local machine. I know I can enable ContextMenu feature but can't seem to get anything to save or prompt me for save location.
Any help as I am a 'newbie' would be great!

Thank you!

Force Save Target As With GetURL Function
Is it possible to force save target as with getURL function? I'm trying to link people to an avi file without zipping it and it opens the default media player to stream it.

Thanks

How Do I Save Data To Mysql And How Do I Make A Table In Flash
how do i save data to mysql and how do i make a table in flash

How Do I Save Data To Mysql And How Do I Make A Table In Flash
how do i save data to mysql and how do i make a table in flash

How To Make A Save Button To The Drawing Made By The Draw...
How to make a save button to the drawing made by the drawing maker
can any one help me
please.

Making Save Game Function With Action Script
I have a problem. Please help! I`ve just made a game. I want the game to have the `save game` function. But I don`t know how to use Action Script to write information to a txt file to somewhere in c:. So I wrote a Pascal program to write the txt file. And then I use `fscommand` to `exec` the Pascal program. This method is very tedious, right?

So, would you please tell me if there are any simplier methods to write a txt file to the secondary storage by Action Script? Can `fscommand` do that?

How Can You Make Sure One Function Completes Before Second Function Runs?
Hi guys:

I apologize if it's a really obvious answer, but I can't even think of the right terms to search on right now!

I have two functions. One is an xml connector trigger, that calls a PHP program to get xml data that includes content and formatting information. It will read the formatting information into hidden text fields.

The second function reads the hidden text fields, and applies the data from them to the style for the content fields:

Here's the prototype (pooh just being a "foo" name), contained in the root of the application:

Code:
// Initial poll for the XML data (this also runs the PHP that updates the movie)
var f_xml_trigger:Function = function(){
xml_community_board_connector.trigger();
}
_global.f_xml_trigger = f_xml_trigger;

// Function to apply styles:
var f_format:Function = function(){
Dashboard_Message_TextArea.setStyle("backgroundColor",Pooh.text);
}
_global.f_format = f_format;

_global.f_xml_trigger();
_global.f_format();
What's happening is _global.f_format is running before _global.f_xml_trigger has completed populating the fields.

I made these Global so a movie clip that's running a clock can periodically check for and apply updated content & formatting.


Code:
function getTime() {
var time = new Date();
<snip>
var second = time.getSeconds();
<snip>

if (second == 30 && _global.t30flag == 1)
{
// The _global.t30flag is used to make sure this only runs once
// otherwise it would run at the frame per second rate (i.e. 12fps = 12 times
// during the 30th second

_global.f_xml_trigger();
_global.t30flag++;
}

if (second == 31 && _global.t30flag == 2)
{
// Apply the formatting brought down by the xml trigger.
// Can't be done at the same time, because it runs before the values are updated.
_global.f_format();
_global.t30flag++;
}

<snip>
But rather than depending on frame numbers or seconds (especially since a 1 second delay between when text changes and formatting changes is annoying to say the least!)...I would think there must be a way that as soon as we can get a success returned from _global.f_xml_trigger we can run _global.f_format.

Any suggestions?

Thanks,
Matt

How Do You Make A Link Do The Equivalent Of "Save Target As..." For An MP3 File
Does anyone know how to make a link in Flash 5, that will bring up the "Save As..." window, which is the equialent of 'Right clicking --> Then clicking on Save Target As... Option'? This is for an mp3 file by the way.

I just want to avoid the IE plugins that might try to play it in IE, when the file is meant to be downloaded.

A Good Challenge... Creating A "save" Function
Wondering if anyone knows how to create a "save" function in flash?

I'm trying to build a small and simple audio creation application similar to this:

www.stopwhaling.org/site/c.hhLTK0PDLqF/b.1389073/k.FC4D/WELCOME_TO_IFAWS_WHALE_REMIX_MUSIC_MASHER.htm

You can create audio - no problem. you can play it back... a little trickier, but on my way to figuring that out, but you can also "save" your creation and send it to people or add it to the database of "creations"...

Anyone know anything about "saving" what you've created? Even if it's not audio.. something like a drawing application where you can "save" and email what you've drawn on the stage would be helpful.

Thanks very much in advance for any feedback!! Truly appreciated!

Can I Make This A Function?
I have this code I downloaded of a tutorial attatched to about 15 MC's.
I would like to declare the function just once and have the MC's call that function--then I don't have to attach the entire code to EVERY MC.

Here's the original code that works as long as I put it on each and every MC..

onClipEvent (load) {
this.elasticScale = function(tar, accel, convert) {
xScale = xScale*accel+(tar-this._xscale)*convert;
yScale = yScale*accel+(tar-this._yscale)*convert;
this._xscale += xScale;
this._yscale += yScale;
};
}
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.elasticScale(110, 0.7, 0.4);
} else if (!this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.elasticScale(100, 0.7, 0.4);
}
}


Here's what I tried to use and could'nt get it to work:

I put this on the first frame
function elasticScale() {
xScale = xScale*accel+(tar-this._xscale)*convert;
yScale = yScale*accel+(tar-this._yscale)*convert;
this._xscale += xScale;
this._yscale += yScale;
}


then I put this on the MC's
onClipEvent (enterFrame) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.elasticScale(110, 0.7, 0.4);
} else if (!this.hitTest(_root._xmouse, _root._ymouse, true)) {
this.elasticScale(100, 0.7, 0.4);
}

Can I Make A Function For This?
Hello,

I'm building an imagegallery using xml.
link: http://www.theremedy.be/fotos/

My problem. I want the thumbnails to fade in and out onRollOver instead of jumping to values like they do now.

So I probably need some kind of function wich I call when that particular button is rollOvered.

I currently use this code.


Code:
for (p=0; p<_root.thumbs.totalSlides; p++) {
_root.thumbs["btn"+p].p = p;
_root.thumbs["btn"+p].onRollOver = function() {
_root.thumbs["mc"+this.p].screen._alpha = 80;
};
_root.thumbs["btn"+p].onRollOut = function() {
_root.thumbs["mc"+this.p].screen._alpha = 0;
};
_root.thumbs["btn"+p].onRelease = function() {
loadMovie(data_xml[this.p].attributes.foto, _root["beeld"]);
_root.thumbs._visible = false;
};
}
Movieclips are placed on the stage using attachMovie.

So basically the question. Can someone help me with creating a function for the fading wich I can call on rollover.

Thank you.


//nevermind. Changed to flashplayer 7 export settings and used the build-in mx tweens.

5 Function Make It Just One
Happy New Year ::: 2004 ::::

hi guys...
if i have 5 function and i want to make them in just one.... the difference between them just in the name of the movie clip....
here Exp. for 3 :

ActionScript Code:
function homeClickreturn() {    if (_root.mc_apLink1._currentframe == 10) {        _root.mc_apLink1.play();    }}function homeClickreturn2() {    if (_root.mc_apLink2._currentframe == 10) {        _root.mc_apLink2.play();    }    if (_root.mc_apmain2._currentframe == 5) {        _root.mc_apmain2.play();    }}function homeClickreturn3() {    if (_root.mc_apLink3._currentframe == 10) {        _root.mc_apLink3.play();    }    if (_root.mc_apmain3._currentframe == 5) {        _root.mc_apmain3.play();    }}

thanx

5 Function Make It Just One
Happy New Year ::: 2004 ::::

hi guys...
if i have 5 function and i want to make them in just one.... the difference between them just in the name of the movie clip....
here Exp. for 3 :

ActionScript Code:
function homeClickreturn() {    if (_root.mc_apLink1._currentframe == 10) {        _root.mc_apLink1.play();    }}function homeClickreturn2() {    if (_root.mc_apLink2._currentframe == 10) {        _root.mc_apLink2.play();    }    if (_root.mc_apmain2._currentframe == 5) {        _root.mc_apmain2.play();    }}function homeClickreturn3() {    if (_root.mc_apLink3._currentframe == 10) {        _root.mc_apLink3.play();    }    if (_root.mc_apmain3._currentframe == 5) {        _root.mc_apmain3.play();    }}

thanx

Make This Into A Function?
As soon as you see some repeated code you think make-a-function. Well so did I

This is the working part

Code:
function show()
{
for (j=0; j<=userSquares.length-1; j++) {
//dynamicly attach mc's
test = userSquares[j];
_root.square_mc.attachMovie(test,"Square"+j,j);
trace("Square " +test);
_root.square_mc["Square"+j]._y = 51*j;
_root.square_mc["Square"+j]._width = 50;
_root.square_mc["Square"+j]._height = 50;
}

for (i=0; i<= userCircles.length-1; i++) {
_root.circle_mc.attachMovie(userCircles[i],"circle"+i,i);
test = userCircles[i];

//dynamicly attach mc's
//here all the layout _x, _y etc
_root.circle_mc["circle"+i]._y = 51*i;
_root.circle_mc["circle"+i]._width = 50;
_root.circle_mc["circle"+i]._height = 50;
}
}
and I want to rewrite it so I can use


Code:
function show()
{
displaySelectedArray(userSquares, square_mc, Square,50, 50);
displaySelectedArray(userCircles, circle_mc, circle,50, 50);
}
This is my attempt but I think I am not using/reading layoutMC the right way


Code:
function displaySelectedArray(whichArray, layoutMC, elementName, elementWidth, elementHeight)
{
//whichArray - holds the mc's to attach
//layoutMC - is an empty mc on stage which is the begin position
//for all the attachmovies.
//elementName - base name for all the attachMovies
//to- do x and y position

layoutMC = layoutMC._name;
for(i=0; i<whichArray.length;i++)
{
//dynamicly attach mc's
test = whichArray[i];
_root.layoutMC.attachMovie(test, elementName+i,i);
_root.layoutMC[elementName+i]._y = 51*j;
_root.layoutMC[elementName+i]._width = elementWidth;
_root.layoutMC[elementName+i]._height = elementHeight;
}


}
Any suggestions???

How To Make A Function 'mc.function()' ?
Hey.. I was hoping you could help me with this doubt. How do I make a prototype for a function like... mc.attachMovie() , or mc.nextframe(). Know what I mean ? the argument of the funcion is the mc.

How ?

FMX: Save User-drawn Objects And Save/load DXF/DWG?
Hey everyone. Sorry to seem like a leech, but I could really use the guidance. Usually I'm pretty good for finding the solution on my own without having to trouble people, but this time I seem to be coming up short. So thanks in advance for taking the time to read this.

I'm developing an auto-cad esque flash application (going good so far too). I have no problem storing object information in a database (xy coordinates, rotation, scale etc), but now my problem is converting that data to another format; specifically DXF or DWG. Now I know the flash environment itself can import/export DXF's, but I don't know how to load the user-made data into the environment. Is it possible to have the environment run actionscripts to build these user-made objects and then manually save that to a DXF? (or even better would be a save/load DXF from the flash player)

Essentially I'd need to know if it's possible for the flash environment to read from my database (probably from reading a PHP built XML file), execute actionscript to reconstruct any objects created, and then let me go and manually (or automatically!) export a DXF of that.

Any comments or help would be greatly appreciated =]


EDIT:

The other very viable alternative is if you guys know of an XML to/from DXF/DWG converter.

Activating "save As" Function
how does one activate the "save as" function from flash 5.

eg. user pushes button in flash movie and "save as" box appears so users can save non-flash documents to their hard disc ???

P O O O
R T C L

THANKS

"Save As" Function Or Similar
HI there -
I'm working on a website where people can download audio files from the site. These are hyperlinks in a dynamic text file which is loaded externally.

Now it works fine when you click on the hyperlink to download. However - Depeneding on the way the persons machine is set up, it could either give you the option to save (if winamp is installed) or just start streaming like quicktime does if it is assciated with the MP3 File.

Is there anyway, to visitor the abilty to do a right click "save as" as with html ? or another method that will download the exact file, without being un predictable depeneding on what setup they are using to associate MP3's with.

(by the way Mp3's is just an example, I would just like the option to save a file that is linked in flash)

Thanks so much !

Johnnybaby

How Do I Make A Function? (for SetInterval)
hello people,

i have made a script wich i want to make in to "function" so that i kan use the setInterval. with the setInterval i want to update the script. but when i make this script a function it doesn't work.
the script works fine but it only works once and when you resize your browser it doesn't adjust to it (wich i want).
the code beneath must become a function, but how?? thanx


Code:
_root.createEmptyMovieClip("barTop", 2);
with (_root.barTop){
beginFill (0x666666, 100);
moveTo (0, 0);
lineTo (0, 0);
lineTo (0, 20);
lineTo (_root.stageMC._width, 20);
lineTo (_root.stageMC._width, 0);
endFill();
}
_root.createEmptyMovieClip("barTop2", 6);
with (_root.barTop2){
beginFill (0x333333, 100);
moveTo (0, 20);
lineTo (0, 20);
lineTo (0, 22);
lineTo (_root.stageMC._width, 22);
lineTo (_root.stageMC._width, 20);
endFill();
}
_root.createEmptyMovieClip("bg", 3);
with (_root.bg){
beginFill (0xCCCCCC, 100);
moveTo (0, 22);
lineTo (0, 22);
lineTo (0, _root.stageMC._height -20);
lineTo (_root.stageMC._width, _root.stageMC._height -20);
lineTo (_root.stageMC._width, 22);
endFill();
}
_root.createEmptyMovieClip("barBottom", 4);
with (_root.barBottom){
beginFill (0xFF6600, 100);
moveTo (0, _root.stageMC._height -20);
lineTo (0, _root.stageMC._height -20);
lineTo (0, Stage.height);
lineTo (_root.stageMC._width, _root.stageMC._height);
lineTo (_root.stageMC._width, _root.stageMC._height -20);
endFill();
}
_root.createEmptyMovieClip("welkomsbloktitle", 8);
with (_root.welkomsbloktitle){
beginFill (0x666666, 100);
moveTo (10, 32);
lineTo (10, 32);
lineTo (10, 52);
lineTo ((_root.stageMC._width/100)*32, 52);
lineTo ((_root.stageMC._width/100)*32, 32);
endFill();
}
_root.createEmptyMovieClip("welkomsblok", 7);
with (_root.welkomsblok){
beginFill (0xFFFFFF, 100);
moveTo (10, 52);
lineTo (10, 52);
lineTo (10, _root.stageMC._height -30);
lineTo ((_root.stageMC._width/100)*32, _root.stageMC._height -30);
lineTo ((_root.stageMC._width/100)*32, 52);
endFill();
}
//title
_root.createTextField("title", 5, 0, 0, 300, 20);
title.type = "dynamic";
title.html = false;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
myTextFormat.font = "Verdana";
myTextFormat.size = 10;
myTextFormat.bold = true;
myTextFormat.selectable = false;
title.text = ": Creating a interface from script : : :";
title.setTextFormat(myTextFormat);

_root.createTextField("welkomstitle", 9, 10, 33, 300, 20);
welkomstitle.type = "dynamic";
welkomstitle.html = false;
myTextFormat = new TextFormat();
myTextFormat.color = 0xFFFFFF;
myTextFormat.font = "Verdana";
myTextFormat.size = 10;
myTextFormat.bold = false;
myTextFormat.selectable = false;
welkomstitle.text = ": Welkoms tekst : : :";
welkomstitle.setTextFormat(myTextFormat);
to see it work check the *.fla

Canīt Make It Function In MX2004
Hi, I'm trying to change the background of my movie, according to the section the user selects to go. But I need the change to be made soflty, in a series of steps. I copied a code of an exercise I found back in 2000 with Flash 4. But when I use it in MX2004 for a strange reason it does not work. It makes the change of color, but without the steps.

Here is the code asigned to the mc that'll change of color:

onClipEvent (load)
{
raa = 0;
baa = 0;
gaa = 0;
init();

myColor = new Color(this);
myColor.setRGB(parseInt(startcolor,16));
function init ()
{
startcolor = "FFFFFF";
ra = new Number(00);
ga = new Number(00);
ba = new Number(00);
raa = _root.sr;
gaa = _root.sg;
baa = _root.sb;

colorsteps = 20;
colordone = true;
ci = 0;
}



function incR(dr)
{
raa += dr;
if (raa > 255)
{
raa = 255;
}
ra = new Number(Math.floor(raa));
ra = (ra).toString(16);
if (raa < 16)
{
ra = "0" + ra;
}
make();
}

function decR(dr)
{
raa -= dr;
if (raa < 0)
{
raa = 0;
}
ra = new Number(Math.floor(raa));
ra = (ra).toString(16);
if (raa < 16)
{
ra = "0" + ra;
}
make();
}



function incG(dg)
{
gaa += dg;
if (gaa > 255)
{
gaa = 255;
}
ga = new Number(Math.floor(gaa));
ga = (ga).toString(16);
if (gaa < 16)
{
ga = "0" + ga;
}
make();
}

function decG(dg)
{
gaa -= dg;
if (gaa < 0)
{
gaa = 0;
}
ga = new Number(Math.floor(gaa));
ga = (ga).toString(16);
if (gaa < 16)
{
ga = "0" + ga;
}
make();
}



function incB(db)
{
baa += db;
if (baa > 255)
{
baa = 255;
}
ba = new Number(Math.floor(baa));
ba = (ba).toString(16);
if (baa < 16)
{
ba = "0" + ba;
}

make();
}

function decB(db)
{
baa -= db;
if (baa < 0)
{
baa = 0;
}
ba = new Number(Math.floor(baa));
ba = (ba).toString(16);
if (baa < 16)
{
ba = "0" + ba;
}

make();
}

function make()
{
if (ra == "0")
{
ra = ra + "0";
}

if (ba == "0")
{
ba = ba + "0";
}

if (ga == "0")
{
ga = ga + "0";
}


farge = ra add ga add ba;

}

function changecolor()
{
if (ci < colorsteps)
{
if (difr < 0)
{
decR(difr*(-1));
}
else
{
incR(difr);
}

if (difg < 0)
{
decG(difg*(-1));
}
else
{
incG(difg);
}

if (difb < 0)
{
decB(difb*(-1));
}
else
{
incB(difb);
}

ci += 1;
myColor.setRGB(parseInt(farge,16));
}
else
{
colordone = true;
giveRGB(_root.er,_root.eg,_root.eb);
myColor.setRGB(parseInt(farge,16));
}
}



function gotoRGB(er,eg,eb)
{
oldcolorS = (myColor.getRGB()).tostring(16);

while (oldcolorS.length < 6)
{
oldcolorS = "0" + oldcolorS;
}
oldSr = oldcolorS.substr(0,2);
oldSg = oldcolorS.substr(2,2);
oldSb = oldcolorS.substr(4,2);

sr = parseInt(oldSr,16);
sg = parseInt(oldSg,16);
sb = parseInt(oldSb,16);

if (sr <> er or sg <> eg or sb <> eb)
{
_root.sr = sr;
_root.sg = sg;
_root.sb = sb;
_root.er = er;
_root.eg = eg;
_root.eb = eb;
init();
colordone = false;
incR(0);
incG(0);
incB(0);
myColor.setRGB(parseInt(farge,16));

difr = (er - sr)/colorsteps;
difg = (eg - sg)/colorsteps;
difb = (eb - sb)/colorsteps;
}
}


function giveRGB(nr,ng,nb)
{
raa = nr;
gaa = ng;
baa = nb;

incR(0);
incG(0);
incB(0);
}
}


onClipEvent (enterFrame)
{
if (not colordone)
{
changecolor();
}
else
{
}
}


And then i'm supposed to just add an "on release" action with the desired RGB, to the button that should trigger the change of color.


Any idea would be appreciated,

Ernesto Baņuelos

Help Me Make This Function Flexible..
hi,

i have the following code which determines the middle point of any triangle (or 3 points):


Code:
function getMiddleOfTriangle(p1:Array, p2:Array, p3:Array):Object {
var x:Number = (p1[0]+p2[0]+p3[0])/3;
var y:Number = (p1[1]+p2[1]+p3[1])/3;
return {_x:x, _y:y};
// usage getMiddleOfTriangle([50,0],[100,50],[0,50])
}
the way it works is by working out the average of the x-cords and the y-cords then returing it as an object,

now the code will for for any amount of points, but if you change the amount of points then you have to change the code and the amount of arguments.

so i tried to make a function which will determine the middle point of any amount of points, but i have been working on something for work all week and my brain is fried, this is what i tried:

Code:
function getMiddlePoint():Object {
args = arguments.length;
for (var z = 0; z<args; z++) {
var x = Number(arguments[z][0].toString().split(","))/args;
var y = Number(arguments[z][1].toString().split(","))/args;
}
return {_x:x, _y:y};
}
i have a feeling that i am going about this the wrong way,

can you make this work?

any help is much appreciated,

cheers,

zlatan

Make A Function Run Without EventListener?
Is it possible to make a function run without the function being called by an eventListener?

Using AS3.

MAKE A Function Happen
Anybody know if you can trigger a mouseEvent function without actually having a mouseEvent happen?

Say the function definition is:


Code:
function doStuff(event:MouseEvent):void
{
bla bla bla blal;
}


How can you make that function happen even though I didn't click or anything? Data types become an issue...

Heres what I have:


Code:
function menuFadeBlue(event:MouseEvent):void
{
if(tfArray.length > 0)
{
for(var i:uint = 0; i < tfArray.length; i++)
{
tfArray[i].visible = false;
}
contentBoxFade = new GCSafeTween(contentBox,"alpha",Regular.easeOut,contentBox.alpha,0,.5,true);
contentBoxFade.addEventListener(TweenEvent.MOTION_FINISH, nextMenu);
}

else
{
nextMenuVoid();
}

function nextMenu(event:TweenEvent):void
{
tfArray.splice(0,tfArray.length);
changeMenuBlue(event);
}

function nextMenuVoid():void
{
changeMenuBlue(event);
}
}


Notice I just copied the nextMenu function and made it have no specific input. But in both cases, i want it to happen. Any way to do it without duplication?

Make A Function Wait...
Hiya,
Im developing a simple top trumps game (nearly done: www.head-spun.co.uk/guildwars/ ).

As you can see from the link above, when you play against the computer, it whizzes through its turns so the human player cant see what is going on. So I was wondering if there is any way of getting a function to wait before carrying out the next instruction...

function myFunction(){
computerTurnOverCard();
waitFor(3);
computerChooseAttribute();
waitFor(3);
completeTurn();
}

kinda thing? I cant think of hw to do it with code. I know I could call for a blank movie Xseconds long to play, then when it stops, call another function, but that way seems messy to me.

Thanks
Abi

Make A Function Work Only Once
hello is there a way to make a function only work once reguardless of how many times its called after that one time?
Thanks

How To Make A Function With Loadvars
I have a Loadvars code and i want to make a function with it but when i add the function it doesn't work...I have googled it and somebody said that it is because of the global problem...I wonder that how we can solve the problem...Here i enclose a code that i have imagined...

Code:
function sendMessage () {
var v = new LoadVars ();
v.onLoad = function () { ... };
v.load ("http://...");
}

How Make Mc Visible With AS, Function
hi,
i have this script to animate my button.
so fare it works fine. the buttons are mc and have three states: one for up, one for over and one for press.
when first loading the swf, i want to have the first button already in the 'press' status.
i tried to do it with this:
but1.mc_butup._visible = false;
but that confuses my function of the button states.
Any help is appreciated. Thank you
_selassi
this is the scrip i have so far:


ActionScript Code:
var buttonActive;_global.buttonRelease = function(which) {if (buttonActive != nil) {with (buttonActive) {mc_butover._visible = false;mc_butup._visible = true;}}};for (i=1; i<=4; i++) {with (_root["but"+i]) {butOn = false;mc_butover._visible = false;}_root["but"+i].onPress = function() {_global.buttonRelease(buttonActive);this.mc_butup._visible = false;this.mc_butover._visible = false;butOn = true;buttonActive = this;};_root["but"+i].onRollOver = function() {if (buttonActive != this) {this.mc_butover._visible = true;} else {this.mc_butover._visible = false;}};_root["but"+i].onRollOut = function() {this.mc_butover._visible = false;};}

[MX] Cant Make Function Work
I was reading Kirupa Chinnathambi's function tutorial and I was trying to make my own function, but it's not working! Here it is:


Code:
move = function (finalX, finalY, k) {
cX = this._x;
cY = this._y;
difX = cX-finalX;
difY = cY-finalY;
setProperty(this, _x, cX-(difX/k));
setProperty(this, _y, cY-(difY/k));
}

_root.btn.onRelease = function() {
_root.ball.move ("200", "200", "5");
}
thanks for the help!

How Make Mc Visible With AS, Function
hi,
i have this script to animate my button.
so fare it works fine. the buttons are mc and have three states: one for up, one for over and one for press.
when first loading the swf, i want to have the first button already in the 'press' status.
i tried to do it with this:
but1.mc_butup._visible = false;
but that confuses my function of the button states.
Any help is appreciated. Thank you
_selassi
this is the scrip i have so far:


ActionScript Code:
var buttonActive;_global.buttonRelease = function(which) {if (buttonActive != nil) {with (buttonActive) {mc_butover._visible = false;mc_butup._visible = true;}}};for (i=1; i<=4; i++) {with (_root["but"+i]) {butOn = false;mc_butover._visible = false;}_root["but"+i].onPress = function() {_global.buttonRelease(buttonActive);this.mc_butup._visible = false;this.mc_butover._visible = false;butOn = true;buttonActive = this;};_root["but"+i].onRollOver = function() {if (buttonActive != this) {this.mc_butover._visible = true;} else {this.mc_butover._visible = false;}};_root["but"+i].onRollOut = function() {this.mc_butover._visible = false;};}

[MX] Cant Make Function Work
I was reading Kirupa Chinnathambi's function tutorial and I was trying to make my own function, but it's not working! Here it is:


Code:
move = function (finalX, finalY, k) {
cX = this._x;
cY = this._y;
difX = cX-finalX;
difY = cY-finalY;
setProperty(this, _x, cX-(difX/k));
setProperty(this, _y, cY-(difY/k));
}

_root.btn.onRelease = function() {
_root.ball.move ("200", "200", "5");
}
thanks for the help!

How Can I Make A Function Know What Called It?
Hi, I hope someone can help as I am sure this is a simple problem - my coding skills are not great by any stretch of the imagination!!

I have a very simple function set up that will change the colour of a MC:

function buttonColourOver() {
myColor = new Color(this.buttonA);
myColor.setRGB(0xBAB7A4);
}

as it stands it will only change the colour of buttonA - what I want to do is change the function so that it can be called by any button (buttonA, buttonB, buttonC, etc) and know which button has called it and hence change the correct buttons colour.

Can anyone help?

Cheers

d

LoadJPEG Function - Let's Make One
hi - It's always a pain to make a preloader for jpeg images... with that in mind I've been trying to make a generic function which would work for any jpeg os simultaneous jpeg downloads. But so far I haven't figured it out.

The ways I think this can be accomplished:

1. Change the loadMovie action prototype to work with onData and onLoad. This would be the most efficient way... a code by FlashGuru was supposed to solve this but I could not make it work:


ActionScript Code:
Movieclip.prototype.oldLoadMovie = Movieclip.prototype.loadMovie;
Movieclip.prototype.loadMovie = function(url, vars) {
    if (this.onData != undefined && this.onData != null) {
        this._parent.createEmptyMovieClip("__fixEvents", 7777);
        this._parent.__fixEvents.theTarget = this;
        this._parent.__fixEvents.onData = this.onData;
        if (this.onLoad != undefined && this.onLoad != null) {
            this._parent.__fixEvents.onLoad = this.onLoad;
        }
        this._parent.__fixEvents.onEnterFrame = function() {
            this.oldv = this.v;
            this.v = this.theTarget.getBytesLoaded();
            if (this.v != this.oldv) {
                this.onData.call(this.theTarget);
            }
            if (this.v == this.theTarget.getBytesTotal() && (this.theTarget._width>0) && (this.theTarget._height>0)) {
                this.theTarget.onData = this.onData;
                if (this.onLoad != undefined) {
                    this.theTarget.onLoad = this.onLoad;
                }
                this.onLoad.call(this.theTarget);
                this.removeMovieClip();
            }
        };
    }
    this.oldLoadMovie(url, vars);
};


the code would be mc.loadMovie("my.jpg")
mc.onData = do preload stuff
mc.onLoad = "wow it loaded!!"

2.or Making a function with setInterval - not as processor efficient as this would execute the code without any new data arriving... but could prove usefull for AS animations.

3. or making an onEnterFrame function for each jpeg to load... the problem being that a new object would need to be created as the loaded movie would delete the onEnterFrame function once the jpeg started loading... I think this is the least efficient method...



I would like help to make a short and simple solution to this constant problem!

thanks!


BTW - for AS1.0

Copyright Đ 2005-08 www.BigResource.com, All rights reserved