Followers

Showing posts with label Flash. Show all posts
Showing posts with label Flash. Show all posts

Friday, April 24, 2015

Flash: Buttons and Scenes Code

Below is code to make your buttons work with scenes.
To read more about it go here
http://www.myglife.org/usa/eaprepmlk/index.php/Help:Ingredients_-_Buttons


Draw 4 buttons on Scene 1.
Each button should have an instant name of nextButton1, nextButton2, and so on.
Make 4 scenes.
Copy the buttons to all of your scenes.
Now copy the code and put it on Scnene 1.
Test.

Here is the code...


stop();
 
import flash.events.MouseEvent;
import flash.ui.Mouse;
 
addEventListener(MouseEvent.CLICK, onMouseClick);
 
function onMouseClick(evt:MouseEvent)
{
 if(evt.target.name == "nextButton1")
 {
  gotoAndStop(1, "Scene 1");
 }
        if(evt.target.name == "nextButton2")
 {
  gotoAndStop(1, "Scene 2");
 }
      if(evt.target.name == "nextButton3")
 {
  gotoAndStop(1, "Scene 3");
 }
    if(evt.target.name == "nextButton4")
 {
  gotoAndStop(1, "Scene 4");
 }
}

Thursday, April 16, 2015

Flash: Mobile Mouse Control Code

This code uses Mouse Control for Player.
The enemy and collectable object will slowly scroll across the screen.




import flash.events.Event;

stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addChild(player);
player.x = stage.mouseX;
player.y = stage.mouseY;
var score = 0;
var health = 10;

function gameLoop(evt:Event)
{
player.x  = stage.mouseX;
player.y  = stage.mouseY;

enemy.x = enemy.x - 1;
collectable.x = collectable.x - 3;


// IF THE PLAYER HITS THE COLLECTABLE

if(player.hitTestObject(collectable) && collectable.visible == true)

{
collectable.visible = false;
score = score + 1;
}

scoreDisplay.text = "Score: " + score;

//IF THE PLAYER HITS THE ENEMY

if(player.hitTestObject(enemy) && enemy.visible == true)

{
enemy.visible = false;
health = health - 1;
}

healthDisplay.text = "Health: " + health;
}

Wednesday, April 8, 2015

Flash: Enemy Chase Code

import flash.events.Event;

stage.addEventListener(Event.ENTER_FRAME, gameLoop);

function gameLoop(evt:Event)
{
 if(enemy.x < player.x)
{
     enemy.x +=1;
}
if(enemy.x > player.x)
{
     enemy.x -=1;
}
if(enemy.y < player.y)
{
     enemy.y +=1;
}
if(enemy.y > player.y)
{
     enemy.y -=1;
}
}

Flash: Mouse Control of the Player

player.x = stage.mouseX;
player.y = stage.mouseY;

Tuesday, April 7, 2015

Flash: AS3 Player Control with Arrow Keys

Originally published 2/5/15


Copy the code below and add it to your actions in Flash.


import flash.events.Event;
import flash.events.KeyboardEvent;
 
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyReleased);
addEventListener(Event.ENTER_FRAME, gameLoop);
 
var playerSpeed = 2;
player.x = 400;
 
var isLeftKeyDown = false;
var isRightKeyDown = false;
var isUpKeyDown = false;
var isDownKeyDown = false;
 
function onKeyPressed(evt:KeyboardEvent) {
 
 if(evt.keyCode == Keyboard.LEFT) {
     isLeftKeyDown = true;
 }
 
 if(evt.keyCode == Keyboard.RIGHT) {
     isRightKeyDown = true;
 }
 
 if(evt.keyCode == Keyboard.UP) {
     isUpKeyDown = true;
 }
 
 if(evt.keyCode == Keyboard.DOWN) {
     isDownKeyDown = true;
 }
}
 
function onKeyReleased(evt:KeyboardEvent) {
 
 if(evt.keyCode == Keyboard.LEFT) {
     isLeftKeyDown = false;
 }
 
 if(evt.keyCode == Keyboard.RIGHT) {
     isRightKeyDown = false;
 }
 
 if(evt.keyCode == Keyboard.UP) {
     isUpKeyDown = false;
 }
 
 if(evt.keyCode == Keyboard.DOWN) {
     isDownKeyDown = false;
 }
}
 
function gameLoop(evt:Event) {
 if(isLeftKeyDown == true) {
     player.x-=playerSpeed;
 }
 
 if(isRightKeyDown == true) {
     player.x+=playerSpeed;
 }
 
 if(isUpKeyDown == true) {
     player.y-=playerSpeed;
 }
 
 if(isDownKeyDown == true) {
     player.y+=playerSpeed;
 }
}

Monday, March 30, 2015

Flash Mobile: Enemy Scroll and Collect Collectable Code

Below is Actionscript 3 code that once is input into your Actions Frame in Flash will allow your player character to move with the mouse, collect an object and the enemy will scroll from right to left.

(Originally published 2/11/15)


import flash.events.Event;
stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addChild(player);

var score = 0;
var health = 0;

player.x = stage.mouseX;
player.y = stage.mouseY;

function gameLoop(evt:Event)
{
player.x = stage.mouseX;
player.y = stage.mouseY;

collectable.x = collectable.x - 3;
enemy.x = enemy.x - 3;

        if(player.hitTestObject(enemy) && enemy.visible == true)
        {
     health = health - 5;
              enemy.visible = false;
        }

if(player.hitTestObject(collectable) && collectable.visible == true)
        {
     score = score +1;
              collectable.visible = false;
        }

        scoreDisplay.text = "Score:" + score;
        healthDisplay.text = "Health:" + health;

}

