Working hard to get a demo done by Monday…

Vodpod videos no longer available.

bg.sun.play();

inst_mc.play();
groundhog.visible=false;
hose.visible = false;

dogBtn.buttonMode=true;
cultBtn.buttonMode=true;

dog.addEventListener(MouseEvent.CLICK, onClickDog);
dogBtn.addEventListener(MouseEvent.CLICK, onClickDog);
relocateNavBtn.addEventListener(MouseEvent.CLICK, relocateWin);
HelpBtn.addEventListener(MouseEvent.CLICK,helpWin);

function helpWin(evt:MouseEvent):void {
inst_mc.visible=true;
inst_mc.play();
}

cultBtn.addEventListener(MouseEvent.CLICK, onClickCult);
cultBtn.addEventListener(MouseEvent.MOUSE_OVER, onCultOver);
cultBtn.addEventListener(MouseEvent.MOUSE_OUT, onCultOut);
spray2.addEventListener(MouseEvent.CLICK, onClickSpray2);
//sprayBtl.addEventListener(MouseEvent.CLICK, onClickSpray);
hose_btn1.addEventListener(MouseEvent.CLICK, onClickHose1);
//hose_btn2.addEventListener(MouseEvent.CLICK, onClickHose2);
btn5.addEventListener(MouseEvent.CLICK, onClickGH);
btn6.addEventListener(MouseEvent.CLICK, onClickDeer);
//hose.addEventListener(MouseEvent.CLICK, onClickDeer);
scarecrow_btn.addEventListener(MouseEvent.MOUSE_DOWN, onSCDown);
hose.addEventListener(MouseEvent.MOUSE_DOWN, onHoseDown);
//hose.addEventListener(MouseEvent.MOUSE_UP, onHoseUp);
scarecrow.addEventListener(MouseEvent.ROLL_OUT, onSCOut);

function onCultOver(evt:MouseEvent):void {
var ct:ColorTransform = new ColorTransform();
ct.greenMultiplier = 100;
ct.greenOffset = -10;
evt.currentTarget.btnBg.transform.colorTransform = ct;
}

function onCultOut(evt:MouseEvent):void {
evt.currentTarget.btnBg.transform.colorTransform = new ColorTransform();
}

function onClickCult(evt:MouseEvent):void {
Mouse.hide();
inst_mc.visible = false;
var cult:MovieClip = new Cult();
addChild(cult);
addEventListener (Event.ENTER_FRAME, onLoopCult);
function onLoopCult(evt:Event):void {
cult.x = mouseX
cult.y = mouseY
}
}
function onClickBeer(evt:MouseEvent):void {
Mouse.hide();
var beer:MovieClip = new Beer();
addChild(beer);
addEventListener (Event.ENTER_FRAME, onLoopBeer);
function onLoopBeer(evt:Event):void {
beer.x = mouseX
beer.y = mouseY
}
}

function onClickLadyBugs(evt:MouseEvent):void {
Mouse.hide();
var bugs:MovieClip = new ladyBugs();
addChild(bugs);
addEventListener (Event.ENTER_FRAME, onLoopBugs);
function onLoopBugs(evt:Event):void {
bugs.x = mouseX
bugs.y = mouseY
}
}

function onClickSpray2(evt:MouseEvent):void {
Mouse.hide();
var spray:MovieClip = new sprayBtl();
addChild(spray);
addEventListener (Event.ENTER_FRAME, onLoopSpray);
function onLoopSpray(evt:Event):void {
spray.x = mouseX
spray.y = mouseY
}
}

function onSCDown(evt:MouseEvent):void {
scarecrow.play();
}

function onSCOut(evt:MouseEvent):void {
scarecrow.stop();
}

function onClickDog(evt:MouseEvent):void {
var dog:MovieClip = new Dog();
dog.x = 260;
dog.y = 140;
deerB.DeerC.gotoAndStop(1);
dog.play();
crowAnim.play();
if (groundhog.visible==true) {
groundhog.gotoAndPlay(1);
}
}

