all groups > flash actionscript > august 2006 >
You're in the

flash actionscript

group:

shared object and color changing


shared object and color changing Walloompoom
8/30/2006 11:29:18 PM
flash actionscript:
Hi there,

Im trying to set a shared object to set the color of two mc's. everything
works up to the point of my_color.setTransform(myColorTransform); which trace's
undefined. I cant see whats heppening here. can you?



dataFile = SharedObject.getLocal("myData");
// Set color
var my_color:Color = new Color(_root.backdrop);
var my_color1:Color = new Color(_root.backdrop1);
if (_root.dataFile.data.bgColor != "") {
var myColorTransform:Object = [_root.dataFile.data.bgColor];
//_root.dataFile.flush();
trace("myColorTransform" + myColorTransform);
} else if (_root.dataFile.data.bgColor == "") {
var myColorTransform:Object = {ra:100, rb:50, ga:0, gb:0, ba:0, bb:0, aa:100,
ab:255};
trace("nothing");
} else {
null;
trace("null");
}
my_color.setTransform(myColorTransform);
my_color1.setTransform(myColorTransform);
trace(my_color.setTransform(myColorTransform));

//buttons

yellow.onRelease = function() {
var myColorTransform:Object = {ra:100, rb:100, ga:100, gb:100, ba:0, bb:0,
aa:100, ab:255};
my_color.setTransform(myColorTransform);
my_color1.setTransform(myColorTransform);
_root.dataFile.data.bgColor = " {ra:100, rb:100, ga:100, gb:100, ba:0, bb:0,
aa:100, ab:255}";
_root.dataFile.flush();
};
black.onRelease = function() {
var myColorTransform:Object = {ra:100, rb:10, ga:100, gb:10, ba:100, bb:10,
aa:100, ab:255};
my_color.setTransform(myColorTransform);
my_color1.setTransform(myColorTransform);
_root.dataFile.data.bgColor = " {ra:100, rb:10, ga:100, gb:10, ba:100, bb:10,
aa:100, ab:255}";
_root.dataFile.flush();
};
Re: shared object and color changing kglad
8/31/2006 12:55:54 AM
first, nothing is returned from the setTransform method of a color object, so
you're going to see undefined even if you use a valid color transform (which
you're not).

second, use a valid color transform: don't store a string conversion of your
color transform in your shared object, store the transform itself:



dataFile = SharedObject.getLocal("myData");
// Set color
var my_color:Color = new Color(_root.backdrop);
var my_color1:Color = new Color(_root.backdrop1);
if (_root.dataFile.data.bgColor != "") {
var myColorTransform:Object = _root.dataFile.data.bgColor;
//_root.dataFile.flush();
trace("myColorTransform" + myColorTransform);
} else if (_root.dataFile.data.bgColor == "") {
var myColorTransform:Object = {ra:100, rb:50, ga:0, gb:0, ba:0, bb:0, aa:100,
ab:255};
trace("nothing");
} else {
null;
trace("null");
}
my_color.setTransform(myColorTransform);
my_color1.setTransform(myColorTransform);
trace(my_color.setTransform(myColorTransform));

//buttons

yellow.onRelease = function() {
var myColorTransform:Object = {ra:100, rb:100, ga:100, gb:100, ba:0, bb:0,
aa:100, ab:255};
my_color.setTransform(myColorTransform);
my_color1.setTransform(myColorTransform);
_root.dataFile.data.bgColor = {ra:100, rb:100, ga:100, gb:100, ba:0, bb:0,
aa:100, ab:255};
_root.dataFile.flush();
};
black.onRelease = function() {
var myColorTransform:Object = {ra:100, rb:10, ga:100, gb:10, ba:100, bb:10,
aa:100, ab:255};
my_color.setTransform(myColorTransform);
my_color1.setTransform(myColorTransform);
_root.dataFile.data.bgColor = {ra:100, rb:10, ga:100, gb:10, ba:100, bb:10,
aa:100, ab:255};
_root.dataFile.flush();
};
Re: shared object and color changing kglad
9/8/2006 4:46:44 AM
AddThis Social Bookmark Button