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




Prototypes Won't Load Variables?



I am using FMS2 to work as a buffer inbetween my PHP Code and my Flash Client.

The thing is, my client worked flawlessly when using PHP/MySQL and Flash alone, but when integrating FMS, I encountered a few problems. It seems like when using a prototype function or onDisconnect and trying to use LoadVars() and retrieve the information the PHP file outputs, FMS returns undefined.

We tried using sendAndLoad but encounter the same errors.

Do you get what I am saying, or do you need more explanation, if you do, could you please help/explain.


Heres a better example:


Code:
Client.prototype.fncload = function(usernumber)
{
returninfo = new LoadVars();
returninfo.load("http://serverip/getinfo.php?unum=usernumber");
returninfo.onLoad = function()
{
trace(returninfo);
//returns undefined, undefined, undefined
}
}



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 01-14-2007, 09:34 PM


View Complete Forum Thread with Replies

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

Prototypes Won't Load Variables?
I am using FMS2 to work as a buffer inbetween my PHP Code and my Flash Client.

The thing is, my client worked flawlessly when using PHP/MySQL and Flash alone, but when integrating FMS, I encountered a few problems. It seems like when using a prototype function or onDisconnect and trying to use LoadVars() and retrieve the information the PHP file outputs, FMS returns undefined.

We tried using sendAndLoad but encounter the same errors.

Do you get what I am saying, or do you need more explanation, if you do, could you please help/explain.


Heres a better example:

quote:Client.prototype.fncload = function(usernumber)
{
returninfo = new LoadVars();
returninfo.load("

Using Tweening Prototypes And Variables
Hello all,

I'd like to use an array/variable with the lmc 1.2 tweening prototypes. I can't seem to get this to work. Can anyone see anything wrong with this code:


ActionScript Code:
var myArray:Array = new Array("circle");myArray[0].tween('_x', 400, 2,'easeInCubic', 0);


I've also tried:

ActionScript Code:
var myArray:Array = new Array("circle");var myVariable = myArray[0];myVariable.tween('_x', 400, 2,'easeInCubic', 0);


Can I make this work? Thanks!

My Variables Load With LoadVars...how Do I Execute A Loop To Assign Variables?
I have 52 (one for each week) duplicated MCs, a loadVars(), and variables "sermonTitle" and "airDate," which I'm trying to assign with the following:

this.airDate=_root.loadContent["airDate" + sermonDate];
this.sermonTitle=_root.loadContent["sermonTitle" + sermonDate];

which is placed in an onClipEvent (enterFrame) handler of the button which is duped . The vars load when I click Video > 2001.

The vars loaded have values named sermonTitle1, sermonTitle2, etc. and the same for airDate. The numbers attached reference the sermonDate which has already been assigned though my duplicateMovieclip loop:

num = 52;
ystart = b._y
n = 1;
while (n <= num) {
duplicateMovieClip("b", "b" + n, n);
setProperty("b" + n, _y, ystart + n*17);
this["b"+n].sermonDate = n ;
trace(this["b"+n].sermonDate);
n = n + 1;
}

I've tried attaching the assign code to the dupMovieClip loop:

num = 52;
ystart = b._y
n = 1;
while (n <= num) {
duplicateMovieClip("b", "b" + n, n);
setProperty("b" + n, _y, ystart + n*17);
this["b"+n].sermonDate = n ;
this["b"+n].airDate = "airDate" + n;
this["b"+n].sermonTitle = "sermonTitle" + n;
trace(this["b"+n].sermonDate);
n = n + 1;
}
setProperty("b", _visible, 0);

and it works - as far as assigning the correct value to the correct button, but it does not associate the loaded vars with them.

The SWF is VERY sluggish, though, which makes me think the onclipEvent is not the best way of assigning vars. I get the trace(this) showing all of the variables loading, so I know that's not the problem.


Does anyone know how to best assign these? I have been advised to use a loop for it. How would I go about executing a loop for this, as I will have navs loading in different text files - Thanks

Link to SWF:
HERE

Return Variables From Php To Load In Flash Text Variables
Im having an issue using the kirupa flash login. I already have the actual login working with php and mysql but i need to change it up a little bit and i don't know enough about php to write it myself. But here's the situation.

Flash login is a basic script, I've already modified this part and it works great

What I need to know is how to modify it so when a user logs in, php captures the $_POST and returns the alternate variable fields that consist of ("co","fname","lname","cph","email") within the ID for user and pass

also i have already made a common loadMovie to load random variables i just need the php to point to the movie

Scrollpane - Load Swf - Load Movie Symbol Controled By Buttons And Variables?
Ok i have searched the board, and racked my brain and read hundreads of bit and pieces. So far 'not happy jan'. Anyhow I thought well I shall start a thread where first I ask a question of 'can it be done' then go away try and do it and if fail 'ask how to do it' or if suceed then say 'how i did it'. Of course all questions are going to relate back to this original post so no new threads need to be started. Anyhow onto my question!!

I have a website I want to make. so I started... called it 'site.swf'. now site.swf has a scrollpane in it called 'content'.

Now I have also created 'home.swf' which has 2 movie symbols in it. one called 'homein' the other 'homeout'.

'Homein' is located in frame1 of home.swf and 'homeout' is located in frame2.

When site.swf loads I want to load home.swf into 'content' and home.swf plays 'homein'.

When the user clicks on the first button (in site.swf) 'content' plays 'homeout' before loading 'button1.swf' into 'content' and playing 'button1in'

see the pattern forming. Now I am sure this has been asked thousands of times, but I haven't found it once. At least in a form that is easy to understand.

Now can this method be done, or do i need to go away and rethink it. (my main reason for loading external.swf's is because i wish to preload where needed).

If all this can be done tell me now... I am sure I need to use 2 variables.... 'loadedmovie' and 'tobeloaded' to communiticate with 'content' and to follow the users clicks of buttons.


Thanks for any help.

Trent

Load Variables, Remembering Variables
I am trying to load variables from a text file, and have them available from then onwards in the movie, globally so to speak.

While I can read the variable values in a loader function which executes when the text file is loaded, I don't seem to be able to keep those variables available afterwards.

How do I that? Isn't AS3 wonderful? :(

John







Attach Code

var urlRequest:URLRequest=new URLRequest("index.as3.txt");
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat=URLLoaderDataFormat.VARIABLES;
urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
urlLoader.load(urlRequest);

var sspColourBG;

function urlLoader_complete(evt:Event) {
trace("During: " + urlLoader.data.extColourBG); // returns correct value
}

trace("After: " + sspColourBG); // returns undefined

Load Movie And Load Variables
on my current project

www.enhancedinnovations.com/brp/news.html


I have 2 text boxes and I have 2 problems. So far, the bio page and the news pages are completed and there are two text boxes on each page. When you go the the news page (www.enhancedinnovations.com/brp/news.html), it all loads dandily and the text loads too.. but when you click on bio, the information doesn't come up.. but if you go to the bio page (www.enhancedinnovations.com/brp/bio.html), then it all works nice and dandy..also, if you are on the news page, click the bio button, when the bio page is loaded, click the news page, and quickly glance below the buttons, you can see the "biography." which is the current text there.. can someone help me so that the text always loads no matter what? or am I just retarded and should uninstall flash?

I Need Some Help With Prototypes
I want to use a prototype to load and display swf's.
this code does the trick:


if (_root.cabinet2) {
_root.currentpic = "cabinet2"}

else {
loadMovie ("range/cabinet2.swf", "cabinet2");
_root.cabinet2 = true;
_root.currentpic = "cabinet2"}

stop ();


but all my attempts to use this code as a prototype have failed..
what i want to do is replace 'cabinet2' as a value.

here is my relatively unsuccesful attempt:


MovieClip.prototype.loadShow = function (object) {
if (_root["object"]) {
_root.currentpic = object}
else {
loadMovie ("range/"+[object]+".swf", "cabinet1");
_root["object"] = true;
_root.currentpic = object}
}

I think i am making a mistake in the dynamic mc name generation. but i'm not sure where.
any help on this would be greatly appreciated.
thanks,
m

Prototypes
I have a library of prototypes that I would like to convert to AS2.0. But I'm not sure how,

ex. how would I convert this prototype so that it is usable in AS2.0

#initclip
// randomizes an array
// returns a new array with out modifing the origional
Array.prototype.randomize = function() {
var start_array = this.slice(0);
var end_array = new Array();
while (start_array.length) {
var pos = random(start_array.length);
end_array.push(start_array[pos]);
start_array.splice(pos, 1);
}
return end_array;
};
ASSetPropFlags(Array.prototype, null, 1, 1);
//
#endinitclip

Prototypes
I trying to learn about object oriented code and prototypes, can someone explain the difference between creating a prototype and a normal function. I have looked at some prototypes and the same thing can be achieved using a standard function instead of creating a custom object.

Thanks
DL

OOP And Prototypes
Anyone know any sites for learning the basics for oop and prototypes?

Thanks
DL

AS 2.0 And Prototypes
Hello

I'm new in AS and currently working on moving an existing flash app written in AS 1.0 to AS 2.0

In current App (AS 1.0) everything works through prototypes, for example Movie Clip is extended with 23 methods

Well - as I understand the use of prototypes is depricated in AS 2.0

But is there any way to extend MC methods in AS 2.0 ?

I understand that I can create a class that extends MC, but in this case I'll have to set this class as AS class for each(!) MC in my application... and so as I've got about 900 MCs it is not a right solution for me :-/

Thanks a lot

Prototypes?
whats the diffrance between prototypes and functions? and can you make your own prototypes?

what is the prototypes really?

i've seen and used prototypes in flash, but i don't understand...

Prototypes
I am having the hardest time figuring out how to declare a prototype on the first frame of the stage.

Then call upon it in an instance on the stage in MX.

In flash five I have it all sorted out... but for some reason my method is not working when used in MX.

This what I would place in the The first frame of the stage:


Code:
Movieclip.prototype.tan_update = function() {
_xscale = 20;
_yscale = 20;
_x = Stage.width/2;
_y = Stage.height/2;
}
Then in the moveclip instance I would call upon it like so:


Code:
onclipEvent(load){
tan_update();
}
However, this "method" is not working in MX.

What is the correct way in which to do this in MX?

I just wrote that out here so disregard the case... it doesn't work in general.

thanks

Prototypes, When To Use Them?
I am pretty new to AS, and I have been using flash mx 2004 and thus AS 2.0. I was under the impression that the use of prototype was no longer needed because of how inheritence is now handle in AS 2.0. Is this true? I see lots of people posting code with use of prototype in it. Like voetsjoeba who posted a cool easing function that uses prototype. Maybe someone could show me how it might work in AS 2.0 without the use of prototype.


Quote:





Code:
MovieClip.prototype.easeX = function(to){
this.onEnterFrame = function(){
this._x = to-(to-this._x)/1.1;
if(this._x > to-1 && this._x < to+1){
this._x = to;
delete this.onEnterFrame
//do other stuff here, this is the point at which the object reaches its target
}
}
}
MC.easeX(100);





thanks,
Brian

Prototypes
Why is it that you can prototype only some AS2 classes when using strict data types for variables? For instance:

ActionScript Code:
String.prototype.traceMe = function() { trace(this);};var s:String = new String("i'm a string");s.traceMe();//error: no method named traceMe//Array.prototype.traceMe = function() { trace(this);};var a:Array = new Array(1, 2);a.traceMe();//1,2  

New To Prototypes
Can't get the following to work. Must be making a simple error. Can someone point it out


Color.prototype.setCol = function (r, g, b) {

trace("set color")

}
createEmptyMovieClip("clip1_mc",1);
var col:Color=new Color("clip1_mc");
col.setCol(10,10,10);

Using Prototypes
I'm trying to use prototypes to create a thumbnail class but I can't seem to access my prototype methods...when I trace the methods I get "undefined". Can anyone find any obvious, or even not so obvious, problems with the way I define my prototype. Shown below is my main function definition and two out of a group of functions I've defined.


Code:
function Thumbnail(filePath, name) {
this.filePath = filePath;
this.name = name;
}
Thumbnail.prototype.thumbContainer;
Thumbnail.prototype.filePath;
Thumbnail.prototype.name;

Thumbnail.prototype.getX = function() {
return this.thumbContainer._x;
};
Thumbnail.prototype.getY = function() {
return this.thumbContainer._y;
};

Prototypes In AS 3.0
Hello,

I am currently trying to rewrite the tile game code of http://www.tonypa.pri.ee/ in AS 3.0 and I am running into some issues. The first thing that gets me is the use of prototypes.

Also I change the code base to use the Sprite class

game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;

How does a prototype play into the roll of a package in AS 3? Does it exist? I think I understand the ideal of a prototype (a single property of a var that differs from any other property).

package {
import flash.display.Sprite;
public class MyGame extends Sprite {
private var myMap:Array = [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]];
private var speed:Number = 0;
private var damage:Number = 0;
private var fuel:Number = 1000;
public var game:Array = {tileW:30, tileH:30, currentMap:1, visx:7, visy:5};
public function game.Tile0():void { };

game.Tile0.prototype.walkable = true;
game.Tile0.prototype.frame = 1;

public function takeOff():void {
// . . .
}
public function crash():void {
// . . .
}
public function shoot():void {
// . . .
}
public function selfDestruct():void {
// . . .
}
}
}

Prototypes - What, When, And How
Maybe someone could shed a little more light on function.prototypes? I've had a look in the reference but it makes little to no sense to me.

What they do, When to use them and How they function?

Cheers in adv.

Prototypes, When To Use Them?
I am pretty new to AS, and I have been using flash mx 2004 and thus AS 2.0. I was under the impression that the use of prototype was no longer needed because of how inheritence is now handle in AS 2.0. Is this true? I see lots of people posting code with use of prototype in it. Like voetsjoeba who posted a cool easing function that uses prototype. Maybe someone could show me how it might work in AS 2.0 without the use of prototype.


Quote:





Code:
MovieClip.prototype.easeX = function(to){
this.onEnterFrame = function(){
this._x = to-(to-this._x)/1.1;
if(this._x > to-1 && this._x < to+1){
this._x = to;
delete this.onEnterFrame
//do other stuff here, this is the point at which the object reaches its target
}
}
}
MC.easeX(100);





thanks,
Brian

Help With Prototypes (i Think?)
Is it possible to write a custom prototype listener? You see i'd like to create a class (akin to Mouse, with onMouseDown, onMouseMove etc) which i can invoke on demand...

I have several files to create with the same AS structure, and the same basic if()'s to repeat in each one, however, I'd like to write an include to create a prototype to invoke these statements as events, (simply) ie:

if (Data && Secure && other checks && they might change) {
// Do lots of things
}

so instead of checking and rewriting each if in each movie every time these checks alter i would simply alter some AS file:

if (Data && Secure && other checks && they might change) {
// Invoke Listener
}

... in each as movie:

Banana.onInvoke () {
}

I'm sorry if this is a tad nonsensical, it's been a long week! If you dont understand then please ask, i'd like to get the ball rolling on this one

King

Prototypes Database
Hi..
The purpose of this post is to make a small database of useful prototypes for Flash.

Like, maths, mouse, color, etc.

Following this post you can add your snippets of code..
If you want.. of course!

THankS!

CreateEmptyMovieClips & Prototypes
Code:
function Clip(){
this.createEmptyMovieClip("ChildClip",3);
trace(this.ChildClip);
}
Clip.prototype = MovieClip.prototype;
myClip = new Clip();
Why doesn't this work?

Thanks in advance,
Somar!

The Mama Of All Prototypes...?
umm...I dont know where the original message went, but im looking for that thread that has the awesome dynamic AS photo gallery...just need to check some code.

I tried the search but it didnt come up with anything.

Anyone have it bookmarked?

Thanks
CB

Prototypes (not Working In MX)
Although i've had a fair bit of scripting experience in Flash 5 ...this is my first time scripting in MX... having problems with some methods i was accustomed to in F5.

All of the reusable functions I built in F5 (prototypes) ..no longer work in MX.

In F5 i would create a prototype ... like this one for example

<code>Movieclip.prototype.fade =
function () {
_alpha+=5;
}
</code>

And then an MC would call the prototype like this ...

<code>
onClipEvent(enterFrame) {
this.fade();
}
</code>

THE PROBLEM:
In Flash 5 the above prototype could be called by multiple MCs simultaneously ... all of the individual MCs calling the prototype would use its functionality independantly.
Now only one MC at a time can call the prototype at a time ... If I make more than one MC call the prototype simultaneously .. none of them work.

.. any clue as to the new method for getting this to work in MX?

Thanx in advance
Garth

Prototypes And Inheritance
Hi,

Is it possible to change a Textfield's inheritance (properties) to inherit MovieClip properties? I've tried this but no luck:


Code:
Object.TextField.__proto__ = MovieClip.prototype;

or

Code:
TextField.__proto__ = MovieClip.prototype;

Hidden Prototypes
Anyone know where I can find a list of he hidden prototypes in flash mx? I though flash guru had posted them a couple months ago, but I can't find them. I remember there was something for a microphone and webcam, but I don't remember any of the others.
Thanks

Well There Is Prototypes And Array In The Q
Hoi

this has me jumping

i got this from http://proto.layer51.com/d.aspx?f=749

but its not working
code:
Array.prototype.findAndRemove = function(toRemove) {
this = this.toString().split(toRemove+",").join("").split (",");
trace(this)// this trace shows that the toRemove has been removed
};
myArray = new Array(1, 2, 3, 3, 5, 6, 7, 8, 3, 0);
myArray.findAndRemove(3);
trace(myArray);//but when i trace myArray nothing has changed!!


its as if the change of the prototype function is not saved!!
is there some one who knows more about Prototype stuff here

Thanks

Using Movieclip Prototypes Or This, Which Is Better?
the project im working requires me to have a lot of these:

MovieClip.prototype.f=function(x){
//do stuff
}

in succession. some of these functions are very short. anyway, it makes the code unreadable and hard to look at, for me at least..

lets say i had this:

code:
MovieClip.prototype.create=function(name){
this.createEmptyMovieClip(name,depth)
}
MovieClip.prototype.kill=function(name){
this.name.removeMovieClip()
}


A lof of little functions like this, and the code starts to piss me off... is there any performance difference if I do this:

code: MovieClip.prototype.create=function(name){
c=this.createEmptyMovieCLip(name,depth)
c.kill=function(){
this.removeMovieClip()
}
}



So, does this affect the performance of the code at all? i want it to be as smooth as possible, because later functions will stress the comp..

How Exactly To Script Prototypes
how would i script this exactly? in the frame itself? on the mc? and how would i increment it using onEnterFrame or onClipEvent(enterFrame)?

Code:
Color.prototype.setBrightness = function (value) {
var t = new Object();
t.ra = t.ga = t.ba = 100-Math.abs(value);
t.rb = t.gb = t.bb = (value > 0 ? 256*(value/100) : 0);
this.setTransform(t);
}


my thought was to put this on a mc:

Code:
onClipEvent(load) {
myColor = new Color(this);
myColor.setBrightness(50);
}
onClipEvent(enterFrame) {
if (brighten) {
value += 5;
} else {
value = 50;
}
this.onRollOver = function() {
brighten = true;
}
this.onRollOut = function() {
brighten = false;
}
}

but it doesnt work. tyia.

AS2 MovieClip Prototypes
I used to make lots of MovieClip prototypes in AS1 like slideTo or fadeTo etc, and I wanna know how this works in AS2..

OnEnterFrame & Prototypes
hi,
i'm trying to use onEnterFrame inside a prototype:


PHP Code:



MovieClip.prototype.loadAndFade2 = function(path, inc){
    this.loadMovie(path);
    this._alpha = 0;
    this.onEnterFrame = function(){
        var loaded = this.getBytesLoaded();
        var total = this.getBytesTotal();
        if(loaded == total && total > 4 && this._width > 0){
            this._alpha += inc;
            if(this._alpha >= 100){
                delete this.onEnterFrame;
            }
        }
    }
}

var mc = this.createEmptyMovieClip("holder", 2);
mc.loadAndFade2("myImg.jpg", 2);




i don't understand why the onEnterFrame method don't work in this case.

thank you for help.
noir

Prototypes In Classes
I have made a class FileReader.as that reads a textfile and returns an Array with the content from the file.
My problem is that the file contains a lot of whitespace and I have earlier created a String prototype removing whitespace.
How do I implement String.prototype.removeWhites() in a class?
Should I just create a private function containg the prototypes or should I put the prototypes in a .as-file and import it if that's possible?

The prototype:

Code:
String.prototype.removeWhites = function() {
this = this.trimLeft ();
return this.trimRigth();
}


The class

Code:
class LMSReader{
private var __infoObj:Array;

//Contructor
public function LMSReader(inFile:String) {
var lv:LoadVars = new LoadVars();
lv._parent = this;
lv.onData = function(inString){
//blablabla
}
lv.load(inFile);
}

//Get method
public function get lms():Array {
//Return lms:array
return __infoObj;
}
}

Prototypes In Flash 8
I'm using this resize prototype in flash 6:

/** RESIZE ************************************************** *****************/
function resizeMC (objet, X, Y, speed) {
if(!resizeMCArray) {
resizeMCArray = [[],[]];
}
var found = false;
for(i=0; i<=resizeMCArray[0].length; i++) {
if(resizeMCArray[0][i] == objet) {
found = true;
if(resizeMCArray[1][i] != objet._resize) {
clearInterval(resizeMCArray[1][i]);
resizeMCArray[1][i] = objet._resize;
};
if( (Math.ceil(objet._width) < ( Math.ceil(X - 1) ) ) || (Math.ceil(objet._width) > ( Math.ceil(X + 1) ) ) ){
objet._width += (X - objet._width)/speed;
} else {
objet._width = X;
};
if( (Math.ceil(objet._height) < ( Math.ceil(Y - 1) ) ) || (Math.ceil(objet._height) > ( Math.ceil(Y + 1) ) ) ){
objet._height += (Y - objet._height)/speed;
} else {
objet._height = Y;
};
if( (objet._width == X) && (objet._height == Y) ) {
clearInterval(objet._resize);
};
};
};
if (found == false) {
var long = resizeMCArray[0].length
resizeMCArray[0][long] = objet;
resizeMCArray[1][long]= objet._resize;
}
};

Movieclip.prototype.resize = function (targetX, targetY, speed) {
clearInterval(this._resize);
this._resize = setInterval(resizeMC, 40, this, targetX, targetY, speed);
}

/************************************************** ***************************/


(source: http://www.actionscript.org/tutorial...on/index.shtml)

This works fine! Why would'nt this work in flash 8??????

Possible To Have 2 Button.prototypes?
Hi I have a button prototype nested in a clip with a few buttons


PHP Code:



Button.prototype.onRelease = function() {
    if (this._name.slice(0, 4) == "butt") {
            trace(this._name);

      }
};




that works fine on its own.. but when I have another clip with the same code, it seems to cancel it out

is it impossible to have 2 prototypes?

thanks

Questions About How To Use Prototypes
1)

Code:
Color.prototype.fade = function() {
trace("asdf");
}

this.onEnterFrame = function() {
var col:Color;
col.fade();
}


I have this code in the first frame of my movie. When I try running it, I get the following error:

Quote:




**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 16: There is no method with the name 'fade'.
col.fade();







2) Is it possible to have prototype functions defined in a seperate .as file and then imported/included into the main program? I've tried doing this a couple of times and I wither get a compilation error or the function doesn't get called when I try to use it.

_root Prototypes
Hi guys. I'm having a problem related to prototypes:

In the main timeline of the 1st scene I have this:


Code:
#include "files_as/prototypes/proto_multiprop.as"
#include "files_as/prototypes/barra_nav/bt_press.as"
the proto_multiprop.as file goes like this:


Code:
MovieClip.prototype.multiProp = function(proper, targetv, smooth) {
this[proper] -= (this[proper]-targetv)/smooth;
};
and the bt_press.as file:


Code:
Button.prototype.bt_press = function() {
_root.NAV_BASE.cursor.cursor_red.onEnterFrame = function() {
this.multiProp("_alpha", 0, 5);
};
rollover.onEnterFrame = function() {
this.multiProp("_x", -472, 5);
};
lnha_up.onEnterFrame = function() {
this.multiProp("_y", -35, 5);
this.multiProp("_alpha", 0, 5);
};
lnha_down.onEnterFrame = function() {
this.multiProp("_y", 45.9, 5);
this.multiProp("_alpha", 0, 5);
};
};
Now in the 3rd scene, in a MC timeline I've got this button, bt_form, and several MC's referenced in the bt_press.as file, like for ex: lnha_up and lnha_down.

The button I use to activate the proto bt_press, has the following:


Code:
on (press) {
bt_form.bt_press();
}
What I'm trying to do is to call the multiProp prototype on to multiple movie clips(lnha_up, lnha_down, etc) using the other prototype bt_press.

The multiProp prototype seems to work on all movie clips on all scenes on the swf, if I call the prototype directly, but if I call it using the bt_press prototype, it doesn't work.

It works if I put this on the MC timeline where the button and the MC's are:


Code:
#include "files_as/prototypes/barra_nav/bt_press.as"
But I would have to call this again and again since I have An infinit number of MC's that I want to use the bt_press prototype.

Can someone give a hand on this, perhaps the solution maybe pretty simple, but it's cracking my head... to pieces.
Thank you.

Prototypes And Funtions
This may be a little problem but I can't figure out.
I try to set a prototype that controls a kind of vibrating movement for letters. These letters are inside of a mc called VE(vibr. effect)
and I type the code in the first frame of the mc timeline but doesn´t works.

this is the code

MovieClip.prototype.vib = funtion();

sx = this._x;
sy = this._y;
this._x = sx+(Math.random()*5);
this._y = sy+(Math.random()*5);

for (i=0; i<21; i++) {
_root["ve"+i].vib();
}

If anyone can help I'd be grateful:

hr:

Prototypes For Components
How to you assign prototypes to components?

SetInterval With Prototypes
I have a movieclip prototype which I want to be applied to different movieclips every so often. The prototype controls it's movement, when it runs, the mc eases to a random x and y and stops. After that I want it to keep executing that movement prototype over and over, ie, keep moving around.

I know how to use setInterval with functions, and I know movieclip prototypes basically are functions, but how can I get setInterval to work with movieclip prototypes assigned to specific movieclips?

Multiple Prototypes For One Mc?
I want to apply two different prototypes to one mc (one for movement, one for behavior), but both prototypes have onEnterFrames in them...so the one executed last works but the one executed before it won't. How can I fix this problem?



(It may sound terribly ineffecient to have 2 prototypes for 1 mc, but one prototype is applied to many mcs, and the other is applied to only certains types of mcs (in this movie)).

Prototypes And Speed
Hey all,
Just wondering, if i use like 30+ MC prototypes, will it slow down the performance of my Movie significantly? I assume it would only take a hit on memory usage and not so much CPU ussage, am i correct?

Tweening Prototypes
Hi!

I have created an swf containing laco's tweening prototpyes (http://laco.wz.cz/tween/). Now I'm trying to load this swf into an empty mc via the loadMovie command but the tweens don't seem to work any more, eg. I don't see any animtion in the swf loaded.

Any suggestions how the swf must be loaded correctly?

Thanks,
Simon

Prototypes And Movies
Hello, i am not a flash expert so i hope i make myself understood:

I have two SWF movies that load into another one.
They are two sliding kind of menus with the following code in the main timelime:

MovieClip.prototype.move2 = function () {
dest = _root.xnew ;
pos = this._x ;
vel = vel*0.7 + (dest-pos)/10 ;
this._x += vel ;
}
MovieClip.prototype.move = function () {
dest = _root.xnew ;
pos = this._x ;
vel = (dest-pos)/10 ;
this._x += vel ;
}

there are also two buttons in each one that make the menu slide. this is the code of one of them

on (press) {
if(_root.xnew>-0)
_root.xnew -= 100
else
_root.xnew = 0
}

When they are both loaded (two independent SWF movies with the menus) into the main movie, the buttons of one of them stop functioning and they both respond at the same time to the buttons of the other one.
I found out that if i publish in flash5 the become dettached and work properly but i need to publish them in a higher version because of other features i am using.

Is there anybody that can explain what is going on, and maybe give me an idea of how to fix it?

thanks!

kirupa is amazing!

Classes And Prototypes
Hi all

I've built a class which extends MovieClip an works ok.
In this class i'm creating some MCs

and this part works ok.

Before i've built some prototypes which adds some methods to the MovieClip object
I'd like to use these methods in the class i've created.

But using the include before the class statement throws an error during compile

How can i do to add the methods in the prototypes to my MCs in my class?

Using Color Prototypes
Hey there,

So I only found out what prototypes are this morning! And I got a couple working, but I can't work out how to apply this one from robertpenner.


ActionScript Code:
//tint an object with a color just like Effect panel//r, g, b between 0 and 255; amount between 0 and 100Color.prototype.setTint = function (r, g, b, amount) {    var percent = 100 - amount;    var trans = new Object();    trans.ra = trans.ga = trans.ba = percent;    var ratio = amount / 100;    trans.rb = r * ratio;    trans.gb = g * ratio;    trans.bb = b * ratio;    this.setTransform(trans);}//Robert Penner June 2001 - <a href="http://www.robertpenner.com" target="_blank">www.robertpenner.com</a>  


I have tried;
myMC.Color.setTint(120,0,0,60);
and also
myMC.color.setTint(120,0,0,60);
but neither work

Can anyone help?

Thanks

Classes And Prototypes.
hello.
was looking into classes,
I wonder if they are needed,
Like i want to make a circle with a prototype added.
This doesnt work, and i wonder how i would make it work?(Might be lots of syntax here)

ActionScript Code:
class Circle{this.isCrazy()} MovieClip.prototype.isCrazy = function (){this.onEnterFrame = function (){this._x = Math.Random()*20}}


Is classes needed for this? What good comes with classes?

Ghost Prototypes?
Flash is leading me to believe that my prototypes for the MovieClip class are haunted. Seriously. I have defined a couple of methods for the MovieClip class (setOutline and reloadItem), but recently changed a fair bit of the functionality of these methods.

By changed, I mean, commented out the entire contents of the setOutline method, and removed a bunch of traces from the reloadItem method.

So, when I test my swf locally, in Flash 8, everything works great. The setOutline method gets called by several objects, but, since the method contains no code, nothing happens. The reloadItem doesnt trace the stuff it used to. All good.

Or not. The craziest thing happens when I simulate download, or when I upload the swf live and view it in the browser....

Suddenly, setOutline works again. Suddenly, reloadItem traces all the wrong shiznit again.

WHAT THE GYUCK? Its as if Flash remembers the old versions of the methods, but only when its being streamed? Eh? Anyone who knows what the hell is going on, please dear God help me

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