function onClickHose1(evt:MouseEvent):void {
hose.visible = true;
}

function onHoseDown(evt:MouseEvent):void {
hose.gotoAndPlay(“spray”);
}

function onHoseUp(evt:MouseEvent):void {
hose.gotoAndPlay(“right”);
}

function relocateWin(evt:MouseEvent):void {
var relocate:MovieClip = new Relocate();
addChild(relocate);
relocate.x = 460;
relocate.y = 270;
}

function onClickGH(evt:MouseEvent):void {
groundhog.visible=true;
groundhog.play();
}

function onClickDeer(evt:MouseEvent):void {
deerB.play();
deerB.DeerC.gotoAndPlay(1);
}

weed1.addEventListener(MouseEvent.CLICK, onClick);
weed2.addEventListener(MouseEvent.CLICK, onClick);
weed3.addEventListener(MouseEvent.CLICK, onClick);
weed4.addEventListener(MouseEvent.CLICK, onClick);

//VEGIES
tomatoe1.addEventListener(MouseEvent.CLICK, onClick);
tomatoe2.addEventListener(MouseEvent.CLICK, onClick);
tomatoe3.addEventListener(MouseEvent.CLICK, onClick);
tomatoe4.addEventListener(MouseEvent.CLICK, onClick);
oregano1.addEventListener(MouseEvent.CLICK, onClick);
oregano2.addEventListener(MouseEvent.CLICK, onClick);
oregano3.addEventListener(MouseEvent.CLICK, onClick);
oregano4.addEventListener(MouseEvent.CLICK, onClick);
oregano5.addEventListener(MouseEvent.CLICK, onClick);
oregano6.addEventListener(MouseEvent.CLICK, onClick);
carrot1.addEventListener(MouseEvent.CLICK, onClick);
carrot2.addEventListener(MouseEvent.CLICK, onClick);
carrot3.addEventListener(MouseEvent.CLICK, onClick);
carrot4.addEventListener(MouseEvent.CLICK, onClick);
onion1.addEventListener(MouseEvent.CLICK, onClick);
onion2.addEventListener(MouseEvent.CLICK, onClick);
scallion1.addEventListener(MouseEvent.CLICK, onClick);
scallion2.addEventListener(MouseEvent.CLICK, onClick);
peas1.addEventListener(MouseEvent.CLICK, onClick);
peas2.addEventListener(MouseEvent.CLICK, onClick);
basil1.addEventListener(MouseEvent.CLICK, onClick);
basil2.addEventListener(MouseEvent.CLICK, onClick);
lettuce1.addEventListener(MouseEvent.CLICK, onClick);
lettuce2.addEventListener(MouseEvent.CLICK, onClick);
lettuce3.addEventListener(MouseEvent.CLICK, onClick);
lettuce4.addEventListener(MouseEvent.CLICK, onClick);
strawberry1.addEventListener(MouseEvent.CLICK, onClick);
strawberry2.addEventListener(MouseEvent.CLICK, onClick);
strawberry3.addEventListener(MouseEvent.CLICK, onClick);
strawberry4.addEventListener(MouseEvent.CLICK, onClick);
cabbage1.addEventListener(MouseEvent.CLICK, onClick);
cabbage2.addEventListener(MouseEvent.CLICK, onClick);
cabbage3.addEventListener(MouseEvent.CLICK, onClick);
cabbage4.addEventListener(MouseEvent.CLICK, onClick);
cabbage5.addEventListener(MouseEvent.CLICK, onClick);
cabbage6.addEventListener(MouseEvent.CLICK, onClick);

function onClick(evt:Event):void {
inst_mc.visible = false;
evt.currentTarget.play();
}

