[mx] Having problems... can someone help?

how would you go about passing variables to another frame?

I have enterd the below code on a MC and would like the blob object in frame 2 to change the color I specified.

Thanks in advace
Brian

[AS]on (rollOver)
{
var Color1 = new Color(this);
Color1.setRGB(0x0000FF);
}

on (rollOut)
{
var Color2 = new Color(this);
Color2.setRGB(0x000000);
}

on (release)
{
var Color3 = new Color(blob);
Color3.setRGB(0x0000FF);
var page = ‘index2.htm’;
_root.gotoAndPlay (2);
}[/AS]

if you use “var”, it is only available within whatever curly brackets it’s in, to put it subtlty. :sigh:

If you want to be able to use the variable throughout the timeline, you might want to take out the var so any frame could use those variables.

also for your page variable, you want to (i’m guessing) set page as a string, with single quotes, it only acts as a single character. so replace that line with this:

page = "index2.htm"; //i also took the liberty of taking out the var

Hey thanks!

the page string now works!

But the color of the MC blob doest change its color yet ( blob appears in frame 2)

again thanks

you’re setting the color object to the button (you use “this” which goes to the button itself). change that to the MC you want to change color.

if you look in the on (release) section i am doing just that, but it does not change the color of it.

where is “blob” located?

*Originally posted by thoriphes *
**where is “blob” located? **

blob is located on frame 2 on a different layer then the button on frame 1

I’m still pulling my hair out with this…

If anyone can give me any more ideas I would truely be thankful. It is probaby something little that I am missing this is all very new to me.

Thanks

Hi there,

Just browsing around and thought I’d try help. Just create a new movie and put the code below into frame 1 and run it.
It shows you how you can target different clips and change the colours or perform an action of some sort. Notice they all start at the same colour. The first square changes colour automatically because of an interval that is used. The colours are all random that are generated.
The second square is controlled by the small square button below. Every time you roll over or out it changes colour at random. When you press on it it changes colour to an ugly pink. When you release the button it changes back to its original colour.
All you are doing is targetting something when the event is actioned. The MC method drawframe is whats used to create the squares to avoid you having to link a clip from your library.
Just trying to simplify for you.
I hope it can help.


//MC method to draw a square
MovieClip.prototype.drawframe = function(lineColour, fillColour,cw,ch,cx,cy, fillAlpha, linealpha) {
if (itsLalpha == undefined) {
	itsLalpha = 100;
	}
with (this) {
		lineStyle(0, lineColour, linealpha);
		beginFill(fillColour, fillAlpha);
		moveTo(cx, cy);
		lineTo(cx+cw, cy);
		lineTo(cx+cw, cy+ch);
		lineTo(cx, cy+ch);
		lineTo(cx, cy);
		endFill();
	}
};
/*****************************************************************************/
function colourchangeMC(myMCobject) {
	// Following is the code for a random colour transition effect
			var incrRB = math.floor(math.random() *255) +1;
			var incrGB = math.floor(math.random() *255) +1;
			var incrBB = math.floor(math.random() *255) +1;
			_global.mysquareTrans = {rb:incrRB, gb:incrGB, bb:incrBB};
			myMCobject.setTransform(_global.mysquareTrans);
	// end of the code for a random colour transition effect
}
//globals needed for this example
_global.depthlvl = 1;
_global.mysquareTrans = new Object();
/*****************************************************************************/
//sample using an interval and random colours
var teaserClip = this.createemptymovieclip("teaser", _global.depthlvl++);
teaserClip.drawframe(0xffffff, 0xa51439,100,100,75,100, 100, 0);
teaserClip = new Color(teaserClip);
clearInterval(teaserClip.itsIid);
teaserClip.itsIid = setInterval(colourchangeMC, 1000, teaserClip);
/*****************************************************************************/
//sample 2 create the clip that will change colour
var teaser1Clip = this.createemptymovieclip("teaser1", _global.depthlvl++);
teaser1Clip.drawframe(0xffffff, 0xa51439,100,100,200,100, 100, 0);
teaser1Clip = new Color(teaser1Clip);
//create the button to control the clip
var mybutton = this.createemptymovieclip("mybutton", _global.depthlvl++);
mybutton.drawframe(0xffffff, 0xa51439,100,25,200,300, 100, 0);
//change the colour using random colour
mybutton.onrollover = function() {
	colourchangeMC(teaser1Clip);
};
//again change the colour using random colour
mybutton.onrollout = function() {
	colourchangeMC(teaser1Clip);
};
//now change the colour using a non random RGB sequence
mybutton.onpress = function() {
	_global.mysquareTrans = {rb:255, gb:40, bb:0};
	teaser1Clip.setTransform(_global.mysquareTrans);
};
//lastly change the colour back to original colour
mybutton.onrelease = function() {
	_global.mysquareTrans = {rb:0, gb:0, bb:0};
	teaser1Clip.setTransform(_global.mysquareTrans);
	//do whatever else you like here ...
};
stop();