RE: Flash Q&A Thread 6 - We help! (Full Version)

All Forums >> [Gaming Community] >> [Legends and Lore] >> Artists of Legend >> Art Academy



Message


MegaPoster404 -> RE: Flash Q&A Thread 6 - We help! (1/30/2010 18:39:33)

That was never turned on... :/




Steel Fire -> RE: Flash Q&A Thread 6 - We help! (1/30/2010 19:49:04)

First, just want to say that I'm using Actionscript 3.0, so I'll need someone to answer with experience in it. (I'm also using Flash CS4.)

In a small project, I want to be able to click the background to start the beginning animation. I made a symbol called "backgroundClick"
This is the code I am using to do this on the first frame;

stop();

// How to start Button Animation.
backgroundClick.addEventListener(MouseEvent.CLICK, startAnimation);

//Functions for Button Animation.
function startAnimation(e:MouseEvent):void
{
	start();
}


The stop command at the beginning is to stop the animation from commencing.
Then I have the MouseEvent.CLICK Event Listener so it executes the "startAnimation" function when backgroundClick is clicked.
Then, the function "startAnimation" will use the start command to begin the animation.

Now, I'm having a bit of trouble with this. When I Test the SWF, I get 2 errors;

1. Error 1180: Call to a possibly undefined method start. Source: start();
2. Error 1061: Call to a possibly undefined method addEventListener through a reference through a static type class. Source: backgroundClick.addEventListener(MouseEvent.CLICK, startAnimation);

Also, when I test the SWF, the animation begins, and loops.

I'm not sure if this is because I named one of the Symbols wrong, or something, or if the Code is wrong. Why is this happening?




Vampire and Human -> RE: Flash Q&A Thread 6 - We help! (1/30/2010 22:34:46)

Steel Fire: Here is a useful guide to follow. http://www.csupomona.edu/~llsoe/42101/Flash/AS3buttons.htm

The reason it is giving you an error is because "start()" is not a real command. It only goes by certain things in the language, which I assume you thought was available because it is the opposite of stop(). The actual command for that situation is play(), and for specifics use gotoAnd follow by either with a specific frame put in the parenthesis.

For example:

gotoAndStop(2)

gotoAndPlay(2)

One will go, and be stopped, at the frame.

The other, however, will go to the frame and continue playing the movie from that point.

You can also use frame names, but I don't want to confuse you yet. It is mentioned more in depth in the link I provided.




Megaposter404: Your code confuses me... Too messy, quite unorganized. I'd have to see the full thing. Location starts etc... It could be as easy as an issue with variable scope, or as difficult as trigonometry (GAH!).




Steel Fire -> RE: Flash Q&A Thread 6 - We help! (1/31/2010 0:37:04)

Thank you Vampire and Human, that was extremely helpful. Thanks. :) And yes, I thought it was start() because it was the opposite of stop()




Vampire and Human -> RE: Flash Q&A Thread 6 - We help! (1/31/2010 8:53:21)

Steel Fire: Don't mention it :).
And yeah, I made that same exact mistake when I first started, but I tried like, 80 different things [:D]. Your not alone, I tried go(), I tried start(), I tried telling to stop() a second time . . . I was even worse :P.





Steel Fire -> RE: Flash Q&A Thread 6 - We help! (1/31/2010 17:48:24)

Hi Again. :)

Using Actionscript 3.0, I followed that tutorial you gave me. But one of the code was; stopBtn.addEventListener(MouseEvent.CLICK, onStopClick, false, 0, true);
I've been using that code, and it works, but I wanted to know something. What is the "false, 0, true);" for?
Thanks in Advance.

Also, I'm having a problem that I can't figure out, this is the code I'm using;

stop();

// Click Start Button to begin main sword animation.
startShade.addEventListener(MouseEvent.CLICK, startAnimation);
startButton.addEventListener(MouseEvent.MOUSE_OVER, mouseOverShade);
startShade.addEventListener(MouseEvent.MOUSE_OUT, mouseShade);

// Animation Function.
function startAnimation(evt:MouseEvent):void {
gotoAndPlay(32);
}

function mouseOverShade(evt:MouseEvent):void {
startButton.visible = false
}

function mouseShade(evt:MouseEvent):void {
startButton.visible = true
}


The stop() command is to pause the timeline.
The 3 addEventListener's is for the 3 following functions.

function startAnimation(evt:MouseEvent):void {
gotoAndPlay(32);
}
That function is to start the rest of the animation.