Thursday, February 12, 2015

Flash Animation: The Forest

https://www.youtube.com/watch?v=rTXudHZM39Q

Is your inner peace an utopian state until you have finally escaped the grip of the society and its rules? Or is affirmation a faster way to your personal luck? And what are you supposed to do, if you have to answer this question at the age of 12?

In the Animated Short "The Forest", the protagonist has to cope with this question and her hostile environment and finds a simple but radical solution.

Conceived, written, directed and animated by
David Scharf
http://www.huesforalice.com

Sound and Music
Javi Otero & César Meler, 48 Billion Atoms

Speakers voice girl
Neath Champion-Weeks

Speakers voice TV Ads
Stephen Taylor

Characterdesign
André Ljosaj
http://www.smatik.de

Flash Animation: Anytime is Ice Cream Time!

https://www.youtube.com/watch?v=VXeQDCNEyCM

Flash Animation Man Interacts with His World

https://www.youtube.com/watch?v=WfGMYdalClU

Monday, February 2, 2015

Flash: AS3 Health Bar Code

import flash.events.Event;

stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addChild(player);

var health = 100;

player.x = stage.mouseX;
player.y = stage.mouseY;

function gameLoop(evt:Event)
{
if(player.hitTestObject(enemy) == true) {
       health = health - 1;
}

healthBar.scaleX = health / 100;

player.x  = stage.mouseX;
player.y  = stage.mouseY;

if(enemy.x < player.x)
{
     enemy.x +=1;
}
if(enemy.x > player.x)
{
     enemy.x -=1;
}
if(enemy.y < player.y)
{
     enemy.y +=1;
}
if(enemy.y > player.y)
{
     enemy.y -=1;
}
}

Thursday, January 29, 2015

Joshua Davis Skillshare Class

http://www.skillshare.com/classes/design/Programming-Graphics-II-Generative-Art-Animation/388564917?teacherRef=126839&utm_campaign=teacher-referral&utm_source=ShortUrl&utm_medium=teacher-referral

Flash Enemy Chase Code AS3

import flash.events.Event;

stage.addEventListener(Event.ENTER_FRAME, gameLoop);
stage.addChild(player);

player.x = stage.mouseX;
player.y = stage.mouseY;

function gameLoop(evt:Event)
{
player.x  = stage.mouseX;
player.y  = stage.mouseY;


if(enemy.x < player.x)
{
     enemy.x +=1;
}
if(enemy.x > player.x)
{
     enemy.x -=1;
}
if(enemy.y < player.y)
{
     enemy.y +=1;
}
if(enemy.y > player.y)
{
     enemy.y -=1;
}
}

Wednesday, January 28, 2015

Flash AS3 Player Control with Arrow Keys Code

import flash.events.Event;
import flash.events.KeyboardEvent;
 
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyReleased);
addEventListener(Event.ENTER_FRAME, gameLoop);
 
var playerSpeed = 2;
player.x = 400;
 
var isLeftKeyDown = false;
var isRightKeyDown = false;
var isUpKeyDown = false;
var isDownKeyDown = false;
 
function onKeyPressed(evt:KeyboardEvent) {
 
 if(evt.keyCode == Keyboard.LEFT) {
     isLeftKeyDown = true;
 }
 
 if(evt.keyCode == Keyboard.RIGHT) {
     isRightKeyDown = true;
 }
 
 if(evt.keyCode == Keyboard.UP) {
     isUpKeyDown = true;
 }
 
 if(evt.keyCode == Keyboard.DOWN) {
     isDownKeyDown = true;
 }
}
 
function onKeyReleased(evt:KeyboardEvent) {
 
 if(evt.keyCode == Keyboard.LEFT) {
     isLeftKeyDown = false;
 }
 
 if(evt.keyCode == Keyboard.RIGHT) {
     isRightKeyDown = false;
 }
 
 if(evt.keyCode == Keyboard.UP) {
     isUpKeyDown = false;
 }
 
 if(evt.keyCode == Keyboard.DOWN) {
     isDownKeyDown = false;
 }
}
 
function gameLoop(evt:Event) {
 if(isLeftKeyDown == true) {
     player.x-=playerSpeed;
 }
 
 if(isRightKeyDown == true) {
     player.x+=playerSpeed;
 }
 
 if(isUpKeyDown == true) {
     player.y-=playerSpeed;
 }
 
 if(isDownKeyDown == true) {
     player.y+=playerSpeed;
 }
}

Friday, January 16, 2015

Flash: Designing Characters Pt 4 and 5

https://www.youtube.com/watch?v=iEN4cL8caxc

Today we will watch part 4 and 5 of designing characters in Flash.
Part for is really short, 7 mins.

A technique you will learn

Duplicate Symbol

Thursday, January 15, 2015

Tuesday, January 13, 2015

Flash: Design Character Pt 2

https://www.youtube.com/watch?v=XtYqYl3cnfo&src_vid=833CZ1OVSVU&feature=iv&annotation_id=annotation_966899

Techniques to Learn

Hold down ALT key on a line to add an anchor point
Deselect by holding down Shift
MODIFY > Tranform > Flip Horizontal

Flash: Designing Characters For Animation pt1

https://www.youtube.com/watch?v=833CZ1OVSVU

Some techniques you will learn:

Drawing with Line tool and modifying shapes
Organizing Flash files for Animation
Using Symbols
Pivot Points
Convert Lines to Fills
Saving Color Swatches