/*//SOUND

var isPlaying:Boolean = new Boolean();
var pausePosition:Number = new Number();
var soundClip:Sound = new Sound();
var sndChannel:SoundChannel = new SoundChannel();

soundClip.load(new URLRequest(“av038.wav”));
soundClip.addEventListener(Event.COMPLETE, onComplete, false, 0, true);

controller.addEventListener(MouseEvent.MOUSE_DOWN, btnPressController, false, 0, true);

function onComplete(evt:Event):void {

}

function btnPressController(evt:MouseEvent):void
{
switch(isPlaying)
{
case true:
controller.gotoAndStop(“off”);
pausePosition = sndChannel.position;
sndChannel.stop();
isPlaying = false;
break;
case false:
controller.gotoAndStop(“on”);
sndChannel = soundClip.play(0,int.MAX_VALUE);
isPlaying = true;
break;
}
}*/

Advertisements

EC Banner

Vodpod videos no longer available.

Still need to check for child – then remove if child exists. Found a workaround for now….
import com.greensock.TweenLite;
import com.greensock.easing.*;

var food:MovieClip = new(theFood);
var wine:MovieClip = new(theWine);
var chefs:MovieClip = new(theChefs);
var fun:MovieClip = new(theFun);

var one:Number=764;
var two:Number=236;
slider.addChild(wine);

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
var thisPos:Number = (Math.round(this.x));
this.x-=1;

if (thisPos==490) {
food1_mc.play();
wine2_mc.gotoAndStop(1);
slider.x = wine1_mc.x;
TweenLite.to(slider, 3, {x:food1_mc.x, ease:Strong.easeOut});
slider.removeChild(wine);
slider.addChild(food);

} else if (thisPos == 355) {
food1_mc.play();
fun1_mc.play();
TweenLite.to(slider, 3, {x:fun1_mc.x, ease:Strong.easeOut});
slider.removeChild(food);
slider.addChild(fun);

} else if (thisPos == 230) {
fun1_mc.play();
chefs1_mc.play();
TweenLite.to(slider, 3, {x:chefs1_mc.x, ease:Strong.easeOut});
slider.removeChild(fun);
slider.addChild(chefs);

} else if (thisPos == 105) {
chefs1_mc.play();
wine2_mc.play();
TweenLite.to(slider, 3, {x:wine2_mc.x, ease:Strong.easeOut});
slider.removeChild(chefs);
slider.addChild(wine);

} else if (thisPos == -20) {
wine2_mc.play();
food2_mc.play();
TweenLite.to(slider, 3, {x:food2_mc.x, ease:Strong.easeOut});
slider.removeChild(wine);
slider.addChild(food);

} else if (thisPos == -145) {
food2_mc.play();
fun1_mc.play();
TweenLite.to(slider, 3, {x:fun1_mc.x, ease:Strong.easeOut});
slider.removeChild(food);
slider.addChild(fun);

} else if (thisPos == -270) {
fun1_mc.play();
chefs2_mc.play();
TweenLite.to(slider, 3, {x:chefs2_mc.x, ease:Strong.easeOut});
slider.removeChild(fun);
slider.addChild(chefs);

} else if (thisPos == -395) {
chefs2_mc.play();
wine2_mc.play();
TweenLite.to(slider, 3, {x:wine2_mc.x, ease:Strong.easeOut});
slider.removeChild(chefs);
slider.addChild(wine);

} else if (this.x<=-488) {
this.x=498;
}

}

The supplied DisplayObject must be a child of the caller.

Does anyone recall what Zevan said about this error in class? I don’t and it’s driving me crazy… I know it is referring to slider_mc.removeChild(food); but I don’t know how to fix it.

“The supplied DisplayObject must be a child of the caller.”