function mouseOverShade(evt:MouseEvent):void {
startButton.visible = false
}
That function is so the startButton will disappear if the mouse is put on the button, letting the shaded version of the startButton be displayed. (Therefore making it look shaded)

function mouseShade(evt:MouseEvent):void {
startButton.visible = true
}
This function is is to make the original startButton re-appear if the mouse is taken off of the shaded version.




My problem is that everytime I try to test the SWF, I don't get any error's, but the following appears in my output panel;

quote:

TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::SimpleButton@edcb821 to Symbol3.

at flash.display::MovieClip/gotoAndPlay()
at FlashSwordUn_fla::MainTimeline/startButtonAnimation()
TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::SimpleButton@edcb701 to Symbol4.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FlashSwordUn_fla::MainTimeline/frame31()


I couldn't figure out why it is constantly doing this.




Steel Fire -> RE: Flash Q&A Thread 6 - We help! (2/3/2010 23:44:04)

Not trying to rush anyone, or anything, but just wondering. Is there a specific reason my question hasn't been answered? Or is it just because no one has had the time to answer it? Either way, I appreciate anyone who answers it.




EragonZZZZ -> RE: Flash Q&A Thread 6 - We help! (2/6/2010 21:18:25)

Oy.

Let me see your code where you first define 'startButton' and where you first set it equal to a value, please.




biG frend -> RE: Flash Q&A Thread 6 - We help! (2/8/2010 13:28:59)

Okay so I have a question. When drawing a shape with API you set a coordinate to start from say 50,50 then line to each point after that with the last point lineing back to the original point. If you modify say the top point on a triangle up by 10 (so -10 on the _y axis) it doesn't move the whole object up by 10 it just stretches the shape. However if you modify the starting points _x and _y it will just move the object by that much. How can I get the starting node to stretch to its shape?

Heres an example I made to clarify: http://megaswf.com/view/ada6971651592d8ab450a0563b0236af.html
Point 2 is the starting point. Each button should stretch the shape through a specific point. The last button should control node 2 by changing the starting position but that doesn't work clearly so how can I modify the starting positon.

tl;dr How can I get the starting node to act like the rest of the nodes?




EragonZZZZ -> RE: Flash Q&A Thread 6 - We help! (2/8/2010 16:54:55)

Please show code or it's rather hard to help xP




biG frend -> RE: Flash Q&A Thread 6 - We help! (2/8/2010 17:04:34)

Main frame has this

hex1 = -25;
hex2 = 0;
hex3 = 60;
hex4 = 60;
hex5 = 150;
hex52 = 150;

_root.createEmptyMovieClip("wall",1);
with (wall) {
	_x=hex5;
	_y=hex52;
lineStyle(10, 0x000000, 100);
beginFill(0x0000FF,50);
lineTo(50,_root.hex1);
lineTo(100,_root.hex2);
lineTo(85,_root.hex3);
lineTo(15,_root.hex4);
}



There are then five buttons all with similar code on

on(press) {;
_root.hex1 = _root.hex1 - 10; 

_root.createEmptyMovieClip("wall",1);
with (_root.wall) {
	_x=_root.hex5;
	_y=_root.hex52;
lineStyle(10, 0x000000, 100);
beginFill(0x0000FF,50);
lineTo(50,_root.hex1);
lineTo(100,_root.hex2);
lineTo(85,_root.hex3);
lineTo(15,_root.hex4);
}}


Only diffrences is that the sum at the top has a diffrent variable and a diffrent value in.




EragonZZZZ -> RE: Flash Q&A Thread 6 - We help! (2/9/2010 0:10:29)

Simplest solution - define the shape's border points as relative to a center point.

Here's a triangle, but you get the idea.

var center:Point = new Point (10, 10);
var offsets:Array = [new Point (0, -5), new Point (-5, 5), new Point (5, 5)];

function redraw():Void
{
     var mc:MovieClip = _root.createEmptyMovieClip("wall", 1);
     mc.lineStyle(0,0x000000);
     mc.moveTo(offsets[0].x, offsets[0].y);

     for(var i:Number = 0; i < offsets.length; i++)
     {
          mc.lineTo(offsets[i].x, offsets[i].y);
     }
     mc.lineTo(offsets[0].x, offsets[0].y);
}


and on each button (0 to 4)

on(press)
{
     _root.offsets[0] = new Point (_root.offsets[0].x + whatever, _root.offsets[0].y + whatever);
     _root.redraw();
}


