How Added EASING Effect? In This
hello, i view the nice tutorial of the simple scroller in kirupa:
http://www.kirupa.com/developer/flash8/scrollbar.htm
now, how can added the EASING efect to this scroller???
the code in:
http://www.kirupa.com/developer/flash8/scrollbar3.htm
somebody can help me!
Pamela.
KirupaForum > Flash > Flash 8 (and earlier)
Posted on: 02-21-2006, 06:16 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
How To Transistion Effect Added?
This is my coding, how to create the one picture to another picture transistion effect added?
imgbtn_center.onRelease = function() {
infoField._visible = true;
startLoading("pic_01.jpg");
};
imgbtn_up.onRelease = function() {
infoField._visible = true;
startLoading("pic_02.jpg");
};
imgbtn_down.onRelease = function() {
infoField._visible = true;
startLoading("pic_03.jpg");
};
imgbtn_left.onRelease = function() {
infoField._visible = true;
startLoading("pic_04.jpg");
};
imgbtn_right.onRelease = function() {
infoField._visible = true;
startLoading("pic_01.jpg");
};
function startLoading(whichImage) {
loadMovie(whichImage, "imageLoader");
_root.onEnterFrame = function() {
infoLoaded = imageLoader.getBytesLoaded();
infoTotal = imageLoader.getBytesTotal();
percentage = Math.floor(infoLoaded/infoTotal*100);
infoField.text = percentage+"%";
if (percentage>=100) {
delete this.onEnterFrame;
infoField._visible = false;
}
};
}
New Layer Being Created When Timeline Effect Added
I am working on a Flash file in which I am adding a Timeline Effect (5 frame fade out). Recently, instead of the transition being applied to the layer, in the frame length specified, Flash adds another layer with the standard 30 frames and it deletes the content from the 5 frames where I'm trying to add the fade out. It doesn't always do this. I had already successfully created a couple of fade-ins at the beginning of the timeline, but once it starts adding and deleting this stuff, it never goes back to normal. On the layer in question, I have a keyframe with a graphic, the graphic is stationary for 20 frames, then I inserted another keyframe and tried to apply the Timeline Effect beginning there. Help!!
Easing Effect
hi,
well i have seen over internet an example of what i want, but i dont remember where and i dont find it.
thats why i ask for your help.
well i want to make an effect, where i have a grid of elements for exameple 5 x 5 squares (25 in total) and where i pass the mouse i have an effect like the mac menu effect.
hope you can help me
thanks
Easing Effect Problem
Hi there, I doing an easing effect to scale a movieclip from the current size to a targeted size say 50pixel width. The problem is the number is always exceed the targeted size when it's moving, therefore i cant delete my onEnterFrame. anybody out there know the way to solve please let me know.
function moveMe(){
var boxHeight:Number=box_mc._height;
var boxWidth:Number=box_mc._width;
var speed:Number=5;
box_mc._width+=(boxTargetWidth-boxWidth)/speed;
boxWidth=box_mc._width;
trace(boxWidth);
if (boxWidth==boxTargetWidth){
delete box_mc.onEnterFrame;
}
}
thanks
ks
Easing Scroll Bar / Effect
i've noticed some websites' scroller has an easing effect, which is quite nice.
it makes the things "smoother"...
i would like to learn how to do it... or maybe some1 can send me the .fla???
Cancel An Easing Effect
Hello people !!!
I was trying to make a cartoon men that follow the mouse (as a mouse trailer). I did it and working like I want. When the cartoon are so far from the mouse he runing faster, but when are close to the mouse, he walk.
All this working right, as you can see here, but when the cartoon stop walking he look flying to the last _x position that the easing effect calculate.
Do you figure out a way to cancel the easing, to add to my AS that stop the walking effect. I want to stop the easing when the cartoon stop walking.
Thank you for any help !!!
Easing Navigation Effect.. Help
cover.onEnterFrame = function ()
{
if (this.hitTest(_root._xmouse, _root._ymouse) == false)
{
destY = 91;
} // end if
};
gal1_btn.onRollOver = function()
{
destY = this._y;
};
gal2_btn.onRollOver = function()
{
destY = this._y;
};
gal3_btn.onRollOver = function()
{
destY = this._y;
};
gal4_btn.onRollOver = function()
{
destY = this._y;
};
gal5_btn.onRollOver = function()
{
destY = this._y;
};
gal6_btn.onRollOver = function()
{
destY = this._y;
};
gal7_btn.onRollOver = function()
{
destY = this._y;
};
arrow_mc.onEnterFrame = function ()
{
this._y = this._y + (destY - this._y) / 10;
};
ok everything is ok. arrow eases and goes where you rolledover. once you leave the hitest it goes back to 91. the original spot. But I want it so that when you click on a button. the arrow now eases back towards the section you just clicked making it the default.
see what I mean? i've tried but im not any good.
thanks.
As2.0 Scrollbar With Easing Effect
this is probably a cliché problem, but how do you work out a scrollbar with ease ?
I know how to use easing pretty well on anything else, I just can't get it to work on my scrollbar
any tips ?
cheers!
X&y Easing / Mapping Effect
Hi,
I'm looking for either a flash component or AS3 that emulates this user experience:
http://www.phcinque.it/fondo.swf
Can anyone help me out?
Thanks!
How Do You Create An Easing Out Effect With Actionscript
I am creating a dynamic nav bar for a site and would like to create the ease out effect that you would normally use motion tweening for, with actionscript instead. I have gotten it work somewhat but my problem is that I need my object to reach a certain destination and I can't figure out how to gradually decrease my speed over the length of a distance. Right now my object is not reaching it's end point ...something to do with speed vs. friction, etc. Sorry I don't know physics well. Here is the current code I have placed in my moving object. Can you help?
onClipEvent(load){
currentSpeed = 45;
friction = 3.25;
startPoint = 0;
endPoint = 500;
this._x = startPoint;
}
onClipEvent(enterFrame){
if(currentSpeed > 0){
currentspeed -= friction;
this._x += currentSpeed;
}
}
Easing Of Scrolling Landscape - 3D Effect
Hi all!
I have this script on each of 3 movieclips (background, trees and gras). The values of some variables of the script below (on the other two movieclips) are a bit different of course, but further they're the same.
I would like to extend this script a bit: when the mouse pointer is in the _ymouse area from 0-50 the landscape scrolls fine. But when the mouse pointer is below 50 px, the scrolling SUDDENLY stops of course. This isn't a nice sight. So I'm trying to decellerate the scrolling (to zero) of the landscape when the user moves the mouse pointer from the 'hit area' to the rest of the stage (y below 50 px).
Anyone know how the code should be modified to achive this effect?
Many thanks!!
The code of 1 of 3 images:
onClipEvent (enterFrame) {
if (_ymouse<50) {
if (_root.mainVar == 0) {
homeX = (-_root._xmouse)+700;
} else {
homeX = (-_root.mainVar)+700;
}
thisX = _x;
diffX = homeX-thisX;
if (_root.mainVar == 0) {
moveX = diffX/30;
} else {
moveX = diffX/5;
}
_x = thisX+moveX;
}
}
Help With An Expanding And Easing 'rectacle' Effect...
Hi guys,
Before I overcook this spaghetti code, I thought I would ask here if anyone had a simpler way of gaining the effect I'm looking for. I'm designing a shooting game, and I want the 'rectacle' to expand and contract with the movement of the mouse so as to simulate aiming difficulty. The effect I have right now has several problems, but the first one is that the animation is jumpy and moves much too fast.. but for the life of me I cannot see how to approach the problem any other way that the way I've written it. Could someone could take a look at what I have so far, and at least tell me if I'm going in the wrong direction?
Thanks in advance...
david
Code:
stage.frameRate = 32;
var shortLine:Sprite = new Sprite();
var crossRadiusOriginal:int = 5;
var crossRadius:int = crossRadiusOriginal;
var crossLength:int = 20;
var mouseMovePunishFactor:int = 2;
var mousePosThenX = 0;
var mousePosThenY = 0;
var mousePosNowX = 0;
var mousePosNowY = 0;
var mousePosChangeX = 0;
var mousePosChangeY = 0;
var mousePosChangeXAndY = 0;
stage.addEventListener(MouseEvent.MOUSE_MOVE, drawCrosshairs);
function drawCrosshairs(MouseEvent:Event):void
{
Mouse.hide();
mousePosChangeX = Math.abs(mouseX - mousePosThenX);
mousePosChangeY = Math.abs(mouseY - mousePosThenY);
mousePosChangeXAndY = (mousePosChangeX+1)+(mousePosChangeY+1);
mousePosThenX = mouseX;
mousePosThenY = mouseY;
crossRadius += mousePosChangeXAndY * mouseMovePunishFactor;
this.addChild(shortLine);
shortLine.graphics.clear();
shortLine.graphics.lineStyle(2, 0x00AA00, .80);
shortLine.graphics.moveTo(mouseX - crossRadius, mouseY - crossRadius);
shortLine.graphics.lineTo(mouseX - (crossLength + crossRadius), mouseY - (crossLength + crossRadius));
shortLine.graphics.moveTo(mouseX + crossRadius, mouseY + crossRadius);
shortLine.graphics.lineTo(mouseX + (crossLength + crossRadius), mouseY + (crossLength + crossRadius));
shortLine.graphics.moveTo(mouseX - crossRadius, mouseY + crossRadius);
shortLine.graphics.lineTo(mouseX - (crossLength + crossRadius), mouseY + (crossLength + crossRadius));
shortLine.graphics.moveTo(mouseX + crossRadius, mouseY - crossRadius);
shortLine.graphics.lineTo(mouseX + (crossLength + crossRadius), mouseY - (crossLength + crossRadius));
crossRadius = crossRadiusOriginal;
}
Increasing Easing Effect Beyond Standards?
Greetings all!
Does any of you guys know how I can increase the easing effect for a shape or motion tween beyond the limit in the menu?
It won't go beyond the standard +100 or -100.. but I've seen plenty examples around the net where the easing effect is way more exagerated than the puny +/- 100 you can do via the menu..
So, how do I do this? Will it require that I do the entire movement by actionscripting? Or is there some other way (an easy one) to accomplish this?
hmmm...
Simple Easing Effect Not Working, And I Don't Know Why
Here's my situation. I have a movie clip called mainClip. Within it is another movie clip called subClip. I am moving the mainClip along the y axis; when it reaches a certain point, then the subClip moves along the x axis.
Here's the basic code:
ActionScript Code:
myButton.onRelease = function() { onEnterFrame = function () { mainClip._y += 10; if (mainClip._y>=100) { mainClip._y = 100; mainClip.subClip._x += 100; if (mainClip.subClip._x>=100) { mainClip.subClip._x = 100; } } };};
But the motions are too abrupt for my taste. So, I'm using a simple easing in script:
ActionScript Code:
endY = 100;endX = 100;speed = 5;myButton.onRelease = function() { onEnterFrame = function () { mainClip._y += (endY-mainClip._y)/speed; if (mainClip._y>=endY) { mainClip._y = endY; mainClip.subClip._x += (endX-mainClip.subClip._x)/speed; if (mainClip.subClip._x>=endX) { mainClip.subClip._x = endX; } } };};
The problem is, the mainClip moves just fine, but the subClip won't move at all. Anyone have any ideas as to why the second script won't work?
Easing Effect In Flash MX2004
I am using flash mx 2004 . the easing provided this version is from 100 to -100 but this is't enough. The effcet is very week nad hardly get noticed any other way?
Easing Rollover Effect For Menu
Hi. I'm not all that great with actionscript, so I'll just ask all ya' kirupians.
For my menu, I have a white image that I want to ease into the button on rollover, so it goes from the bottom, where it's not seen, and it eases to fill the button, then the same ease out when the mouse is off of the button. I have no idea how to code this, and I don't want to make movie clips, to keep the file size down.
Help would be greatly appreciated. Thanks.
GBP
Increasing Easing Effect Beyond Standards?
Greetings all!
Does any of you guys know how I can increase the easing effect for a shape or motion tween beyond the limit in the menu?
It won't go beyond the standard +100 or -100.. but I've seen plenty examples around the net where the easing effect is way more exagerated than the puny +/- 100 you can do via the menu..
So, how do I do this? Will it require that I do the entire movement by actionscripting? Or is there some other way (an easy one) to accomplish this?
hmmm...
Dynamic Text With Easing Effect?
Hello there,
can anybody show me how to make scroller with easing effect and dynamicly loaded text. I've tried to do it maybe 2-3 days, but ...nothing happens. If anybody have idea, or ready to use code and there is no problem to post it here... please, post it.
10x a lot
Changing Y Position Of A Movie Clip With An Easing Effect
Hi everybody
I have 6 buttons which are supposed to control the movement of a MC; on each button I set a variable for the y position, ie:
on (press) {
firstvar = -427;
}
My MC has 3 frames, and that´s how the code looks like on each:
1) fri = .1;
2) dify = _root.firstvar-fou._y;
speedy = dify*fri;
fou._y = fou._y + (speedy*1,5);
3) call ("2");
The problem is it just don´t work at all. Is there any way to solve it, or can this be achieved some other way?
Thanks!
Short Script Notation Multiple Movieclips With Same Effect/easing
Hello,
I'm having a piece of actionscript written for 63 of the same movieclips. All of them start at _alpha = 0 and then one at a time fade in on screen. I've made myself a working actionscript but it's waaaaaay to long.
Now I'm looking for a short script notation for the following code:
PHP Code:
overlap.ovl01._alpha = 0;
overlap.ovl02._alpha = 0;
overlap.ovl03._alpha = 0;
...
overlap.ovl60._alpha = 0;
overlap.ovl61._alpha = 0;
overlap.ovl62._alpha = 0;
// Overlap A + B
overlap.alphaTo(100, 1, "lineair", 2.2)
overlap.ovl01.alphaTo(100, 1, "lineair", 2.2)
overlap.ovl02.alphaTo(100, 1, "lineair", 2.3)
...
overlap.ovl61.alphaTo(100, 1, "lineair", 9.5)
overlap.ovl62.alphaTo(100, 1, "lineair", 9.6)
overlap.ovl63.alphaTo(100, 1, "lineair", 9.7)
I found a script but I can't get it to work.
PHP Code:
//use a for loop to reduce repetition of the code
for(i=1;i<63;i++){
theOverlap=_root.overlap["ovl"+i];
//this variable stores what number button it is
theOverlap.thisNum=i;
theOverlap.onEnterFrame=function() {
this._alpha= 0;
}
}
Can someone help me out?
thanx
I Added The Url
So that you can see what I did wrong????
I hope!
http://www.angelsonmyside.com/eaglem...mac_flash.html
(((Angel Hugs)))
Donna
Very tired in Brooklyn!
.0 Added To A Number?
Hello,
I need to add a ".0" to the end of a number if there is not a fractional portion.
Example:
If I get a number like 12, I need to return 12.0
And if I get a number like12.5, I need to do nothing...
I was looking into using parseFloat(); but, I'm getting hung up on how to look for a fractional portion. and if i need to, how to add .0
Does anyone know how this can be done?
Can Alt Tags Be Added To Swf's
Can anyone tell me if you can add an alt tag in html to the embedded flash swf, In order to enhance the page for search engines.
please let me know
Evet.ADDED
I feel very strange about how the event added are dispatched. i.e.
mc.addEventListener(Event.ADDED,onAdded)
and the function onAdded is run when:
stage.addChild(mc)
which is as expected
but i also found out that it also run when:
(under the class of mc)
addChild(otherMC)
which is when anotherMC is added to mc
and most interestingly, when:
mc.play()
and it seems whenever it reaches the first frame, the onAdded run again.
[as2]last Added Thumbs
Hi i want to add on my site sth like - last added pictures. Ive got a folder with some jpg's - normal size called 1.jpg 2.jpg etc. and thumbs - 1_th.jpg 2_th.jpg etc. I want to show only last added thumbs, not original size. I dont want to link thumbs with normal sized pics or sth. This should be in one column - last, 5 added thumbs. I know that I should use createEmptyMovieclip to create 5 container mc's. And next I should load last added thumbs. but now ive got a problem. I really dont know how to do that. Because it must depend on date of adding the file. Im also using a gallery based on xml. here its his structure:
Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>pics/1.jpg</image>
<thumbnail>pics/1_th.jpg</thumbnail>
<title>Obrazek nr 1</title>
<caption>Opis</caption>
<url>pics/big_1.jpg</url>
</pic>
<pic>
<image>pics/2.jpg</image>
<thumbnail>pics/2_th.jpg</thumbnail>
<title>Obrazek nr 2</title>
<caption>Opis</caption>
<url>pics/big_2.jpg</url>
</pic>
<pic>
<image>pics/3.jpg</image>
<thumbnail>pics/1_th.jpg</thumbnail>
<title>Obrazek nr 3</title>
<caption>Opis</caption>
<url>pics/big_3.jpg</url>
</pic>
<pic>
<image>pics/4.jpg</image>
<thumbnail>pics/2_th.jpg</thumbnail>
<title>Obrazek nr 4</title>
<caption>Opis</caption>
<url>pics/big_4.jpg</url>
</pic>
</images>
maybe i could use this file to solve my problem? for example script will read from file last 5 <thumbnail></thumbnail>? but im not good at as so maybe you could help me?
Additional Y Value Added
When I press a button, I am trying to say if the ball is in a certain position then move it to another position... if it is in a different position then move it a different amount x and/or y... it almost work except that in the last case it finishes at 423.85... therefore should move 0 along x... actually it moves about +30 along y ?!?
button.onPress=function(){
if (ball._x = 388.85) {
ball._x += 35;
ball._y += 94;
} else if (ball._x = 98.85) {
ball._x -=325;
} else if (ball._x = 423.85) {
ball._x -=0;
}
}
Easing Out AND Easing In Using Math?
Hello,
I'm familiar with how to ease something in using motion math. Easing out would not be that bad either. But how would I script something easing in half way, then easing out the second half? It would start slow, gradually move faster, then slow to a stop at the end. - almost like a sine wave I guess?
Any thoughts? I appreciate any feedback.
Video Added To Movie?
I am not sure if it can be done or how it is done, but I want to add video clips to my swish movie. I am going to burn it on a CD and use it that way, as a presentation. can any one give me some idea. It seems to me that it can be done. I might be wrong.
Keith
HTML <a> Added Onto A Querstring
I'm sure this has been asked before but I couldn't find it. I'm loading HTML into my movie to create a dynamic links set. It's drawing data from a database, and has been devised in such a way that I am loading the data into the movie (MX) by attaching it to the end of the filename when in the page:
Code:
movie.swf?var1=value1&var2=value2
But this fails when applying certain HTML tags. It works fine with bold, italic etc, but as soon as I try an anchor, it fails. any ideas why? By means of an example:
Code:
movie.swf?linkset1=<a href="page.asp">Link</a> | <a href="page2.asp">Link</a>&linkset2=<a href="....
I've tried placing quotes around various parts but to no avail. I know you'll tell me it's a poor way to send variables into my movie because the movie won't be cached, but the file size is 980bytes, so smaller than the equivolent javaScript code I *cooud* be using
Many thanks folks!
128k Added To All My Swf Files?
Day one of building the site. All my swf files are low memory. Everything is working great. Day two of working. I test a swf and the file size is high. Too high. I take everything off the page and test that page. It gave me 128k for a blank page. I work with a couple graphics that are low in k yesterday try testing them today and 128k was added to swf size. I am hoping someone can tell me why 128k is being added to all my swf files.
Need the help!!!!!!,
noguns
Already Added Sound, How Do I Mute
Hi peoples,
once again, i have soo many questions, i was wondering if anyone could help me out, how can i make a mute button i already have the music it loads at the begining of the presentation and i have a button on every scene which i want to convert so when clicked on it mutes the sound.
Ok thanx to all
it really appreciated,
santiago
V-0.fla Added To Filename During Save As?
Strange thing started happening to me yesterday. Whenever I did a "Save As..." with a FLA, Flash would add an invisible " v-0" to the end of the filename, before the extension.
Example:
If my filename was "products.fla" and I did a Save As, the filename would turn into "products v-0.fla". The thing was that I didn't catch it right away, because in the Save As dialog the filename looks like "products" - there is no extension.
If I place my cursor at the end of the field where the file name is, the text cursor (blinking I-bar) is several characters away from the end of the original filename. It's just like there are several invisible characters appended to the filename. If I drag left to select the invisible charcters, it only highlights one space after the original filename. If I delete the highlighted space, the added characters do not show up in the filename of the newly saved file.
This is mighty strange. Has anyone else had any similar experiences? I would love to hear about them and if any cause/solution was determined.
Flash MX, Mac OSX 10.2.6
Thanks.
Dynamic Tex Box Added, Something Disapears
When I add a dynamic text box to my .fla and publish or test it, something disapears or the mc stop function as btns. What the heck is going on. The text block contains a font that is from a shared Library if that means anything.
Thanks
Removing And Added Movieclip
i have this function that everytime i click the screen a box appears.
function box () {
_root.onMouseDown = function(){
movie = _root.attachMovie("mcBox", "mcBox", _root.getNextHighestDepth());
movie._x = _xmouse;
movie._y = _ymouse;
}
}
how can i make it so i only have one box on the screen at a time
like this
if (there is a box on the screen) {
function = false
} else { continue function; }
i cant figure out how to do that in actionscript.
[F8] Added Stop(); But It Keeps Looping
Link to the site:
http://www.abccreativegroup.com/optimized/main.html
Here are the files:
http://www.abccreativegroup.com/optimized.zip
Could someone go through the code on the main.fla file and tell me what piece of code is causing the file to keep looping over and over again?
Thanks!
-Mannycreative
Can’t Remove Added MCs From Array?
Trying to add x3 items (MCs) to the stage using an array, but once they are added I can’t remove them.
I’ve uploaded my .FLA HERE (for a limited time as this is my Uni project)
Also posted the full code below…
MANY THANKS!
Quote:
//Initiate variables
var currentWallD1:int = 0;
var lastWallD1:int = 0;
var currentWallD2:int = 0;
var lastWallD2:int = 0;
var itemNo:int = 0;
var score:int = 0;
var amount:int = 0;
var clickX:Number = 0;
var clickY:Number = 0;
var startX:int = 0;
var startY:int = 0;
var lPercent:Number = 2;
var initPos:int;
var endPos:int;
var contPos:int;
var perPos:int;
var cPointX:int = 0;
var cPointY:int = 0;
var goThrow:Boolean = false;
var oldladyspeed:Number = 6;
var left:Number = 0;
var right:Number = stage.stageWidth;
var item:Array = new Array();
var lastItemThrown = 1;
for (var b = 1; b <=3; b++) {
item[b] = new breadClass();
stage.addChild(item[b]);
item[b].alpha = 0;
}
// Movment of avatar with arrow keys
stage.addEventListener(KeyboardEvent.KEY_DOWN, downHandler);
function downHandler(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.LEFT) {
oldlady.gotoAndPlay(14);
oldlady.x -= oldladyspeed;
}
if(event.keyCode == Keyboard.RIGHT) {
oldlady.gotoAndPlay(11);
oldlady.x += oldladyspeed;
}
// if avatar goes OFF screen left, comes ON screen right & visa-versa
if (oldlady.x - oldlady.width / 2 > right) {
oldlady.x = left - oldlady.width / 2;
} else if (oldlady.x + oldlady.width / 2 < left) {
oldlady.x = right + oldlady.width / 2;
}
}
// Because you didn't declare dx/dy as integers in your code it was causing some bizzarre
// problems when hitting a wall! I've also changed this so that dx and dy are never
// initiated as zero, which removes a lot of code later on.
// Duck 01 speeds & random direction
var dx:int=-2-Math.floor(Math.random()*1);
var dy:int=-2-Math.floor(Math.random()*1);
// Duck 02 speeds & random direction
var hx:int=-3-Math.floor(Math.random()*6);
var hy:int=-3-Math.floor(Math.random()*6);
// Initiate event listeners
addEventListener(Event.ENTER_FRAME, gameLoop);
targarea.addEventListener(MouseEvent.CLICK, clickHandler);
// Start Timer
var timer:Timer = new Timer(1000,250);
timer.addEventListener(TimerEvent.TIMER, countDown);;
timer.start();
// Move Sprites
function gameLoop(event:Event):void {
moveBread();
moveDuck1();
moveDuck2();
}
// Crosshair custom cursor on mouseOver pond
targarea.addEventListener(MouseEvent.MOUSE_OVER, TargMouseOver);
targarea.addEventListener(MouseEvent.MOUSE_OUT,Tar gMouseOut);
function TargMouseOver(e:MouseEvent){
addChild(tcursor_mc);
tcursor_mc.startDrag(true);
Mouse.hide();
}
function TargMouseOut(e:MouseEvent){
removeChild(tcursor_mc);
Mouse.show();
}
// Moves Bread along Bezier Curve
function moveBread():void {
if (goThrow) {
if (lPercent <= 1) {
item[itemNo].x = setBezierPos(startX, clickX, cPointX, lPercent);
item[itemNo].y = setBezierPos(startY, clickY, cPointY, lPercent);
lPercent = lPercent + 0.05;
}
else {
goThrow = false;
}
}
// hitTest Duck1 with Bread + 50 points
for (var n:int = 1; n <= 3; n++){
if (box1.hitTestObject(item[n])) {
stage.removeChild(item[n]);
updateScore(50);
}
if (box2.hitTestObject(item[n])) {
stage.removeChild(item[n]);
updateScore(-50);
}
}
}
function moveDuck1():void {
//Move the duck
box1.x += dx;
box1.y += dy;
// Test for any collisions and change the ducks direction if there are any
if (box1.hitTestObject(wall1)) {
currentWallD1 = 1;
}
if (box1.hitTestObject(wall2)) {
currentWallD1 = 2;
}
if (box1.hitTestObject(wall3)) {
currentWallD1 = 3;
}
if (box1.hitTestObject(wall4)) {
currentWallD1 = 4;
}
if (currentWallD1 != lastWallD1) {
dx=(3+Math.floor(Math.random()*6))*dx/Math.abs(dx);
dy=(3+Math.floor(Math.random()*6))*dy/Math.abs(dy);
switch (currentWallD1) {
case 1:
dx=dx*-1;
box1.gotoAndStop(1);
break;
case 2:
dy=dy*-1;
break;
case 3:
dy=dy*-1;
break;
case 4:
dx=dx*-1;
box1.gotoAndStop(2);
break;
}
lastWallD1 = currentWallD1;
}
}
function moveDuck2():void {
//Move the duck
box2.x += hx;
box2.y += hy;
// Test for any collisions and change the ducks direction if there are any
if (box2.hitTestObject(wall1)) {
currentWallD2 = 1;
}
if (box2.hitTestObject(wall2)) {
currentWallD2 = 2;
}
if (box2.hitTestObject(wall3)) {
currentWallD2 = 3;
}
if (box2.hitTestObject(wall4)) {
currentWallD2 = 4;
}
if (currentWallD2 != lastWallD2) {
hx=(3+Math.floor(Math.random()*6))*hx/Math.abs(hx);
hy=(3+Math.floor(Math.random()*6))*hy/Math.abs(hy);
switch (currentWallD2) {
case 1:
hx=hx*-1;
box2.gotoAndStop(1);
break;
case 2:
hy=hy*-1;
break;
case 3:
hy=hy*-1;
break;
case 4:
hx=hx*-1;
box2.gotoAndStop(2);
break;
}
lastWallD2 = currentWallD2;
}
}
function updateScore(amount):void {
score += amount;
theScore.text = String(score);
}
function countDown(event:TimerEvent):void {
myText.text = String(250 - timer.currentCount);
}
function clickHandler(event:MouseEvent):void {
if (!goThrow) {
startX = oldlady.x + 100;
startY = oldlady.y + 50;
itemNo ++;
if (itemNo > 3) {
itemNo = 1;
}
item[itemNo].alpha = 1;
oldlady.gotoAndPlay(2);
clickX = event.stageX;
clickY = event.stageY;
lPercent = 0;
cPointY = startY -150;
cPointX = startX + ((clickX - startX)/3);
//trace(startX + " " + cPointX + " " + clickX);
goThrow = true;
}
}
function setBezierPos(initPos, EndPos, ContPos, perPos):Number {
return initPos*(1-perPos)*(1-perPos)+2*ContPos*(1-perPos)*perPos+EndPos*perPos*perPos;
}
getting this error...
"ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
at flash.display:: DisplayObjectContainer/removeChild()
at GAME_3_fla::MainTimeline/moveBread()
at GAME_3_fla::MainTimeline/gameLoop()"
... as far as I can see it IS a a child of the caller!
ADDED Event Problem
hey all,
first time post would appreciate any help
im loading images dynamically using xml and using using a listener to see when the object has been ADDED to the timeline and then organizing using image width im using added because im not sure of any other way that works
but this re organizes the images in an order that i dont prefer the xml docs has them listed as image1-image5 but when the imover function reorganizes them they end up showing up as 5,3,1,4,2 .
the flash help says that the item listening isnt always that which is used and that I should use the "currentTarget property to access the object in the display list that is currently processing the event." but im not sure how to do this.
heres the code any suggestions on how i can get this to work properly?
thanx all
CODE:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var inTween:Tween;
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var container:MovieClip= new MovieClip();
var xmlLoader:URLLoader=new URLLoader();
var iShift:Number=25;
container=new MovieClip();
container.name="iHolder";
xmlLoader.load(new URLRequest("data/images.xml"));
xmlLoader.addEventListener(Event.COMPLETE,xmlLoade d);
function xmlLoaded(event:Event):void {
xml=XML(event.target.data);
xmlList=xml.children();
for (var i:int; i<xmlList.length(); i++) {
imageLoader=new Loader();
imageLoader.name="image"+(i+1);
imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
container.addChild(imageLoader);
imageLoader.addEventListener(Event.ADDED,iMover);
}
}
function iMover(event:Event):void {
inTween=new Tween(event.target,"alpha",None.easeNone,0,1,3)
var iBuf:Number=25;
event.target.x=iShift;
event.target.y=(stage.stageHeight/2)-(event.target.height/2);
iShift+=event.target.width+iBuf;
trace(event.target.name);
container.x=(stage.stageWidth/2)-(container.width/2);
}
addChild(container);
Checking To See If Child Has Been Added
i am using container.addChild(myswf.swf) to load in a swf, but then when the user navigates away from the page i need the container to be removed, which i believe is container.removeChild(myswf.swf)
however if the container hasnt been loaded before the user clicks on the page then errors occur.
i therefore think i need an if/else statement to check whether it has been loaded or not, but not sure how to go do this, or if this is the best method.
thanks
Dan
Event For Added Child?
Is there an event that is triggered when a child is added to a sprite?
To be clear, when I call:
ActionScript Code:
spriteA.addChild(spriteB)
I want spriteA to be listening for this, and run a method to accommodate having a new child. What should I do?
Problem Removing Added MC...
I'm adding a few MC to my stage based on an array containing MCs.
However when I call to remove a MC an error is thrown some why...
Code:
var prev:Object = count_history[count_history.length-2];
trace("prev="+prev); // I get traced: "[Object blank]" when "blank" is the MCs name.
Tweener.addTween(prev,{alpha:0, time:4, onComplete:removeMe(prev)});
function removeMe(id:Object):void {
trace("removed: "+id); // So does this: "[Object blank]" when "blank" is the MCs name.
removeChild(id.target);
}
This is the error I'm getting:
Error #2007: Parameter child must be non-null.
at flash.display:isplayObjectContainer/removeChild()
Any ideas?
Can’t Remove Added MCs From Array?
Trying to add x3 items (MCs) to the stage using an array, but once they are added I can’t remove them.
I’ve uploaded my .FLA HERE (for a limited time as this is my Uni project)
Also posted the full code below…
MANY THANKS!
ActionScript Code:
//Initiate variables
var currentWallD1:int = 0;
var lastWallD1:int = 0;
var currentWallD2:int = 0;
var lastWallD2:int = 0;
var itemNo:int = 0;
var score:int = 0;
var amount:int = 0;
var clickX:Number = 0;
var clickY:Number = 0;
var startX:int = 0;
var startY:int = 0;
var lPercent:Number = 2;
var initPos:int;
var endPos:int;
var contPos:int;
var perPos:int;
var cPointX:int = 0;
var cPointY:int = 0;
var goThrow:Boolean = false;
var oldladyspeed:Number = 6;
var left:Number = 0;
var right:Number = stage.stageWidth;
var item:Array = new Array();
var lastItemThrown = 1;
for (var b = 1; b <=3; b++) {
item[b] = new breadClass();
stage.addChild(item[b]);
item[b].alpha = 0;
}
// Movment of avatar with arrow keys
stage.addEventListener(KeyboardEvent.KEY_DOWN, downHandler);
function downHandler(event:KeyboardEvent):void {
if(event.keyCode == Keyboard.LEFT) {
oldlady.gotoAndPlay(14);
oldlady.x -= oldladyspeed;
}
if(event.keyCode == Keyboard.RIGHT) {
oldlady.gotoAndPlay(11);
oldlady.x += oldladyspeed;
}
// if avatar goes OFF screen left, comes ON screen right & visa-versa
if (oldlady.x - oldlady.width / 2 > right) {
oldlady.x = left - oldlady.width / 2;
} else if (oldlady.x + oldlady.width / 2 < left) {
oldlady.x = right + oldlady.width / 2;
}
}
// Because you didn't declare dx/dy as integers in your code it was causing some bizzarre
// problems when hitting a wall! I've also changed this so that dx and dy are never
// initiated as zero, which removes a lot of code later on.
// Duck 01 speeds & random direction
var dx:int=-2-Math.floor(Math.random()*1);
var dy:int=-2-Math.floor(Math.random()*1);
// Duck 02 speeds & random direction
var hx:int=-3-Math.floor(Math.random()*6);
var hy:int=-3-Math.floor(Math.random()*6);
// Initiate event listeners
addEventListener(Event.ENTER_FRAME, gameLoop);
targarea.addEventListener(MouseEvent.CLICK, clickHandler);
// Start Timer
var timer:Timer = new Timer(1000,250);
timer.addEventListener(TimerEvent.TIMER, countDown);;
timer.start();
// Move Sprites
function gameLoop(event:Event):void {
moveBread();
moveDuck1();
moveDuck2();
}
// Crosshair custom cursor on mouseOver pond
targarea.addEventListener(MouseEvent.MOUSE_OVER, TargMouseOver);
targarea.addEventListener(MouseEvent.MOUSE_OUT,TargMouseOut);
function TargMouseOver(e:MouseEvent){
addChild(tcursor_mc);
tcursor_mc.startDrag(true);
Mouse.hide();
}
function TargMouseOut(e:MouseEvent){
removeChild(tcursor_mc);
Mouse.show();
}
// Moves Bread along Bezier Curve
function moveBread():void {
if (goThrow) {
if (lPercent <= 1) {
item[itemNo].x = setBezierPos(startX, clickX, cPointX, lPercent);
item[itemNo].y = setBezierPos(startY, clickY, cPointY, lPercent);
lPercent = lPercent + 0.05;
}
else {
goThrow = false;
}
}
// hitTest Duck1 with Bread + 50 points
for (var n:int = 1; n <= 3; n++){
if (box1.hitTestObject(item[n])) {
updateScore(50);
//stage.removeChild(item[n]);
}
if (box2.hitTestObject(item[n])) {
updateScore(-50);
//stage.removeChild(item[n]);
}
}
}
function moveDuck1():void {
//Move the duck
box1.x += dx;
box1.y += dy;
// Test for any collisions and change the ducks direction if there are any
if (box1.hitTestObject(wall1)) {
currentWallD1 = 1;
}
if (box1.hitTestObject(wall2)) {
currentWallD1 = 2;
}
if (box1.hitTestObject(wall3)) {
currentWallD1 = 3;
}
if (box1.hitTestObject(wall4)) {
currentWallD1 = 4;
}
if (currentWallD1 != lastWallD1) {
dx=(3+Math.floor(Math.random()*6))*dx/Math.abs(dx);
dy=(3+Math.floor(Math.random()*6))*dy/Math.abs(dy);
switch (currentWallD1) {
case 1:
dx=dx*-1;
box1.gotoAndStop(1);
break;
case 2:
dy=dy*-1;
break;
case 3:
dy=dy*-1;
break;
case 4:
dx=dx*-1;
box1.gotoAndStop(2);
break;
}
lastWallD1 = currentWallD1;
}
}
function moveDuck2():void {
//Move the duck
box2.x += hx;
box2.y += hy;
// Test for any collisions and change the ducks direction if there are any
if (box2.hitTestObject(wall1)) {
currentWallD2 = 1;
}
if (box2.hitTestObject(wall2)) {
currentWallD2 = 2;
}
if (box2.hitTestObject(wall3)) {
currentWallD2 = 3;
}
if (box2.hitTestObject(wall4)) {
currentWallD2 = 4;
}
if (currentWallD2 != lastWallD2) {
hx=(3+Math.floor(Math.random()*6))*hx/Math.abs(hx);
hy=(3+Math.floor(Math.random()*6))*hy/Math.abs(hy);
switch (currentWallD2) {
case 1:
hx=hx*-1;
box2.gotoAndStop(1);
break;
case 2:
hy=hy*-1;
break;
case 3:
hy=hy*-1;
break;
case 4:
hx=hx*-1;
box2.gotoAndStop(2);
break;
}
lastWallD2 = currentWallD2;
}
}
function updateScore(amount):void {
score += amount;
theScore.text = String(score);
}
function countDown(event:TimerEvent):void {
myText.text = String(250 - timer.currentCount);
}
function clickHandler(event:MouseEvent):void {
if (!goThrow) {
startX = oldlady.x + 100;
startY = oldlady.y + 50;
itemNo ++;
if (itemNo > 3) {
itemNo = 1;
}
item[itemNo].alpha = 1;
oldlady.gotoAndPlay(2);
clickX = event.stageX;
clickY = event.stageY;
lPercent = 0;
cPointY = startY -150;
cPointX = startX + ((clickX - startX)/3);
//trace(startX + " " + cPointX + " " + clickX);
goThrow = true;
}
}
function setBezierPos(initPos, EndPos, ContPos, perPos):Number {
return initPos*(1-perPos)*(1-perPos)+2*ContPos*(1-perPos)*perPos+EndPos*perPos*perPos;
}
ADDED Event Problem
hey all,
first time post would appreciate any help
im loading images dynamically using xml and using using a listener to see when the object has been ADDED to the timeline and then organizing using image width im using added because im not sure of any other way that works
but this re organizes the images in an order that i dont prefer the xml docs has them listed as image1-image5 but when the imover function reorganizes them they end up showing up as 5,3,1,4,2 .
the flash help says that the item listening isnt always that which is used and that I should use the "currentTarget property to access the object in the display list that is currently processing the event." but im not sure how to do this.
heres the code any suggestions on how i can get this to work properly?
thanx all
CODE:
ActionScript Code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
var inTween:Tween;
var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var container:MovieClip= new MovieClip();
var xmlLoader:URLLoader=new URLLoader();
var iShift:Number=25;
container=new MovieClip();
container.name="iHolder";
xmlLoader.load(new URLRequest("data/images.xml"));
xmlLoader.addEventListener(Event.COMPLETE,xmlLoaded);
function xmlLoaded(event:Event):void {
xml=XML(event.target.data);
xmlList=xml.children();
for (var i:int; i<xmlList.length(); i++) {
imageLoader=new Loader();
imageLoader.name="image"+(i+1);
imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
container.addChild(imageLoader);
imageLoader.addEventListener(Event.ADDED,iMover);
}
}
function iMover(event:Event):void {
inTween=new Tween(event.target,"alpha",None.easeNone,0,1,3)
var iBuf:Number=25;
event.target.x=iShift;
event.target.y=(stage.stageHeight/2)-(event.target.height/2);
iShift+=event.target.width+iBuf;
trace(event.target.name);
container.x=(stage.stageWidth/2)-(container.width/2);
}
addChild(container);
EDIT
Please put Actionscript code in [ as ] [ /as ] tags (without spaces)
Dynamicly Added To Array
Hy, i´m looking for a way to bring a mc, at a certain point, to be a apart of a array. So there is a way to do that, dynamicly, but i don´t know how that works. Do i have to use a push method?
If somebody knows, maybe there is a tutorial or good link that explains it.
Thx
DisplayObject Is Not Always Added To Stage
Alright, I have another post with the same issue but this one is more isolated.
I have a simple app which adds 2 boxes to the stage. For some reason when the swf is cached the first box doesn't make it to the stage. Link to test
ActionScript Code:
package {
import flash.display.Sprite;
import flash.display.Stage;
public class SampleApp extends Sprite
{
private var bg:Sprite;
private var box:Sprite;
public function SampleApp()
{
bg = new Sprite();
bg.graphics.lineStyle();
bg.graphics.beginFill(0x000000, 1);
bg.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
bg.graphics.endFill();
stage.addChild(bg);
init();
}
private function init():void
{
box = new Sprite();
box.graphics.lineStyle();
box.graphics.beginFill(0xccff00, 1);
box.graphics.drawRect(0, 0, 200, 100);
box.graphics.endFill();
stage.addChild(box);
}
}
}
on initial load (as expected)
after leaving the page and returning. The swf is now cached. (not expected)
Check it out for your self. I can reproduce this every time on my works fast connection.
Added Event Is Not Firing
I have a simple event that never fires. I have gone through the help section and the syntax appears to be correct but I am new to 3.0 so perhaps I am missing something obvious that someone here can help me with. The loader just loads a jpg and I'm trying to add an init event to it. What is really confusing is that the loader loads the jpg with no problems but the init event never fires which leads me to think it's either something with my declaration of the event or possibly even a sandbox issue but the image loads so I don't know if that's possible. Here's the code for the listener if anyone can help.
Attach Code
var mylv4:Loader = new Loader();
function initHandler(event:Event):void
{
text1.text = "ok";
}
mylv4.addEventListener("INIT", initHandler);
Label Cannot Be Added To Movie
while workign on this i am trying to add a lable to the Movie which is dynamically added using addChild(myLabel).
i cannot add no error no out put .
but i am able to add button and grid without issue .
any idea .
Unloading Components Added On The Fly
Ok, quite complicated, but I'll explain:
I'm creating a cool little toolbar program using Flash MX, which loads up an XML file and creates buttons for each of the little tabs that are clicked on. The problem I have is that I load up the buttons, which are Flash UI Icon buttons components, really easily, but I can't seem to sucessfully unload them
Can anyone help?
Heres the code for the loading:
Code:
ProgramXML = new XML();
ProgramXML.load("Data.xml");
ProgramXML.ignoreWhite = True;
ProgramXML.onLoad = function(success) {
if (success) {
Base = ProgramXML.firstchild;
_root.Butt0.Title = Base.childnodes[0].attributes.TITLE;
_root.Butt1.Title = Base.childnodes[1].attributes.TITLE;
_root.Butt2.Title = Base.childnodes[2].attributes.TITLE;
_root.Butt3.Title = Base.childnodes[3].attributes.TITLE;
_root.Butt4.Title = Base.childnodes[4].attributes.TITLE;
_root.Butt5.Title = Base.childnodes[5].attributes.TITLE;
//
_root.ButtonArray = [];
// Load Buttons
for (i = 0; i < Base.childnodes[0].childnodes.length; i++) {
ButtonLbl = Base.childnodes[0].childnodes[i].attributes.TITLE;
ButtonNm = "ButtD"+i;
init = {Label: ButtonLbl, arrange: right, toggle: false, value: false, background: "ButtonSkin", _x: i * 97};
_root.LoadClip.attachMovie("FIconButtonSymbol", ButtonNm, i, Init);
BAL = _root.ButtonArray.length;
_root.ButtonArray[BAL] = "_root.LoadClip."+ButtonNm;
trace(_root.ButtonArray);
}
//
//
// Button 1 function
_root.Butt0.Butt.onRelease = function() {
trace("lENGTH: "+Base.childnodes[0].childnodes.length);
Erase();
for (i = 0; i < Base.childnodes[0].childnodes.length; i++) {
ButtonLbl = Base.childnodes[0].childnodes[i].attributes.TITLE;
trace("ButLbl: "+ButtonLbl);
ButtonNm = "ButtD"+i;
trace("BytNum: "+ButtonNm);
init = {Label: ButtonLbl, arrange: right, toggle: false, value: false, background: "ButtonSkin", _x: i * 97};
_root.LoadClip.attachMovie("FIconButtonSymbol", ButtonNm, i, Init);
}
};
} else {
trace("Problem:");
trace(ProgramXML.status);
trace(ProgramXML);
}
};
If you need the source, just ask!
Thankyou
News Feed, Xml With A Bit Of CSS Added
Hi,
I'm currently trying to make a news feed, and in order to do that, I need a little help. I've been combining XML and CSS for a while now, but every time, I try making something useful with it, the XML stops me. Now, I'm not a hawk to XML actionScripting, but the idea of the feed is, to pull some lines from an xml document into my news textbox, and then add a CSS style to it. And then for the user to swich between the different news, by hitting the "left" or "right" key.
Everything works, except the swich function, so that the user will be able to read more than just the first news child.
This is my AS:
ActionScript Code:
// xml & stylevar myStyle:TextField.StyleSheet = new TextField.StyleSheet();var myXML:XML = new XML();// styleSheetmyStyle.load("CSS.css");myStyle.onLoad = function(success) {if (success) {nyheder.styleSheet = this;load_xml();}};listen = new Object();listen.onKeyDown = function() {if (Key.getCode() == Key.LEFT) {prevNyhed();} else if (Key.getCode() == Key.RIGHT) {nextNyhed();}};Key.addListener(listen);// XML loadfunction load_xml() {myXML.ignoreWhite = true;myXML.load("forside.xml");myXML.onLoad = function(success) {p = 0;mainNode = this.firstChild.childNodes[p];var nyhederOverskrift:Array = new Array();nyhederOverskrift = mainNode.childNodes[0].childNodes;for (var i = 0; i<nyhederOverskrift.length; i++) {var nyhederOverskriftVar = nyhederOverskrift[i].toString();var nyhederDato:Array = new Array();nyhederDato = mainNode.childNodes[1].childNodes;for (var i = 0; i<nyhederDato.length; i++) {var nyhederDatoVar = nyhederDato[i].toString();var nyhederTekst:Array = new Array();nyhederTekst = mainNode.childNodes[2].childNodes;for (var i = 0; i<nyhederOverskrift.length; i++) {var nyhederTekstVar = nyhederTekst[i].toString();var nyhederLink:Array = new Array();nyhederLink = mainNode.childNodes[3].childNodes;for (var i = 0; i<nyhederLink.length; i++) {var nyhederLinkVar = nyhederLink[i].toString();nyheder.htmlText = "<span class='titel'>"+nyhederOverskriftVar+"</span><br><span class='dato'>"+nyhederDato+"</span><br><br><span class='tekst'>"+nyhederTekst+"</span><br><br><a href='"+nyhederLink+"' target='_blank'>"+nyhederLink+"</a><br><span class='center'>· · · · · · · · · · · · · · · · · · · · · · · · · · · ·</span>";}}}}};}function nextNyhed() {if (p<(total-1)) {p++;}}function prevNyhed() {if (p>0) {p--;}}
My XML looks like this:
PHP Code:
<?xml version="1.0" encoding="UTF-8"?><nyheder><news> <header>News 1</header> <date>29-05-05</date> <text>Google just launched their new portal - still beta.</text> <link>http://www.google.com/ig</link></news><news> <overskrift>News 2</overskrift> <dato>28-05-05</dato> <tekst>This is working!</tekst> <link>http://www.macro-design.org</link></news></nyheder>
Just so there aren't any doubt, it all loads into my "nyheder" textbox, just fine, and the CSS is added. But I can't make the swich funtion, so therefore I can only see the first news content, and not the following.
Any help, hint and/or trick, would be much appreciated, thanks
|