I wrote this repel function (below) for 2 movieclips and I call it from a timer instead of an enter_frame listener (speed), but it has the tendency to jerk and not be very smooth. How can I smooth the movements?
function repel(mover2, mover) {
var xdiff:Number = mover2.x - mover.x;
var ydiff:Number = mover2.y - mover.y;
var dist:Number = Math.sqrt(xdiff*xdiff + ydiff*ydiff);
I'm trying to build an application where the themouse cursor is used to "blow" a movieclip around. The way I'm doing this is by making the mouse cursor repel the movieclip. The problem is, I can only get it to work on the top and the left of the movieclip.
Here's my code:
function moveCloud(event:Event):void { var yChange:Number = Math.round(mouseY-cloud.y); var xChange:Number = Math.round(mouseX-cloud.x);
I'm a bit slow when it comes to grasping this whole concept.
I am after a script that allows me to use my mouse and repel objects within the canvas in Flash. For example, if I move my mouse close to a shape, say a circle, the shape would immediately dodge the mouse.
I'm trying to assign a custom property to an attached MC. In this case it's an ID number, but it's always undefined inside the onRelease function... What am I missing?
ActionScript Code: function blablaMethod(){_root.attachMovie("bla", "bla"+someIncrementingId, _root.getNextHighestDepth());var mcReference = _root["bla"+someIncrementingId];// I've also tried the following:var mcReference = _root.attachMovie("bla", "bla"+number, _root.getNextHighestDepth());
I want to call a function from another function's parameter but I don't know how and don't know if it is possible.I've considered this as a solution but it didn't worked.
having trouble with this .fla (attached) i have an object on the stage and I want to be able to make it repel the mouse cursor, similar to a magnet, so you cant get near it...
The MC is called BOX and this code I have on the frame...
var dist = 30; var objx = box._x += (box._width/2); var objy = box._y += (box._height/2);
I have a movieclip that I want to be resized when a button is clicked. I want the animation to be smooth as if it had weight though. I read the tutorial on this but I need something slightly different, I would rather it where I can just refer to a function that is set in another movieclip. That way I could easily refer to it again and just set the height, width, and if possible, x, and y.
And my second question, is how to keep the border of my movieclip that is going to be resized the same thickness. I want the inside to be resized but the sides to stay the same width but move to stay on the edge.
I have the following script in both frame 1 and 2 to let a movieclip move from right to left on the stage: Code: speed =-5 name._x += speed if (name._x<-500) { name._x = 250; } And the clip is indeed moving from right to left on the stage and when it reaches _x -550 it is going back to it's starting position _x 250 only the movement isn't smooth at all. What should I do to make the movement more smooth or should I use a completely different script?
I want to make a movieclip moves smoothly and when it changes the direction, it can turn smoothly but not a sudden turn, I try out the code below. and the truning is odd: this.rotation = (Math.atan2(targetY-this.y, targetX-this.x )/Math.PI)*180;
I have the following script in both frame 1 and 2 to let a movieclip move from right to left on the stage:
[Code]...
And the clip is indeed moving from right to left on the stage and when it reaches _x -550 it is going back to it's starting position _x 250 only the movement isn't smooth at all. What should I do to make the movement more smooth or should I use a completely different script?
Can you please tell me why this isn't working? It takes me 10 minutes to test the movie every time and it's taking me forever to fix things. Do I have to do something else with the variable names I'm using or something?
I have movieclip which contains child movieclip. when child movie clip finish to play i want to run a function in a parent movieclip. so I made a custom event dispatcher in the first frame of the child movieclip:
I have a document class called Main.as In the class constructor I have the following listener:
enter code here var listeningFORModeChangeToStudent:Sprite = new Sprite; listeningFORModeChangeToStudent.addEventListener(TellAllModeChangeToStudent.STUDENT,exp); addChild(listeningFORModeChangeToStudent);
[code]....
In a third class I make a call to the despatcher in the previous class:
enter code here var ThisTellAllModeChangeToStudent:TellAllModeChangeToStudent = new TellAllModeChangeToStudent; ThisTellAllModeChangeToStudent.tellAllModeChangeToStudent();
I have trace statements in eveything and from this I know the despatcher in TellAllModeChangeToStudent is being called.The problem is that the listener in the main.as is not calling the function exp.I cant see why and I dont know how to check if the listener is actually seeing the dispatch event?
I am new to AS3, as well as Flash in general, so forgive me if this seems highly elementary. All I am trying to do is create a custom class that extends the MovieClip class and contains a custom property of "marker". I want to be able to use and change the value of this custom property on the timeline for an instance of this class and have it behave just like any other (Ex: this.x ==> this.marker).
i have a set of "if conditionals" that should always be together,what i want to do is to put these conditionals in a function... then call the function once needed. i want to call this function once the flash starts playing + when i click on any of the 3 buttons.
here is the code so far:
ActionScript Code: var btn1:Boolean=true; var btn2:Boolean; var btn3:Boolean;
[code]....
the problem is button1 should have no eventlistener once the movie starts playing, but it has all listeners... so how can i make AS reads BtnStatus function once it starts loading
I have a game and i use function gotoAndStop in actionscript to play frame "moving" in my character game.And in this frame have movieclip. How can i detect when movieclip inside frame "moving" end ?
The fact is that the "dispatchEvent" method must be placed into the code or timeline where the "event" happens, then it can be trigged and the function associated with the event will be invoked. Ok, it is understood. Nevertheless, my question is: what's the point to create an event to trigger the a function call, if I can simply call the function instead directly???
Code: package{ import flash.events.Event; public class CustomEvent extends Event{ public static const ONSOMETHING:String = "onSomething"; public function CustomEvent(type:String){ super(type); [Code] .....
If I can do simply: Code: DoIt(); function DoIt(){ trace ("Done!"); } What I mean is that custom events doesn't look like as REAL events for me, but more like a delegate way to call a function. Differently from Flash native events that are controlled by an internal engine that keep checking if the event happened, in the custom events they must triggered 'manually', and it seems to lose the event main characteristic.
I am trying to sort big array using actionscript 3. The problem is that i have to use custom sorting function which is painfully slow and leads to flash plugin crash.
Below is a sample code for custom function used to sort array by length of its members:
I want to be able to make my own math-functions, so that I don't have to write the same trivial functions in all my classes. I would like to import a class called something like MathExtended, and then use functions like this:
MathExtended.sign(x)
I have made an example that tries to import a custom class like that:
Code: /* This is the main script which my fla. runs. */
ActionScript Code: private function drawMap(tile1:DisplayObject, tile2:DisplayObject):void { var _tile1 = tile1;
[Code].....
The idea behind this is to store custom sprites in an array and then feed the array to the drawMap function, which would use the sprites from the array to draw a map.
I'm trying to fade a piece of text that I'm loading via XML in and out (as well as moving it's location in and out).* The fade out part is working fine, and as long as I have a _alpha.100 command where I'm currently calling my "slidein" function (really the fade in function) it works fine. No idea why! I've tried about 100 different placements and I'm stumped.. It's very perplexing.*
ActionScript Code: function loadXML(loaded) { if (loaded) {
I'm trying to create a custom sort function. This function will sort the pegs in a certain row by their row number (0: lowest -- numRows - 1: highest)For context, here is Adobe's description for the Array sort method: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/Array.html#sort()
My array-building function:
Code: public function getPegsInRow(row:int):Array { var pegRowArray:Array = new Array() for(var i:int = 0; i < pegArray.length; i++)
[code]....
Unfortunately, the array does not get sorted correctly.
I've been trying to find an easing generator that supports bounce but have found none. I want to create an easing function that starts as a easeInSine (or quad) and ends as en easeOutBounce (imagine dropping an object on the ground). I've already thought of splitting up the tween in two. Just realised that the easeOutBounce actually starts a little bit like easeInSine but I would like to enhance that part to make a steeper curve.
I created a function with input variables, so I don't have to repeat this function X amount of times. But within the function is a TweenLite call and that call has an onComplete. This onComplete somehow doesn't understand what the variables filled in in my function represent.
EDIT:I think I can make this a bit more clear when I explain what this is supposed to do:This menu can reach it's end via different routes. So the user can choose Path A or B, but what I'm trying to set up here is. If A is on stage, A should be removed first before B is placed and vice versa. And because this happens for about 4-5 times I wanted to shorten the code by using something like this.
I'm building a flash app that pulls images from flickr and removes the white background. I'm doing this using threshold and I get a really ragged outcome. Is there any way to get a better and smoother color key?