Untested and it's been awhile since I've AS2-ed, but this (or something similar) should work.

Don't forget to
import flash.geom.Point;




razackie -> RE: Flash Q&A Thread 6 - We help! (2/11/2010 11:07:03)

Hmm, this may sound like a very nooby question, but how can I get a running animation to work when I use the arrow keys to move?




Sea -> RE: Flash Q&A Thread 6 - We help! (2/11/2010 13:00:26)

I had the same question a while ago!

double click the movieclip
name 1 frame "Idle" (non moving)
and then a new frame called "Moving" (make the walking animation in there)


then give the person you want to animate this code:

onClipEvent(load){
speed=10;
//change this to what you want
}
onClipEvent(enterFrame){
animation = "Idle"
if(Key.isDown(Key.RIGHT)){
_x+=speed;
animation = "Moving"
}
if(Key.isDown(Key.LEFT)){
_x-=speed;
animation = "Moving";
}
if(Key.isDown(Key.UP)){
_y-=speed;
animation = "Moving";
}
if(Key.isDown(Key.DOWN)){
_y+=speed;
animation = "Moving";
}
this.gotoAndPlay(animation);
//sorry, I forgot this part xD
}



By the way, if it is a sideview game (such as RoTRC) try frames called "Left" "Right" "Up" "Down" etc.




razackie -> RE: Flash Q&A Thread 6 - We help! (2/11/2010 13:36:33)

I know you can name a layer, but I didn't know you could name a frame. Can you tell me how to do that please?




Sea -> RE: Flash Q&A Thread 6 - We help! (2/11/2010 13:44:41)

sure (Btw, I forgot a part of the code xD I edited it, so you can redo it)

click the frame and press ctrl + f3

and type in the name in the "<frame label>" box




TreadLight -> RE: Flash Q&A Thread 6 - We help! (2/11/2010 13:47:10)

Select the frame, then go to your Properties panel, open the "Label" tab, and then type the frame name in the "Name" textbox.




Sea -> RE: Flash Q&A Thread 6 - We help! (2/11/2010 14:48:25)

M'Kay, I have a question

I have it when you click a button it will load the .swf of the name you typed in from your comp. How would I do this?

loadVariablesNum(_root.game);

or

getURL(root.game);

or

attachMovie(_root.game);


or what would I use to open a file from the users computer? (btw, I want this so people can play flash games offline)

fixed, still need to know how to export as .exe


I would also like to know if I can export a flash file as a .exe


got it xD




Vampire and Human -> RE: Flash Q&A Thread 6 - We help! (2/13/2010 13:11:45)

I question have a.

It bugs me constantly, but I have been unable to give my boring Dynamic Text Boxes the cool outlines they deserve. Rather than a boring white text or something, why not white with a black outline or something?

I've tried using the Glow filter... Ugh. Hate filters.

Is there some method/tool that can be used to do this?

I know for Static Texts I just expand fill and put it in a layer behind, but... there's got to be someway!

Anybody know? Or have a clever trick? I'd love to hear it ;)!


Thanks,
~VnH




Sea -> RE: Flash Q&A Thread 6 - We help! (2/13/2010 13:16:06)

I think glo is the only way...




Walt -> RE: Flash Q&A Thread 6 - We help! (2/13/2010 15:42:02)

I usually add glow and put the strength at the max percentage.




Alpha Atom -> RE: Flash Q&A Thread 6 - We help! (2/13/2010 15:55:11)

You could duplicate the object and then do a soften fill edges on it.




biG frend -> RE: Flash Q&A Thread 6 - We help! (2/14/2010 1:57:00)

Uuuh just do the exact thing you said you do for static text but do it through code. E.g when you set your dynamic textbox set another one behind it thats slightly bigger in size with a diffrent colour.




Silver Lion -> RE: Flash Q&A Thread 6 - We help! (2/14/2010 14:46:24)

Newbie question (xP): How do I import downloaded fonts to Flash CS4?

I have Windows XP.




biG frend -> RE: Flash Q&A Thread 6 - We help! (2/14/2010 15:31:38)

Same as with any other program, put them in your fonts folder. Be advised, unless you break the text into shape (ctrl+B twice) only people with those custom fonts will be able to see the custom fonts, for everyone else it will look like arial.




Page: <<   < prev  4 5 [6] 7 8   next >   >>

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition
0.15625