webForumDet fria alternativet

Ändra färgton mha actionScript

Flashur Flash, Shockwave

5 svar · 290 visningar · startad av Cindy 156

Medlem sedan jan. 20048 inlägg
Frågan#1

Hej på er!

Nu är det jag igen som har en fråga...

Jag har en grön boll med en tonad fyllning (gradient) och jag skulle vilja veta hur man med actionScript under körning kan ändra färgtonen på bollen.

Jag har försökt att lösa problemet genom att använda Flash MX 2004:s integrerade hjälp men jag förstår inte.

Frågan är därför:

Hur kan jag ändra fägen från den urspungliga (grön) på ett movieClip med hjälp av ett actionScript till en annan fägton (ex. röd)?

Vore bra om man liksom _xscale = 150; kunde skriva något liknande _RGB = 0x00ff00;

/C

Medlem sedan nov. 20018 492 inlägg
#2
this.setRGB(0xFF0000);

Testa med den koden, brukar inte använda setRGB så där väldigt ofta precis så jag vet inte exakt hur den fungerar men nu när du vet vilken kod det är så kan du ju slå upp den i manualen om det behövs. ;) :)

Medlem sedan jan. 20048 inlägg
#3

Tack Mika3l men...
(new Color(this)).setRGB(0xffffff);
...hade jag redan testat - och problemet är att då blir hela objektet enfärgat (alltså hela movieClip objektet får en och samma färg).
Det jag vill är att jag skall ändra färgtoningen - precis som man kan göra "statiskt" genom att ta:

*properties på movieClipet
*i color-dropdown menyn väljer man advanced
*där kan man ändra respektive färgkanal.

Så skulle jag vilja göra fast med actionScript.

Medlem sedan jan. 20048 inlägg
#4

Det här är det närmaste jag kan komma en "lösning" Så här står det i Flash MX2004 hjälpen:

This example creates a new Color object for a target SWF file,
creates a generic object called myColorTransform with the
properties defined above, and uses the setTransform()
method to pass the colorTransformObject to a Color object.
To use this code in a Flash (FLA) document, place it on Frame 1
on the main Timeline and place a movie clip on the Stage with
the instance name my_mc, as in the following code:

// Create a color object called my_color for the target my_mc
my_color = new Color(my_mc);
// Create a color transform object called myColorTransform using
// the generic Object object
myColorTransform = new Object();
// Set the values for myColorTransform
myColorTransform = { ra: '50', rb: '244', ga: '40', gb: '112', ba: '12', bb: '90', aa: '40', ab: '70'};
// Associate the color transform object with the Color object
// created for my_mc
my_color.setTransform(myColorTransform);

Problemet är att jag vet inte hur jag skall få det att fungera...

/C

Medlem sedan maj 2003750 inlägg
#5

då skall du använda setTransform() istället för setRGB().

/Mirandir

Medlem sedan maj 2003750 inlägg
#6

Hehe vi skrev visst samtidigt... ;)

Så här står det i "stycket" innan i min hjälp(MX) vilket kan vara till en hjälp:

-----------------------------------------------------------------------------------
Method; sets color transform information for an instance of the Color object. The colorTransformObject parameter is a generic object that you create from the new Object constructor. It has parameters specifying the percentage and offset values for the red, green, blue, and alpha (transparency) components of a color, entered in the format .

The parameters for a color transform object correspond to the settings in the Advanced Effect dialog box and are defined as follows:

•	ra is the percentage for the red component (-100 to 100).
•	rb is the offset for the red component (-255 to 255).
•	ga is the percentage for the green component (-100 to 100).
•	gb is the offset for the green component (-255 to 255).
•	ba is the percentage for the blue component (-100 to 100).
•	bb is the offset for the blue component (-255 to 255).
•	aa is the percentage for alpha (-100 to 100).
•	ab is the offset for alpha (-255 to 255).

You create a colorTransformObject parameter as follows:

myColorTransform = new Object();
myColorTransform.ra = 50;
myColorTransform.rb = 244;
myColorTransform.ga = 40;
myColorTransform.gb = 112;
myColorTransform.ba = 12;
myColorTransform.bb = 90;
myColorTransform.aa = 40;
myColorTransform.ab = 70;

You can also use the following syntax to create a colorTransformObject parameter:

myColorTransform = { ra: `50', rb: `244', ga: `40', gb: `112', ba: `12', bb: `90', aa: `40', ab: `70'}
----------------------------------------------------------------------

/Mirandir

137 ms totalt · 3 externa anrop · v20260731065814-full.55e59744
0 ms — hämta forumlista (cache)
0 ms — hämta statistik (cache)
134 ms — hämta tråd, inlägg och bilagor (db)