var food:MovieClip = new(theFood);
var wine:MovieClip = new(theWine);
var chefs:MovieClip = new(theChefs);
var fun:MovieClip = new(theFun);

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
var clipPos:Number = (Math.round(clip.x));
clip.x-=.5;
if(clipPos == 460) {
slider_mc.addChild(food);
TweenLite.to(slider_mc, 2, {x:300, ease:Bounce.easeOut});
clip.food_mc.play();

} else if (clipPos == 350) {
slider_mc.removeChild(food);
slider_mc.addChild(wine);
clip.wine_mc.play();
TweenLite.to(slider_mc, 2, {x:650, ease:Bounce.easeOut});

}
}

oops

got it – just needed to do this…

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
var clipPos:Number = (Math.round(clip.x));
clip.x-=.5;
if(clipPos == 490) {
trace(“490”);
}
}

AARRGGHHHHHH

Why doesn’t this trace out 490 when the clip position reaches 490????????

var clipPos:Number = (Math.round(clip.x));

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
clip.x-=.5;
if(clipPos == 490) {
trace(“490”);
}
}

Simple_Particle Practice

Vodpod videos no longer available.

var numOfParticles:uint=50;
var particles_ary:Array=[];

function updateStage(evt:Event):void {
if (particles_ary.length<numOfParticles) {
var ball:Ball = new Ball();
addChild(ball);
ball.xVelocity=Math.random()*10-5;
ball.yVelocity=Math.random()*10-5;
ball.x=stage.stageWidth/2;
ball.y=stage.stageHeight/2;
particles_ary.push(ball);
}
for (var i:uint = 0; i < particles_ary.length; i++) {
var particle:Ball = particles_ary[i];
particles_ary[i].update();
if(particle.x > stage.stageWidth + particle.width / 2 || particle.x < -particle.width / 2 || particle.y > stage.stageHeight + particle.height/2 || particle.y < -particle.height/2) {
particle.xVelocity = Math.random() * 10 – 5;
particle.yVelocity = Math.random() * 10 – 5;
particle.x = mouseX;
particle.y = mouseY;
}
}
}

addEventListener(Event.ENTER_FRAME, updateStage);

User Determines how many

So I thought it sounded like fun to have the user control how many elements are added to the stage – But I got stuck ummm… here:     will fix tomorrow… maybe.

var num = textBox.text;

function drop(evt:Event):void {
for (var i:int = 0; i<num; i++) {
trace(i);
}
}
drop();

Same Alley with TweenLite

This Math is still not right – there is more of the clip to be panned… still working it out.

Vodpod videos no longer available.

import com.greensock.TweenLite;
import com.greensock.easing.*;

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
TweenLite.to(alley, 2, { x:(alley.width – stage.stageWidth)/2 – mouseX, y:(alley.height – stage.stageHeight)/2 – mouseY, ease: Strong.easeOut });
}

Panning image via Mouse Position

Vodpod videos no longer available.

addEventListener(Event.ENTER_FRAME, onLoop);

function onLoop(evt:Event):void {
alley.x = (alley.width – stage.stageWidth)/2 – mouseX;
alley.y = (alley.height – stage.stageHeight)/2 – mouseY;
}

very_simple_site

Function / Var Review

Vodpod videos no longer available.

stop();

import com.greensock.TweenLite;
import com.greensock.easing.*;

TweenLite.from(content_mc, 2, { x:-500, ease: Strong.easeOut });

btn1.addEventListener(MouseEvent.CLICK, display(btn1.x,”one”));
btn2.addEventListener(MouseEvent.CLICK, display(btn2.x,”two”));
btn3.addEventListener(MouseEvent.CLICK, display(btn3.x,”thr”));
btn4.addEventListener(MouseEvent.CLICK, display(btn4.x,”fou”));
btn5.addEventListener(MouseEvent.CLICK, display(btn5.x,”fiv”));

function display(endX,frame):Function{
return function(evt:MouseEvent) {
TweenLite.from(content_mc, 2, { x:-500, ease: Strong.easeOut });
TweenLite.to(selector_mc, 1, { x: endX, ease: Elastic.easeOut });
content_mc.gotoAndStop(frame);
}
}