Highlighted

how to pass parimiters onto a movieClip through a method function

Community Beginner ,
Dec 31, 2018

Copy link to clipboard

Copied

I can pass it like example below but I want it like Movieclip.gotoAndPlay(1) or Movieclip.ColorThis(thecolor)  so what ever movieclip I want to add values is outside the function (). 

I don't know if it will ever be useful but I think it looks nicer

ColorThis(mymov,nm5);

function ColorThis(Pmov:MovieClip,mycolor:Number):void {

var newColorTransform_2:ColorTransform = new ColorTransform();

newColorTransform_2.color = mycolor;

Pmov.transform.colorTransform = newColorTransform_2;

}

TOPICS
ActionScript

Views

268

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

how to pass parimiters onto a movieClip through a method function

Community Beginner ,
Dec 31, 2018

Copy link to clipboard

Copied

I can pass it like example below but I want it like Movieclip.gotoAndPlay(1) or Movieclip.ColorThis(thecolor)  so what ever movieclip I want to add values is outside the function (). 

I don't know if it will ever be useful but I think it looks nicer

ColorThis(mymov,nm5);

function ColorThis(Pmov:MovieClip,mycolor:Number):void {

var newColorTransform_2:ColorTransform = new ColorTransform();

newColorTransform_2.color = mycolor;

Pmov.transform.colorTransform = newColorTransform_2;

}

TOPICS
ActionScript

Views

269

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 31, 2018 0
Adobe Community Professional ,
Dec 31, 2018

Copy link to clipboard

Copied

create a class for the movieclips that need a custom method and add all the public methods you need.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 31, 2018 0
Community Beginner ,
Dec 31, 2018

Copy link to clipboard

Copied

I don't understand classes much past the document class and a movie clip class from the library.  I am using neither here, this is what I got and I get this error

TypeError: Error #1006: mytest is not a function.

the classes folder is in the same folder as the main swf

package  classes{

import flash.display.MovieClip;

public class mytest extends MovieClip  {

public function mytest(Width:Number) {

this.width = Width

}

}

}

main timeline code

import classes.mytest;

mymov.mytest(100)

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 31, 2018 0
Adobe Community Professional ,
Jan 01, 2019

Copy link to clipboard

Copied

try:

var mymovie:mytest=new mytest(100);

but it doesn't seem to me that would be very useful.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 01, 2019 0
kglad LATEST
Adobe Community Professional ,
Jan 02, 2019

Copy link to clipboard

Copied

this would probably be more useful but i still don't think it's better than the msg 1 code and is definitely inferior to creating a class with its own methods and properties:

function colorF(Pmov:MovieClip,mycolor:Number):void {

var newColorTransform_2:ColorTransform = new ColorTransform();

newColorTransform_2.color = mycolor;

Pmov.transform.colorTransform = newColorTransform_2;

}

addMethodF(mc,'colorF',colorF);  // add a new method to the movieclip mc

.

.

mc.colorF(0x00ffff);  // apply the new method anytime after it's been added

// code to add a method

function addMethodF(mc:MovieClip,s:String,f:Function):void{

mc = function(col:uint){

f(mc,col);

};

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 02, 2019 0
Adobe Community Professional ,
Jan 01, 2019

Copy link to clipboard

Copied

I think I will mark this as assumed answered, because it wasn't really a question. People can still make comments.

Your original idea seemed good, whether it then is as a class doesn't matter.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jan 01, 2019 0