Prototype.addProperty
Hi,
I just started with trying prototype methods. With the help of a found function I wrote this:
code:
MovieClip.prototype.addProperty('_color', this.getColor, this.setColor);
function getColor(){
return new Color(this).getRGB();
}
function setColor(rgb){
return new Color(this).setRGB(rgb);
}
That works great. Anywhere in the movie I can now change a color of an object with object._color = 0xff0000; (pretty excited about this)
However I'm trying to do the same thins with _bold. It would be great if you could just alter the textformatting by saying textbox._bold = true;
This is what I'm trying (and does not work):
code:
MovieClip.prototype.addProperty('_bold', this.getBold, this.setBold);
function getBold(){
format = new TextFormat();
return format.bold;
}
function setBold(bool){
format = new TextFormat();
format.bold = bool;
return this.setTextFormat(format);
}
Notatation or syntax may seem a bit odd, but I'm useing SWiSHmax (please don't bash me.)
Thanks for any help!
FlashKit > Flash Help > Flash ActionScript
Posted on: 02-12-2005, 11:12 AM
View Complete Forum Thread with Replies
Sponsored Links:
Addproperty And Prototype - Find My Mistake
Hi - this was going to be a simple thing but theres an error in here and I can't find it. Maybe you do? I would be glad ...
vektor.prototype = new Object();
function Vektor(x,y)
{
this.addProperty("x", this.getx, this.setx); //x-Koordinate
this.addProperty("y", this.gety, this.sety); //y-Koordinate
this.addProperty("m", this.getm, this.setm); //Anstieg
this.addProperty("a_b", this.geta_b, this.seta_b); //Anstiegswinkel in Bogenmaß
this.addProperty("a_g", this.geta_g, this.seta_g); //Anstieg in Gradmaß
this.addProperty("l", this.getl, this.setl); //Länge
trace ("this.x vor init= "+this.x);
this.init(x,y);
trace ("this.x nach setx= "+this.x);
//this.init(x,y);
}
Vektor.prototype.init= function (x,y)
{
trace("x in init= "+x);
this.Vektor.x=x;
this.y=y;
this.m=this.y/this.x;
this.l= Math.sqrt((this.x*this.x)+(this.y*this.y));
this.a_b=Math.atan2(this.y,this.x);
this.a_g=(180/Math.PI)*this.a_b;
}
Vektor.prototype.draw()
{
trace("draw");
lineStyle( 1, 0x0000ff, 100 );
moveTo (0,0);
lineTo (this.x,this.y);
}
Vektor.prototype.getx = function() {return this.x;}
Vektor.prototype.gety = function() {return this.y;}
Vektor.prototype.getm = function() {return this.m;}
Vektor.prototype.getl = function() {return this.l;}
Vektor.prototype.geta_b = function() {return this.a_b;}
Vektor.prototype.geta_g = function() {return this.a_g;}
Vektor.prototype.setx = function(x)
{
this.x=Number(x);
this.m=this.y/this.x;
this.l= Math.sqrt((this.x*this.x)+(this.y*this.y));
this.a_b=Math.atan2(this.y,this.x);
this.a_g=(180/Math.PI)*this.a_b;
}
Vektor.prototype.sety = function(y)
{
this.y=Number(y);
this.m=this.y/this.x;
this.l= Math.sqrt((this.x*this.x)+(this.y*this.y));
this.a_b=Math.atan2(this.y,this.x);
this.a_g=(180/Math.PI)*this.a_b;
}
Vektor.prototype.setm = function(m)
{
this.m=m;
this.x=this.l/Math.sqrt((this.m*this.m)+1);
this.y=this.m*this.x;
this.a_b=Math.atan2(this.y,this.x);
this.a_g=(180/Math.PI)*this.a_b;
}
Vektor.prototype.setl = function(l)
{
this.l=l;
this.x=this.l/Math.sqrt((this.m*this.m)+1);
this.y=this.m*this.x;
}
Vektor.prototype.seta_b = function(a_b)
{
this.a_b=a_b;
this.a_g=(180/Math.PI)*this.a_b;
this.m=Math.tan(this.a_b);
this.x=this.l/Math.sqrt((this.m*this.m)+1);
this.y=this.m*this.x;
}
Vektor.prototype.seta_g = function(a_g)
{
this.a_g=a_g;
this.a_b=(Math.PI/180)*this.a_g;
this.m=Math.tan(this.a_b);
this.x=this.l/Math.sqrt((this.m*this.m)+1);
this.y=this.m*this.x;
}
vek=new Vektor (20,20);
vek.draw();
View Replies !
View Related
AddProperty();
I need help with this method!
ActionScript Code:
function Book () {} Book.prototype.setQuantity = function(numBooks) { this.books = numBooks; } Book.prototype.getQuantity = function() { return this.books; } Book.prototype.getTitle = function() { return "Catcher in the Rye"; } Book.prototype.addProperty("bookcount", Book.prototype.getQuantity, Book.prototype.setQuantity); Book.prototype.addProperty("bookname", Book.prototype.getTitle, null);myBook = new Book(); myBook.bookcount = 5; order = "You ordered "+myBook.bookcount+" copies of "+myBook.bookname;
ok i understand that we are creating a class here called the book class...and we got a whole bunch o methods within this class.
what the heck does the addproperty do?!
is this what the first add property do?
it creates a property in this book.prototype called bookcount. and this bookcount property gets this.books and then sets its property as numBooks? its so confusing..can anyone explain to me how to use it exactly?
View Replies !
View Related
AddProperty();
I need help with this method!
ActionScript Code:
function Book () {} Book.prototype.setQuantity = function(numBooks) { this.books = numBooks; } Book.prototype.getQuantity = function() { return this.books; } Book.prototype.getTitle = function() { return "Catcher in the Rye"; } Book.prototype.addProperty("bookcount", Book.prototype.getQuantity, Book.prototype.setQuantity); Book.prototype.addProperty("bookname", Book.prototype.getTitle, null);myBook = new Book(); myBook.bookcount = 5; order = "You ordered "+myBook.bookcount+" copies of "+myBook.bookname;
ok i understand that we are creating a class here called the book class...and we got a whole bunch o methods within this class.
what the heck does the addproperty do?!
is this what the first add property do?
it creates a property in this book.prototype called bookcount. and this bookcount property gets this.books and then sets its property as numBooks? its so confusing..can anyone explain to me how to use it exactly?
View Replies !
View Related
Problems With AddProperty()
Hey folks
wondering is anyone else is having problems with the addProperty method. Examine the following code:
Code:
D_DataObject = function( ) {
this.p_name_str = "Default Name"; // private property
}
D_DataObject.prototype.getName = function () {
trace("getName");
return this.p_name_str;
}
D_DataObject.prototype.setName = function ( name_str ) {
trace("setName");
this.p_name_str = name_str;
}
D_DataObject.prototype.addProperty("name_str", this.getName, this.setName);
my_object = new D_DataObject( );
trace(my_object.name_str);
Neither the script editor nor the flash player output any errors from the code, but anytime I try to access my_object.name_str (created with addProperty) it returns undefined. If I attempt to set name_str, it simply creates a new property called name_str.
I using the tryout version of flash MX, under MacOS 9.2
Thanks for any help
View Replies !
View Related
Bizarre- Prototyping AddProperty
code: TextField.prototype.laoformatget = function () {
return this.laoformat;
};
TextField.prototype.laoformatset = function (lqlobj) {
trace(lqlobj)
//this.prototype.laoformat=lqlobj; this doesn't seem to work
};
TextField.prototype.addProperty("laoformat", this.laoformatget, this.laoformatset);
this.createTextField("txt1", 1, 10, 30, 100, 20);
trace("laoformat is:"+txt1.laoformat) //outputs nothing
txt1.laoformat=3
trace("init1 seted:"+txt1.laoformat) //outputs 3
oh well, if you want to move this to the as forum, it's ok, but i think there's much interesting people here, that's why i posted.
I was trying to find a way to add a property to a TextField object (prototyping). Of course you need the addProperty method, a setter and a getter function. The setter function wasn't working using code: this.laoformat=lqlobj
but did work when i did trace(lqlobj) in the setter function, instead of assigning a value to this.laoformat.
It's kinda weird, but it works and assigns the value to the property. I have been looking for similar cases but haven't found any in the internet. Is this something new i just discovered, or is it a common thing people already know of?
My conclussions so far:
Apparently the setter function works alright (using this.myvariable=parameter in the setter function)with custom objects, but with native objects (at elast with the TextField object, you need to use trace() instead)
I found that pretty weird.
View Replies !
View Related
Return The Speed Of A MC, Using AddProperty
i have written this script to get the speed of a movieClip:
ActionScript Code:
box.onEnterFrame = function() {
if (!box.oldX) {
box.oldX = box._x;
} else {
box.oldX = box.bufferX;
}
box.bufferX = box._x;
box.deltaX = box._x-box.oldX;
// 'box.deltaX' is the velocity of the
// movieClip in the x direction
// in "pixels per frame-change"
if (!box.oldY) {
box.oldY = box._y;
} else {
box.oldY = box.bufferY;
}
box.bufferY = box._y;
box.deltaY = box._y-box.oldY;
// 'box.deltaY' is the velocity of the
// movieClip in the y direction
// in "pixels per frame-change"
if (!box.oldTime) {
box.oldTime = getTimer();
} else {
box.oldTime = box.bufferTime;
}
box.bufferTime = getTimer();
box.deltaTime = getTimer()-box.oldTime;
// 'box.deltaTime' is the time for
// a "frame-change" to take place
// in milliseconds
box.velocityX = box.deltaX/box.deltaTime;
// 'box.velocityX' is the velocity of the
// movieClip in the x direction
// in "pixels per millisecond"
box.velocityY = box.deltaY/box.deltaTime;
// 'box.velocityY' is the velocity of the
// movieClip in the y direction
// in "pixels per millisecond"
};
so, at any point you can get the speed of the movieClip 'box'...
now, i would like to use MovieClip.prototype.addProperty() to apply this to all movieClips, so you can get box._velocityX etc. problem is that previously i have only used this method for 'definite' functions. for example the colour, size etc... this function works by using onEnterFrame, so is constantly looping. i am not sure how to use the addProperty function in this case
please could you help? James
ps.. is this script fast or are there better ways of getting the same result? also, using addProperty, if all movieClips are running the loop, is this a bit stupid?
View Replies !
View Related
AddProperty And Scope Problems With Inheritence
Hello all...
Bit of a frustrating problem with inheriting properties added through addProperty.
First off, I have two classes; Sprite.as and then Porter.as.
Porter inherits from Sprite using
code: Porter.prototype = new Sprite();
Sprite inherits from MovieClip in the same way.
In the Sprite class I've defined a _scale property;
code: /////////////Scale
Sprite.prototype._setScale = function(scale) {
trace("scaled");
this._xscale = scale;
this._yscale = this._xscale;
};
Sprite.prototype._getScale = function() {
trace("returning scale");
return this._xscale;
};
Sprite.prototype.addProperty("_scale", Sprite.prototype._getScale, Sprite.prototype._setScale);
//
But when I attach a porter object and pass it an init object with a _scale property it makes no difference...
code: propertyObject = function(_scale){ this._scale = _scale;};
porterProp = new propertyObject(50);
_root.attachMovie("Porter","porter",2,porterProp);
Even if I put
code: trace(this._scale);
in the porter object, it traces the 50 value, but the porter isn't actually scaled at all?!
Traces in the setter/getter show that it's never even called, so obviously the sprite isn't inheriting the setter/getter property, but it is inheriting other functions from the Sprite class, so I don't get what's wrong...help!
View Replies !
View Related
Recenter Clip Via Addproperty - Imprecise Results
if using the following to coax a clip to scale from center, the results are imprecise. at first it seems fine, but when quickly starting and stopping a motion tween, the clip will often settle a fractional distance off the intented position - over time this can be exaggerated and obvious. anything obviously wrong with the math? the approach?
Code:
someclip.addProperty("width", function() { return this._width }, function(d) { this._x+=(this._width-d)/2; this._width=d; });
someclip.addProperty("height", function() { return this._height }, function(d) { this._y+=(this._height-d)/2; this._height=d; });
View Replies !
View Related
How Do You Pass A Prototype To A Prototype?
PREFACE: This post is not as long as it looks, I just included my code as an example.
It seems that I am constantly resizing images (in MovieClips) and centering images (also in MovieClips), so I wrote a couple of simple functions to automate the process.
Then I realized that sometimes I don't want to actually center or resize the MovieClip, I just want the properties of the the resized, repositioned MovieClip. So I wrote a couple of new prototypes that basically did the same thing: they created a temporary invisible duplicate, applied the transforms, extracted and returned the properties!
I am sure there's a way that I can use one prototype function for all the transforms, but I don't know how to pass the protoype function in the definition of another prototype.
I would like to say:
ActionScript Code:
var coords:Array = this.predictValues(this.centerIn(this._parent));
this is my center prototype:
ActionScript Code:
MovieClip.prototype.centerIn=function (obj:Object) {
if (obj==""||obj==undefined) {
var srcWidth:Number= Stage.width;
var srcHeight:Number=Stage.height;
var srcScope:MovieClip=_root;
} else if(obj.length==2) {
var srcWidth:Number=obj[0];
var srcHeight:Number=obj[1];
var srcScope:MovieClip=this;
} else if (typeof(obj)=="movieclip") {
var srcWidth:Number=obj._width;
var srcHeight:Number=obj._height;
var srcScope=obj;
} else {
var srcWidth:Number=this._width;
var srcHeight:Number=this._height;
var srcScope=this;
}
var startX:Number=srcScope._x;
var startY:Number=srcScope._y;
var centerW:Number = Math.round((srcWidth-this._width)/2);
var centerH:Number = Math.round((srcHeight-this._height)/2);
this._x=startX+centerW;
this._y=startY+centerH;
}
this is my fitIn prototype
ActionScript Code:
MovieClip.prototype.fitIn = function(obj:Object) {
trace (typeof(obj));
if (obj == "" || obj == undefined) {
var maxWidth = Stage.width;
var maxHeight = Stage.height;
} else if (obj.length == 2) {
var maxWidth = obj[0];
var maxHeight = obj[1];
} else {
if (typeof (obj) == "movieclip") {
var someClip = obj;
var maxWidth = someClip._width;
var maxHeight = someClip._height;
} else {
var maxWidth = this._width;
var maxHeight = this._height;
}
}
var ratioW2H:Number = this._width/this._height;
var ratioH2W:Number = this._height/this._width;
var adjW_ws:Number = maxWidth;
var adjH_ws:Number = ratioH2W*adjW_ws;
var area_ws:Number = (adjH_ws<maxHeight) ? adjH_ws*adjW_ws : 0;
var adjH_hs:Number = maxHeight;
var adjW_hs:Number = ratioW2H*adjH_hs;
var area_hs:Number = (adjW_hs<maxWidth) ? adjW_hs*adjH_hs : 0;
if (area_ws>area_hs) {
this._width = maxWidth;
this._height = adjH_ws;
} else {
this._height = maxHeight;
this._width = adjW_hs;
}
};
These are the functions that just get the info without transforming the clip:
ActionScript Code:
MovieClip.prototype.findCenterIn=function(obj:Object):Array {
this.duplicateMovieClip(this._name+"temp",this.getNextHighestDepth(),{_visible:false});
var temp=this._parent[this._name+"temp"];
temp.centerIn(obj);
var reslt:Array = new Array(temp._x, temp._y);
temp.swapDepths(999);
temp.removeMovieClip();
return (reslt);
}
MovieClip.prototype.findFitIn=function (obj:Object):Array {
var temp=this._parent[this._name+"temp"];
temp.fitIn(obj);
var reslt:Array = new Array(temp._width, temp._height);
temp.swapDepths(999);
temp.removeMovieClip();
return (reslt);
}
As you can see these last two are basically the same function.
So what I am asking is how to make this work:
ActionScript Code:
MovieClip.prototype.findResults(someFunc:Function, obj:Object):Array {
var temp=this._parent[this._name+"temp"];
// here's the problem:
temp.call(someFunc(obj));
//????
var reslt:Array = new Array(temp._width, temp._height, temp._x, emp._y);
temp.swapDepths(999);
temp.removeMovieClip();
return (reslt);
}
Sorry for the ridiculously long post. Thanks for any help or advice you can give.
Jase
View Replies !
View Related
Does An MC Have A Prototype?
You can assign variables to an MC instance like so:
onClipEvent(load){
this.sillyVariable = 15;
}
Say I want to add a method/function to all instances of an MC. Wouldn't I need to add it to the MC's prototype object? (It doesn't seem to exist)
The following works, but is a bit inefficient I would think for many MC instances:
onClipEvent(load){
this.sillyVariable = 15;
this.MyFunction = function(value){ trace(value); }
}
Any thoughts?
What I am trying to do is create reusable components without going the smart clip route. This way I could drop a couple of MC instances in a new project and make function calls and set up properties, etc...
View Replies !
View Related
Prototype
What is one? Ive seen it used like:
thing.prototype.something = blah blah blah...
But I have no idea what it does, and I cant find anything in the help files about it.
View Replies !
View Related
What Is Prototype Used For Anyway?
I have been learning actionscript by myself for a few months, and I know about Arrays, Objects, Functions, etc. and how to use them. But the one thing I never used was the function prototype method, or whatever its proper name is.
What exactly is it used for? I cant think of what it could be, all I know is that a lot of these great coders use it, so I figured I might as well know what it is!
So can anyone spare a minute and tell me what exactly its all about!
Cheers.
View Replies !
View Related
Prototype MC
How to pass the name of a mc to a prototype function?
My program consists of:
Two Mc and one prototype for the program.
First MC is named as Green (which has got one button inside for startDrag)
second Mc Is named as GreenR
with one prototype function
How to pass the name of the second MC from first MC to prototype
This program is not working (coz of the right is a string).
-----------------------------
My Prototype function in scene 1 as follows
MovieClip.prototype.myMove = function(){
right = this._name+"R"
x_pos = this._x;
y_pos = this._y;
if (eval(this._droptarget) == right){
this._visible = false;
} else {
this._x = x_pos;
this._y = y_pos;
}
}
---------
First MC function
onClipEvent(load){
this.myMove();
}
First Mc has a button inside it
on(press){
startDrag(this);
}
on(release){
stopDrag();
}
View Replies !
View Related
Help With Prototype
I'm trying to create a prototype but the method i add to the prototype doesn't seem to be wanting to stick. Am I missing something because the function isn't being created in spawn.
duplicate.prototype = new MovieClip();
duplicate.prototype.method = function () {
trace (this._visible);
}
Object.registerClass("duplicator", duplicate);
function createmovie(name, depth) {
attachMovie("duplicator", name, depth);
}
createmovie("spawn", 5);
spawn.method();
stop();
View Replies !
View Related
About Prototype~
Hi all~
I made an experiment for inheritance but something confused me alot. that is the ways of declaring methods, plz check the code first:
code:
function Human()
{
this.head = 1;
this.walk = function(){return "human can walk~";}; // internal declaration for method~
}
Human.prototype.temp = function(){return "temp method here~";}; // external method~
when we trace method temp everthing goes right:
code:
trace(Human.prototype.temp(); // prints that string~
but a second trace for walk method we met the problem:
code:
trace(Human.prototype.walk(); // Oops we get a undefined !
and same things happens for tracing Human.walk, then where could we find walk method without inheritance(the emphisis is not using inheritance) ???
thanx in advance~
View Replies !
View Related
AS 1 & 2 - What Would You Use Instead Of PROTOTYPE?
Hello
i am switching all my code to AS2... I love it...
but there is still something I am missing....
I built so many functionalities inside prototype functions of built in objects....
MovieClip.prototype was the most used for motion effects....
How would you translate such a simple thing in AS2?
thank you and enlightment
Pippo
View Replies !
View Related
Prototype Help
i'm trying to create a generic open/close switch for an MC.
here is my code
Code:
tog = function (item) {
if (item.isClosed) {
opn(item);
} else {
cls(item);
}
};
cls = function (item, x, y, speed,scale, fade, callback) {
item.slideTo(x, y, speed,scale, fade, callback);
};
opn = function (item,x, y, speed,scale, fade, callback) {
item.slideTo(x, y, speed,scale, fade, callback);
};
i'm trying to create it so I can say:
Code:
mybutton.onRelease=function(){
mymenu1.cls
mymenu2.opn
}
I'd like to also construct a prototype so that I can dynamically set those attributes in the constructor for a specified object. The attributes will be specific to the object i'm attaching the proto to.
Code:
mymenu.prototype.togglescript=function(){
//set all specific attribuites
}
I'm not sure if any of this makes any sense, reply and I"ll explain more.
View Replies !
View Related
Can Someone Help Me With My Prototype?
Hi,
I created a prototyped to format my flash form elements, namely the TextFields. It almost works, except I can't get the
onSetFocus and onKillFocus functions working...It has something to with the fact my prototype is a MovieClip and these are TextField functions, but I cant figure out for the life of me how to make it work.
Thanks in advance
code:
// ActionScript Document
_global.FormatForm = function(form){
this.form = form;
this.init();
};
FormatForm.prototype = new MovieClip();
FormatForm.prototype.init = function(){
// --------------------
// TextField Styles
// --------------------
this.normal_border = 0xCCCCCC;
this.select_border = 0x000000;
this.normal_background = 0xEEEEEE;
this.select_background = 0x0066FF;
this.normal_color = 0x999999;
this.select_color = 0x666666;
this.format();
};
FormatForm.prototype.format = function(){
for(var a in this.form)
{
this.form[a].border = true
this.form[a].borderColor = this.normal_border
this.form[a].background = true
this.form[a].backgroundColor =this.normal_background
this.form[a].textColor = this.normal_color
this.form[a].onSetFocus = this.selected();
this.form[a].onKillFocus = this.deselected();
}
};
FormatForm.prototype.selected = function()
{
this.borderColor = this.select_border
this.backgroundColor = this.select_background
this.textColor = this.select_color
}
FormatForm.prototype.deselected = function()
{
this.borderColor = this.normal_border
this.backgroundColor = this.normal_background
this.textColor = this.normal_color
}
Oh and the reason why ive declared it as _global function is because I want to add this to a global_functions.as file i created which i'll #include in the main movie so that all child movies can access repeatedly used functions (such as this)
View Replies !
View Related
When To Use Prototype ?
When/if should I prototype AS 2.0 classes? I want to extend the functionality of AS 2.0 classes Object, XML, and Array. I have not found much about the origins of "prototype".
Was this something MX 2004 that was depreciatedin 2005?
Is it still a good idea to use it?
Will it be going away in the future?
Code:
Object.prototype.convertToXml - function{
}
So obviouly the other option is to extend the class
Code:
class Object2 extends Object{
function Object2{
}
function convertToXml():XML{
}
}
the big disadvantage with extending the class is that I can't get the compiler to treat "Object2" as an Object. (i guess that I could make it a dynamic class, but I have avoided using dynamic classes up to now b/c they seem sloppy to me.)
ex:
Code:
var myObj2:Object2 = new Object2();
var myStr:String = "hello world";
myObj2.myStr = myStr; // Compiler Error Here! "here is no property with the name 'myStr '."
ideas, thoughts, sugestions?
ty
--mm
View Replies !
View Related
Prototype
Why doesn't this work with attachMovie?
Code:
MovieClip.prototype.onLoad = function() {
trace(this);
};
//
_root.attachMovie("testMC", "testMC", 1);
View Replies !
View Related
What's A Prototype?
hi guys...i have seen it too many times to finally let it pass. I googled this, but i still can not find a really clear explanation in basic terms of what a protoype is, and how to use it. Part of the problem is that the definitions refer to a "superclass" which i am not familiar with. But also, the help document in flash refers to it in terms over my head...can someone put it in layman's terms?
View Replies !
View Related
What Exactly Is A Prototype?
Ive seen it around and searched for an explanation on its purpose and found nothing. Checked out the new aweful flash help file and couldnt make sense of things.
Im not some guru programmer so I dont understand classes either and it seems like its a "super" class. Well, what's the difference between a class and function?
Maybe if I understand the difference between a class and function a prototype may make sense 0o
View Replies !
View Related
Prototype And This.?
I'm trying to make this script, and I'm also practicing some OOP-techniques I've read.
But I can't seem to get it to work - why isn't this working:
Code:
onEnterFrame=function(){
Aimpoint();
}
function Aimpoint() {
this.addIt();
this.moveIt();
}
Aimpoint.prototype.addIt = function() {
if (!_root.aimpoint) {
_root.attachMovie("aim","aimpoint",10,_root)
}
}
The code in bold simply never gets called...
Can't I call a functions methods from within itself?
View Replies !
View Related
Prototype
Hi,
I tried overwrite the loadMovie function by the following commands
MovieClip.prototype.loadMovie = function() {
mc_loc = this;
trace(arguments+":::::::::ver written:::::::::::::::"+mc_loc);
};
but it over write only the following syntax [MovieClip.loadMovie(url)]
fl = "YourImage.jpg";
container_1.loadMovie(fl);
not overwrite the following syntax [loadMovie(url,target)]
loadMovie(fl,container_1)
Plz help me to overwrite the second sytax function also
View Replies !
View Related
XML.prototype
hello,
I'd like to add two new methods to the 'XML' class: "nextSibling()" and "previousSibling()". I'd like these 2 methods available anytime I need to manipulate and :XML type object, further in my code.
For now, I've done the following, but it doesn't seem to work. And I'm not sure where to place this code, so I've putted it in my main class:
Code:
package com.tlv.players{
import ...;
// With "this"
XML.prototype.nextSibling = function() {
return this.parent().children()[this.childIndex() + 1];
}
// With full package
XML.prototype.previousSibling = function() {
return XML.prototype.parent().children()[XML.prototype.childIndex() - 1];
}
public class MediaPlayer extends MovieClip {
...
public function MediaPlayer() {
...
}
}
}
Thanks for your help !
Regards,
Alex
View Replies !
View Related
Prototype And AS3
Hello,
I'm trying to use this two prototypes in AS3 but doesn't work and neither shows any error. Anybody knows why? Can someone help me converting this code to AS3???
Thanks
-------------------------
//fade in
MovieClip.prototype.fadeIn = function(fade) {
this.onEnterFrame = function() {
(this._alpha>=(100)) ? (this._alpha=100, delete (this.onEnterFrame)) : this._alpha += fade;
};
};
//_root.logo.fadeIn(10);
//
MovieClip.prototype.elastico_X = function(tx, ty) {
var f = 0.2;
var r = 0.3;
//f = fricion r= ratio
var xtam = 0;
var ytam = 0;
this.onEnterFrame = function() {
this._x += (xtam=xtam*f+(tx-this._x)*r);
this._y += (ytam=ytam*f+(ty-this._y)*r);
};
};
View Replies !
View Related
Prototype
i'm a bit confused about the usage of "Prototype"...
i found some tutorial with an Array.Prototype function, which i understood,
but i was actually curious if i can use this Prototype function (to be declared in some empty frame) and call it in any MC i want, at any moment, for any event.
this is, since i'm creating a game: i have lots of functions, and especially one is called in many different MCs. Actually i declared the same function in every MC (onClipEvent (load)) and then call it later on (onClipEvent(EnterFrame)).
is there any way i can declare it only one time, and then call it in different MCs?
View Replies !
View Related
Prototype Help
I was under the impression that I could use a prototype to set a default value for all reoccuring objects in a flash. For instance, I'm trying to achieve an effect where all text fields created will be unselectable.
TextField.prototype.selectable = false;
does not seem to be working... have I got it all wrong, and if so, how do I achieve this effect?
Thanks,
Rege
View Replies !
View Related
Prototype
MovieClip.prototype.onRelease = function(){
trace ("working");
delete this; // what this delete will remove
};
box2.onRelease();
what the statement "delete this" will remove? actually what that will perform.....
anyone know this....????
Edited: 12/07/2006 at 01:20:50 AM by steeban
View Replies !
View Related
Prototype
Can anyone tell me why I can't prototype Sprite?
Sprite.prototype.sayHello = function(){
trace("hello");
}
spr:Sprite = new Sprite();
spr.sayHello();
This gives a 1061 error. Although replacing the last 2 lines with
mc:MovieClip = new MovieClip();
mc.sayHello();
works fine. The first version works fine if I turn off strict mode, but I don't want to do that obviously.
This also works fine
Array.prototype.sayHello(){
trace("hello");
}
arr:Array = [];
arr.sayHello();
It seems like prototyping Graphics causes the same error. It works, so can anyone tell me why it produces a compiler error?
View Replies !
View Related
Prototype And AS3
Hello,
I'm trying to use this two prototypes in AS3 but doesn't work and neither shows any error. Anybody knows why? Can someone help me converting this code to AS3???
Thanks
Attach Code
//fade in
MovieClip.prototype.fadeIn = function(fade) {
this.onEnterFrame = function() {
(this._alpha>=(100)) ? (this._alpha=100, delete (this.onEnterFrame)) : this._alpha += fade;
};
};
//_root.logo.fadeIn(10);
//
MovieClip.prototype.elastico_X = function(tx, ty) {
var f = 0.2;
var r = 0.3;
//f = fricion r= ratio
var xtam = 0;
var ytam = 0;
this.onEnterFrame = function() {
this._x += (xtam=xtam*f+(tx-this._x)*r);
this._y += (ytam=ytam*f+(ty-this._y)*r);
};
};
View Replies !
View Related
AS1 I Use Prototype, AS2 I Use ?
Allright, i need a bit of help.
i want to do a simple function and incorpore it into every mc in my flash movie.
In mx, i use prototype, but in mx2004, you cannot use it.
how would you assign a function to selected mc's on the stage.
here what i use in mx:
---
MovieClip.prototype.xTraceName= function(){
trace(this);
};
// on first frame of mc
this.onRollOver=function(){
this.xTraceName();
};
---
how can i do the same in as2 using class or subclass ?
View Replies !
View Related
Prototype?
i often see prototype in actionscripts but i have no idea what it means.
usually i will see it as MovieClip.prototype.somethingelse
sometimes i will see others.prototype
what does this prototype stands and wat is its function?
thanks
View Replies !
View Related
Prototype
As I was wokring my way through the AS tutorials, I got to the arrays and noticed that it used prototype. Sorry, but I have little clue as to what it does. If somebody could answer this, that would bre great. Thanks in advance
View Replies !
View Related
Prototype Help
Hey,
Why wont work this prototype ?
I dont understand it.
You can download the fla here
What do it need to do: When you roll-over a piece of the skyline it need to resize to that defined number.
I putted the code in a for()-loop.
View Replies !
View Related
Lil Prototype Q
quick question about prototypes... sry if this is a scrub question and all that... i searched yes i did and didnt find the answer and i figured it should be a quick answer so i'd post.
according to my latest experiment.. you cant call a prototype twice at the same time from 2 different buttons.
is that right?
i can give an example if needed to clarity.
thanks for any help
View Replies !
View Related
Prototype ?
Hi, i was checking the code for the resizable gallery that's on "best of k", and i found this code:
Code:
MovieClip.prototype.loadPic = function(pic){
_root.containerMC._alpha = 0;
this.loadMovie(pic);
_root.onEnterFrame = function(){
var t = containerMC.getBytesTotal(), l = containerMC.getBytesLoaded();
if (t != 0 && Math.round(l/t) == 1){
var w = containerMC._width + spacing, h = containerMC._height + spacing;
border.resizeMe(w, h);
delete _root.onEnterFrame;
}
}
};
i'm "returning" to flash, after a year, almost two, so i dont remember that "prototype" function...
so, can someone plz explain it to me ???? :S what is it for? is it used instead of something else?....
View Replies !
View Related
Help With A Prototype
i need help with a prototype that calls another prototype... hope u get it
ActionScript Code:
MovieClip.prototype.tracing = function() { trace(this._name+"\n\thello, how are u doing?");};MovieClip.prototype.calling = function(proto) { this.proto();};
is that ok?
if it is.. how should i call the function "calling"?
1.- this.calling(tracing)
2.- this.calling(MovieClip.prototype.tracing)
none of that works
(dont worry if u think this is nonsense, im working with bigger prototypes, this was simplified to show my problem and nothing else)
View Replies !
View Related
Help On A Prototype
Hi everyone,
i can't find an issue on this problem:
I have a prototype
PHP Code:
TextField.prototype.changeHtmlText = function(texte:String, oldColor, effectSpeed, myTextStyle) { oldColor = (oldColor == undefined) ? "#4A6C99" : oldColor; if (myTextStyle == undefined) { var myTextStyle = new TextField.StyleSheet(); myTextStyle.setStyle("a", {color:"#ff7800", textDecoration:"none"}); //links myTextStyle.setStyle("a:hover", {color:"#99cc00", textDecoration:"none"}); //hover links } cx = this._parent.createEmptyMovieClip("texteTempControl"+this._parent.getNextHighestDepth(), this._parent.getNextHighestDepth()); this.styleSheet = myTextStyle; if (cx.tempcaixadetexte == undefined) { cx.createTextField("tempcaixadetexte", cx.getNextHighestDepth(), 0, 0, 0, 0); } cx.setTextFormat(textformat); cx.tempcaixadetexte.htmlText = this.htmlText="<font color='"+oldColor+"'>"+this.text+"</font>"; cx.textefullsize = texte.length; cx.thisfullsize = cx.tempcaixadetexte.text.length; cx.texte = texte; cx.effectSpeed = (effectSpeed == undefined) ? 5 : effectSpeed; cx.caixa = this; cx.onEnterFrame = function() { this.effectSpeed = int(this.texte.length/this.effectSpeed)+1; this.velActual = Math.min(this.effectSpeed, this.texte.length); this.pedacotexte = this.texte.substr(-this.velActual); if (this.pedacotexte.indexOf(">")>-1) { this.velActual = this.texte.length-this.texte.lastIndexOf("<"); this.pedacotexte = this.texte.substr(-this.velActual); } this.texte = this.texte.slice(0, -this.velActual); this.tempcaixadetexte.text = this.pedacotexte+this.tempcaixadetexte.text; this.tempcaixadetexte.text = this.tempcaixadetexte.text.slice(0, this.textefullsize-this.texte.length+int(this.thisfullsize*(this.texte.length/this.textefullsize))); this.caixa.htmlText = this.tempcaixadetexte.text+"</font>"; if (!this.texte.length) { this.removeMovieClip(); } };};this.createTextField("test", this.getNextHighestDepth(), 20, 20, 200, 200);test.multiline = true;test.html = true;test.wordWrap = true;//actual texttest.htmlText = "OLÁ, bem vindo,<br/><br/>Eu sou Paulo Afonso.<br/> o meu <a href='http://www.semmais.com'>site </a> e o meu <a href='http://forum.semmais.com'>fórum </a><br/><br/> Obrigado";//new textnewText = "HELLO, welcome,welcome,welcome,welcome,<br/><br/>My name is Paulo Afonso, visit <a href='http://www.semmais.com'>website </a>, my <a href='http://forum.semmais.com'>fórum </a><br/><br/> thanks";test.changeHtmlText(newText);
Try it to see what it does.
My problem is that i can't use it if i want to embed a font and seriously i don't understand why. I try to create a new textFormat, it doesn't work. the only thing that works is when i add this :
PHP Code:
cx.tempcaixadetexte.htmlText = this.htmlText="<font face='myfont' color='"+oldColor+"'>"+this.text+"</font>";
When it works weird.
If someone can lok at that and tell me what's wrong i would appreciate.
Thank you again for your help.
Chris
View Replies !
View Related
AS1 I Use Prototype, AS2 I Use ?
Allright, i need a bit of help.
i want to do a simple function and incorpore it into every mc in my flash movie.
In mx, i use prototype, but in mx2004, you cannot use it.
how would you assign a function to selected mc's on the stage.
here what i use in mx:
---
MovieClip.prototype.xTraceName= function(){
trace(this);
};
// on first frame of mc
this.onRollOver=function(){
this.xTraceName();
};
---
how can i do the same in as2 using class or subclass ?
View Replies !
View Related
Prototype?
i often see prototype in actionscripts but i have no idea what it means.
usually i will see it as MovieClip.prototype.somethingelse
sometimes i will see others.prototype
what does this prototype stands and wat is its function?
thanks
View Replies !
View Related
Prototype
As I was wokring my way through the AS tutorials, I got to the arrays and noticed that it used prototype. Sorry, but I have little clue as to what it does. If somebody could answer this, that would bre great. Thanks in advance
View Replies !
View Related
Prototype Help
Hey,
Why wont work this prototype ?
I dont understand it.
You can download the fla here
What do it need to do: When you roll-over a piece of the skyline it need to resize to that defined number.
I putted the code in a for()-loop.
View Replies !
View Related
Prototype?
Just curious here...
I have, let's say, 50 movie clips.
I want the movie clips to do something on rollover.. the will all do slightly similar things
on(rollover){
do x; //where x will be a variable
}
Is there actually a way that will save me from adding the code to each button?
Meaning, I don't want to do,
function doit(){}
button1.onRollover=doit;
button2.onRollover=doit;
button3.onRollover=doit;
Im thinking protoype? Hmm... Pom, c'mon dude. Although I understand the basic concept, I simply have not applied it to date.
View Replies !
View Related
Lil Prototype Q
quick question about prototypes... sry if this is a scrub question and all that... i searched yes i did and didnt find the answer and i figured it should be a quick answer so i'd post.
according to my latest experiment.. you cant call a prototype twice at the same time from 2 different buttons.
is that right?
i can give an example if needed to clarity.
thanks for any help
View Replies !
View Related
Prototype Help
I seem to be having trouble with this, I will explain:
I have an MC that contains 14 MC children , each of those has a tween, and I am trying to setup a "rewind" so that when someone does the mouseover, they can hit the down key to rewind the tween. This is what I have.....
parentMC (instance name "words")has within it:
onClipEvent(enterFrame){
this.Go(!(Key.isDown(Key.DOWN)));
}
Frame 1 of the main timeline has this:
words.prototype.Go = function (dir) {
gotoAndStop ((!dir) ? (_currentframe == 1) ? _totalframes : prevFrame () : play ());
}
I am quite new to this, so I will need help
View Replies !
View Related
|