Applying Transitition To Function
I have a transition that works fine when I put it on a frame with my movie clip but I am trying to make it into a function. my movie clip instances are called mc1 thru mc5. The code is function (BounceEffect){mx.transitions.TransitionManager.start(this["mc" + q], {type:mx.transitions.Wipe, direction:0, duration:1, easing:mx.transitions.easing.Bounce.easeOut, param1:empty, param2:empty});but when I write BounceEffect();q = 1; in the frame with the movie clip it doesn't work, also the value q stays undefined. Any ideas??
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 05-23-2005, 11:55 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Applying A Function To A Mc
I'm trying to apply a function to a movie clip, but can't get the timeline to play in the child movies.
function myFunction() {
this.fade12_mc.gotoAndPlay(2);
this.fade18_mc.gotoAndPlay(2);
}
myFunction.apply(_root.myset_mc);
..anyone have any ideas why these clips won't play? They go to frame 2 but don't move forward.
Sumo
Applying A Function To Multiple Movieclips?
i have a sprite that grows as the mouse nears it, and shrinks as it pulls away using the distance formula (provided by the great wangbar)..
how can i apply this to multiple instances on the stage??
ActionScript.......//
function scanClip () {
// distance formula
diffX = _xmouse-clip._x;
diffY = _ymouse-clip._y;
// scaling
scale = 300-Math.sqrt(diffX*diffX+diffY*diffY);
scale = (scale<100) ? 100 : scale;
clip._xscale = clip._yscale=scale;
};
Clip.onEnterFrame = scanClip;
;
//
stop();
//
Applying A Variable Function To A Series Of Buttons
I've been coding for about six months, and somehow I've still never managed to solve this one basic issue. How do I write a single function to manage a series of buttons? If I create a series of buttons, my inclination is to do the following:
1. Put the button series into an array
2. Create a loop to cycle through the array and apply a function to each button that varies based on "i" within the loop.
Now I realize the problem with what I am doing. By the time I click a button, the loop has cycled all the way through and applied the final "i" value to every button.
But, I cannot figure out how to get around this. I'm sure it is a simple fix, and I equally sure that it has been addressed a thousand times in this forum, but I've looked for weeks, and still haven't found an answer. How do I deal with applying a variable function to a series of buttons?
I will include a simple example below that follows the basic problem that I find myself if. How would someone do this differently?
EXAMPLE:
var button_array:Array = new Array(button1_btn, button2_bth, button3_btn, button4_btn);
for (var i:Number = 0; i < button_array.length; i++) {
button_array[i].onRelease = function() {
trace(i+1);
}
}
How do I trace i such that if I click button1_btn, I get "1" and if I click button3_btn, I get "3" (and so on)?
Thanks for baring with a basic question,
tophers
Trying To Grasp Applying Generic Function To Mc OnEnterFrame's
Ok, so first of all thank you for reading this, extra thanks for taking the time to reply.
So, I'm a beginning to intermediate Flash and AS guy grappling with some programming concepts.
I find that when I create my own functions from scratch, especially to define a generic function to different movie clips, in this case to their onEnterFrame functions, I get unexpected results.
The bottom is some code from a new simple website I'm trying to code. My problem is that I can't get the function working in a generic way. I know I may be taking the completely wrong approach and totally missing something, but I am continuously coming up with problems (seems to be a misunderstading of scope at a deeper level, not simple variable timeline scope, but inherant scope within functions, etc..).
So, I will just copy paste the code here and try and comment as much as possible. For claritie's sake I will remove button codes except option1 and option2.
Ok, it's late and my brain is fried. Here we go. Flame away, I need to get this!!
//initialization of a few global and one timeline variable. These should
//be self explanatory in the code so I wont go into to much detail
//my probs arent in the detail but in the overall relationship of the
//code blocks
//
_global.INIT_MOVIE_POS = 1230;
_global.TARGET_X = 5;
_global.SPEED = 5;
var currentMovie = "0";
//
//
//LoadNewMovie function unloads current movie and loads new movie
//My main problem here is that this function seems to assign itself to
//every movie clip onEnterFrame that is subscribed to it, even though
//the assignment of the MC's onEnterFrame is governed by a onRelease
//event of the associated button
//
//
LoadNewMovie = function () {
if (currentMovie != "0") {
currentMovie.UnloadMovie();
}
this._visible = true;
if (this._x>TARGET_X) {
this._x -= (TARGET_X+this._x)/5;
} else {
this._x = TARGET_X;
currentMovie = this;
delete this.onEnterFrame;
}
};
//
//
//UnloadMovie unloads the current movie, called by LoadNewMovie
//
UnloadMovie = function() {
currentMovie._visible = false;
currentMovie._x = INIT_MOVIE_POS;
};
//prototype shiver controls roll over and roll out movement of buttons
//
MovieClip.prototype.shiver = function(xScale, yScale, strength, weight) {
var xScaleStep = 0;
var yScaleStep = 0;
this.onEnterFrame = function() {
xScaleStep = (xScale-this._xscale)*strength+xScaleStep*weight;
yScaleStep = (yScale-this._yscale)*strength+yScaleStep*weight;
this._xscale += xScaleStep;
this._yscale += yScaleStep;
};
};
option1.onRollOver = function() {
this.shiver(110, 110, 0.3, 0.8);
this._alpha = 100;
};
option1.onRollOut = function() {
this.shiver(100, 100, 0.3, 0.8);
this._alpha = 70;
};
option1.onMouseDown = function() {
_root.accolade_mc.onEnterFrame = LoadNewMovie;
};
option2.onRollOver = function() {
this.shiver(110, 110, 0.3, 0.8);
this._alpha = 100;
};
option2.onRollOut = function() {
this.shiver(100, 100, 0.3, 0.8);
this._alpha = 70;
};
option2.onMouseDown = function() {
dummy2_mc.onEnterFrame = LoadNewMovie;
};
Any and all help is appreciate here. Sometimes advanced RIA developers will see a problem like this and send me a 5 page RIA app that explains all the problems, but is SO over my head, it doesn't really help. What I do need to understand is, from a procedural approach to my simple problem, what am I missing, OR if my problem naturally points to an OOP approach of solving it, please let me know what the area of my fundamental misunderstanding or lack of knowledge is so I can specifically look to address it.
I am prepairing to study OOP structure, but feel that it won't benefit me until I have a strong procedural background. + I'm in between jobs right now and have to think about immediate visual effects, nor RIA which I am still a bit far from to say the least!
Anybody who read this far, you have my serious appreciation, respect, and thanks!!
David
Applying A Function To An Attached Object From A For Loop
why doesn't this work
i have an mc called ball that i've attached as an experiment on the first frame.
i put the numbers above the ball instances to show that the for loop was working and can call the variable i
what i want to do is make it so the balls slide in from the left with easing
so i started their _x at 0 and incremented it while still in the for loop.
this appears to be making them move along with the script until the next ball is attached during the next cycle through the for loop.
how can i access these to get them to slide in the way i want them to?
thanks
Trying To Grasp Applying Generic Function To Mc OnEnterFrame's
Ok, so first of all thank you for reading this, extra thanks for taking the time to reply.
So, I'm a beginning to intermediate Flash and AS guy grappling with some programming concepts.
I find that when I create my own functions from scratch, especially to define a generic function to different movie clips, in this case to their onEnterFrame functions, I get unexpected results.
The bottom is some code from a new simple website I'm trying to code. My problem is that I can't get the function working in a generic way. I know I may be taking the completely wrong approach and totally missing something, but I am continuously coming up with problems (seems to be a misunderstading of scope at a deeper level, not simple variable timeline scope, but inherant scope within functions, etc..).
So, I will just copy paste the code here and try and comment as much as possible. For claritie's sake I will remove button codes except option1 and option2.
Ok, it's late and my brain is fried. Here we go. Flame away, I need to get this!!
//initialization of a few global and one timeline variable. These should
//be self explanatory in the code so I wont go into to much detail
//my probs arent in the detail but in the overall relationship of the
//code blocks
//
_global.INIT_MOVIE_POS = 1230;
_global.TARGET_X = 5;
_global.SPEED = 5;
var currentMovie = "0";
//
//
//LoadNewMovie function unloads current movie and loads new movie
//My main problem here is that this function seems to assign itself to
//every movie clip onEnterFrame that is subscribed to it, even though
//the assignment of the MC's onEnterFrame is governed by a onRelease
//event of the associated button
//
//
LoadNewMovie = function () {
if (currentMovie != "0") {
currentMovie.UnloadMovie();
}
this._visible = true;
if (this._x>TARGET_X) {
this._x -= (TARGET_X+this._x)/5;
} else {
this._x = TARGET_X;
currentMovie = this;
delete this.onEnterFrame;
}
};
//
//
//UnloadMovie unloads the current movie, called by LoadNewMovie
//
UnloadMovie = function() {
currentMovie._visible = false;
currentMovie._x = INIT_MOVIE_POS;
};
//prototype shiver controls roll over and roll out movement of buttons
//
MovieClip.prototype.shiver = function(xScale, yScale, strength, weight) {
var xScaleStep = 0;
var yScaleStep = 0;
this.onEnterFrame = function() {
xScaleStep = (xScale-this._xscale)*strength+xScaleStep*weight;
yScaleStep = (yScale-this._yscale)*strength+yScaleStep*weight;
this._xscale += xScaleStep;
this._yscale += yScaleStep;
};
};
option1.onRollOver = function() {
this.shiver(110, 110, 0.3, 0.8);
this._alpha = 100;
};
option1.onRollOut = function() {
this.shiver(100, 100, 0.3, 0.8);
this._alpha = 70;
};
option1.onMouseDown = function() {
_root.accolade_mc.onEnterFrame = LoadNewMovie;
};
option2.onRollOver = function() {
this.shiver(110, 110, 0.3, 0.8);
this._alpha = 100;
};
option2.onRollOut = function() {
this.shiver(100, 100, 0.3, 0.8);
this._alpha = 70;
};
option2.onMouseDown = function() {
dummy2_mc.onEnterFrame = LoadNewMovie;
};
Any and all help is appreciate here. Sometimes advanced RIA developers will see a problem like this and send me a 5 page RIA app that explains all the problems, but is SO over my head, it doesn't really help. What I do need to understand is, from a procedural approach to my simple problem, what am I missing, OR if my problem naturally points to an OOP approach of solving it, please let me know what the area of my fundamental misunderstanding or lack of knowledge is so I can specifically look to address it.
I am prepairing to study OOP structure, but feel that it won't benefit me until I have a strong procedural background. + I'm in between jobs right now and have to think about immediate visual effects, nor RIA which I am still a bit far from to say the least!
Anybody who read this far, you have my serious appreciation, respect, and thanks!!
David
Applying A Function To An Attached Object From A For Loop
why doesn't this work
i have an mc called ball that i've attached as an experiment on the first frame.
i put the numbers above the ball instances to show that the for loop was working and can call the variable i
what i want to do is make it so the balls slide in from the left with easing
so i started their _x at 0 and incremented it while still in the for loop.
this appears to be making them move along with the script until the next ball is attached during the next cycle through the for loop.
how can i access these to get them to slide in the way i want them to?
thanks
Applying A SetInterval Fade Function To Multiple Duplicated Movieclips
After duplicating a movieclip and positioning them on the stage, I would like to have them all individually fade in, stay for a period of time, then fade out. I have a fade function that uses setInterval and works perfectly for one movieclip, but I can't get it to work for each in a series of duplicated movieclips.
I tried to do this using a for loop that references the unique ID of each movieclip (see commented out code), but it didn't seem to work. Perhaps there is a way to use a for loop to pass the movieclip ID into the fade function?
Following is the code I used (which applies the fade, as I intended only to qDup0, because I commented out the loop that calls all movieclip IDs):
CODE:
Code:
//variable declaration
var fadeOutSpeed = 12;//speed of q movieclip fade out
var fadeInSpeed = 12;//speed of q movieclip fade in
var xPos = 0;//initial x Position of q movieclip
var yPos = 100;//initial y Position of q movieclip
var qAlpha = 20;//initial alpha of q movieclip
var displayTime = 1000;//duration in ms that q remains before fade out
var quantityQ = 5;//total number of q to render onto the stage
var maxQalpha = 60;//sets maximum alpha that q gets to
//duplicate and position movie clips
dupQ = function () {
for (i=0; i<quantityQ; i++) {
qDup.duplicateMovieClip("qDup"+i, i,
//set position, alpha, and size/scale of q movieclips
{_x:xPos+(i*50),
_y:yPos,
_alpha:qAlpha});
with (eval("qDup"+i+".qShape")) {
//set size/scale of each movieclip
_xscale = 20;
_yscale= 100;
}
}
};
dupQ();
//code to fade q and keep it on the stage for a certain length of time (thanks kglad!)
function fadeF(dir) {
//for (i=0; i<quantityQ; i++) {
//qDupID = "qDup"+i;
if (dir>0) {
qDup0._alpha += dir*fadeInSpeed;
if (qDup0._alpha>=maxQalpha) {
clearInterval(fadeI);
startFOutI = setInterval(startFOutF, displayTime);
}
} else {
qDup0._alpha += dir*fadeOutSpeed;
if (qDup0._alpha<=0) {
clearInterval(fadeI);
}
}
//}
}
function startFOutF() {
clearInterval(startFOutI);
fadeI = setInterval(fadeF, 50, -1);//initiates fade out
}
fadeI = setInterval(fadeF, 50, 1);//initiates fading functions
Applying Already Working Grow/fade Function To Previously Loaded Swf (mc Container)
Through some previous as help, I am using this code to scale & fade an attached movie:
Code:
_root.attachMovie("logo","logo",10001)
_root.logo._xscale = 10;
_root.logo._yscale = 10;
_root.logo._x = 500;
_root.logo._y = 400;
_root.logo._alpha = 100;
MovieClip.prototype.grow = function(a,b) {
this._xscale += b;
this._yscale = this._xscale;
if (this._xscale>a-1 && this._xscale<a+1) {
delete this.onEnterFrame;
}
};
_root.logo.onEnterFrame = function() {
this.grow(250,50);
if (this._alpha <= 100)
{
this._alpha -= 4;
}
else{
delete this.onEnterFrame;
}
}
Now, I would like to do basically the same thing with a movie that I have previously loaded into to an empty movie clip, called holder12, which occurs at a 34 second interval...I want to run the code to scale & fade the clip at about 70 seconds.
Here is one of my non working attempts:
Code:
MovieClip.prototype.EBSgrow = function(a,b) {
this._xscale += b;
this._yscale = this._xscale;
if (this._xscale>a-1 && this._xscale<a+1) {
delete this.onEnterFrame;
}
};
_root.holder12.onEnterFrame = function() {
clearInterval(EBSgrow);
this.EBSgrow(250,50);
if (this._alpha <= 100)
{
this._alpha -= 4;
}
else{
delete this.onEnterFrame;
}
}
EBSgrow = setInterval (EBSgrow, 70000);
I am wondering do I even need to code to check if the movie is loaded? (since I know it is)
Because I have gotten this working (below) but it just jumps to x and y scale values provided and the important part is that I scale & fade in a gradual transistion...
Code:
//function growEBS(){
//clearInterval(growEBS);
//_root.holder12.onEnterFrame = function() {
//_root.holder12._xscale = 500;
//_root.holder12._yscale = 500;
//delete this.onEnterFrame;
//}
//}
//growEBS = setInterval (growEBS, 70000);
I appreciate any suggestions on how to get this working and feel free to point out any mistakes I am making (because my basic understand of as is lacking, I sometimes put things together than any one with more experience would know cannot go together)
Applying Already Working Grow/fade Function To Previously Loaded Swf (mc Container)
Through some previous as help, I am using this code to scale & fade an attached movie:
Code:
_root.attachMovie("logo","logo",10001)
_root.logo._xscale = 10;
_root.logo._yscale = 10;
_root.logo._x = 500;
_root.logo._y = 400;
_root.logo._alpha = 100;
MovieClip.prototype.grow = function(a,b) {
this._xscale += b;
this._yscale = this._xscale;
if (this._xscale>a-1 && this._xscale<a+1) {
delete this.onEnterFrame;
}
};
_root.logo.onEnterFrame = function() {
this.grow(250,50);
if (this._alpha <= 100)
{
this._alpha -= 4;
}
else{
delete this.onEnterFrame;
}
}
Now, I would like to do basically the same thing with a movie that I have previously loaded into to an empty movie clip, called holder12, which occurs at a 34 second interval...I want to run the code to scale & fade the clip at about 70 seconds.
Here is one of my non working attempts:
Code:
MovieClip.prototype.EBSgrow = function(a,b) {
this._xscale += b;
this._yscale = this._xscale;
if (this._xscale>a-1 && this._xscale<a+1) {
delete this.onEnterFrame;
}
};
_root.holder12.onEnterFrame = function() {
clearInterval(EBSgrow);
this.EBSgrow(250,50);
if (this._alpha <= 100)
{
this._alpha -= 4;
}
else{
delete this.onEnterFrame;
}
}
EBSgrow = setInterval (EBSgrow, 70000);
I am wondering do I even need to code to check if the movie is loaded? (since I know it is)
Because I have gotten this working (below) but it just jumps to x and y scale values provided and the important part is that I scale & fade in a gradual transistion...
Code:
//function growEBS(){
//clearInterval(growEBS);
//_root.holder12.onEnterFrame = function() {
//_root.holder12._xscale = 500;
//_root.holder12._yscale = 500;
//delete this.onEnterFrame;
//}
//}
//growEBS = setInterval (growEBS, 70000);
I appreciate any suggestions on how to get this working and feel free to point out any mistakes I am making (because my basic understand of as is lacking, I sometimes put things together than any one with more experience would know cannot go together)
Applying For Job
I am Interested in you job offer. Let me know about your requiremetns and then I will send you my CV and other related details. I am waiting for your response.
Thanks
Asim Iqtidar
Applying Functions To Mc's In MX
ok i have a function called dots that i wish to apply to a set of movie clips - now usually I would just use
dots.apply(mcname);
but am duplicating mc's like so
Code:
while (i < 50) {
duplicateMovieClip(mcname, "mcname"+i, i);
setProperty ("mcname"+i, _x, (Math.random()*i)+20);
setProperty ("mcname"+i, _y, (Math.random()*i)+20);
i++
}
so how would I apply the function dots to each duplicated mc?
thanks for the help
v_Ln
Applying OnRelease
I'm getting there slowly. Can somebody help me with another simple one? I can't seem to pass anything into an onRelease function. Here's what I have ....
code:
for (j=0; j<obj[i].val.length; j++) {
var tab_mc = menu_mc.attachMovie("tab", obj[i].val[j].id, j);
//apply text to tabs
var tabTxt = obj[i].val[j].text;
tab_mc.tab_txt.text = tabTxt;
//set tab state
if (j>0) {
tab_mc.gotoAndStop("inactive");
}
//set tab actions
tab_mc.onRelease = function() {
tab_mc.gotoAndStop("active");
}
I'm assigning text, actions etc to a set of menu tabs. The part where I make the tabs inactive works. But this ....
code:
tab_mc.onRelease = function() {
tab_mc.gotoAndStop("active");
}
.... has problems. I had advice on a similar problem yesterday. Either this one has a different solution or I don't understand what's going on fully. Can someone please tell me how to get this working, and maybe explain why it doesn't work in this way?
thanks
mark
Applying Arc To Text
Is there a way to take dynamically created text and apply an arc to it? So if I entered "Hello World" I could make the text look like a flag or apply any number of "wavey" effects to it.
Thanks,
khanathor
[F8] Applying CSS On TextField
Hey guys,
I'm building a dynamic website in Flash. Some text (html-formatted with <p>'s and <a>'s) is loaded from the database and inserted in a runtime-created TextField, like so:
code: cd.createTextField("cdt",cd.getNextHighestDepth(), 14,38,398,334);
cd.cdt.html = true;
cd.cdt.htmlText = colorDetails;
cd.cdt.selectable = true;
cd.cdt.wordWrap = true;
cd.cdt.styleSheet = styleObj;
Where colorDetails is the text from the database, and styleObj is my stylesheet. The stylesheet looks like this:
Code:
a:link {
font-size: 9;
font-family: Verdana,sans-serif;
color: #0000ff;
text-decoration: underline; }
a:visited {
font-size: 9;
font-family: Verdana,sans-serif;
color: #0000ff;
text-decoration: underline; }
p {
font-size: 9;
font-family: Verdana,sans-serif;
display: block; }
The links work perfectly. They turn blue, have the right font and size and are underlined. Now no matter what I try, I can't style the rest of the text. Text inside <p> tags stays Times New Roman and inline. The selector sort of works, because I can set the font-weight of <p> to bold. Using a custom tag, a class or no tag at all doesn't help either. I've tried generating the stylesheet from inside flash (using styleObj.setStyle()), but the result is the same. Am I overlooking something trivial? Or am I trying to do something that's impossible? Thanks in advance for your answers!
Applying Actions
Hi,
I know you can apply an action to a specific object, but is there a way to apply an action to the whole flash movie?
thanks!
Applying A Var To A Movieclip?
Hello,
I am looking for some guidance here.
I am working with this code right now,
var hasFocus:Number=1;
mc_1.onPress=function(){
hasFocus=1
}
and I would like to understand how to apply hasFocus=1 to the movieclip mc_1 without using an onPress or onRelease function.
Please help if you can,
Thanks
Applying Inertia
butterfly_mc.onEnterFrame = function() {
butDistance = Math.sqrt(((this._x-_xmouse)*(this._x-_xmouse))+((this._y-_ymouse)*(this._y-_ymouse)));
if (butDistance<=250) {
this._x += (_xmouse-this._x)/10;
this._y += (_ymouse-this._y)/10;
}
};
I have this code which works awesomely for getting an mc to follow the mouse wile it is within a certain distance and it stops following it when it is out of the distance range. at the moment it comes to a dead stop but i was wondering what i would have to do to apply inertia to it so it comes to a gradual stop.
cheers.
Applying Variables Only Once ?
Hi, is there a way to apply variables only once?
Like in an MC when you can use Load to give it variables et c. Can you use anything like this for an function?
I have this problem:
ActionScript Code:
ai_foe = function (target){ if (target.action == undefined) { target.action = "idle"; } if (target.hitTest (_root.char)) { target.action = "attack"; } switch (target.action) { case "idle" : target.gotoAndPlay (target.action); break; case "attack" : target.gotoAndPlay (target.action); break; case "dead" : target.gotoAndPlay (target.action); break; }};
The problem is that the target MC is going to freeze at the first frame of "action", since this is loaded every onEnterFrame.
How do i get around this?
Applying SWF Into HTML
(I know this might be lame, but Im doing it for a client and really need this as well as my other post so thank you for ANY information! please...need code soon)
I think I got this code from a friend...Anyways it does NOT work with the new internet explorer and my teacher was saying that <object> works with firefox, while src works with explorer...so were do I put the src to make it work in internet exploder?
Or if anyone has better overall, simpler code, that would be much appreciated..
AGAIN: I hadnt really made myself clear as to what I need... I just need that code that puts the actionscript 3.0 SWF into the HTML....O yeah, and center it in the vertical and horizontal middle!
HERES MINE:
<html>
<head>
<title>
| myPage |
</title>
<LINK REL=StyleSheet HREF="style.css" TYPE="text/css" MEDIA=screen>
<head>
<body>
<table border="0" width="100%" height="430px" style="position:relative; top:-100px;">
<tr>
<td>
<div style="width:100%; height:20px; vertical-align:middle;" align="center">
<object classid="firstplay.swf" src="firstplay.swf" width="888" height="468" align="absbottom" vspace="absmiddle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="allowFullScreen" value="false" />
<param name="movie" value="firstplay.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#000000" />
<embed src="firstplay.swf" width="888" height="468" align="absbottom" quality="high" bgcolor="#000000" allowscriptaccess="sameDomain" allowfullscreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
again this code works, just not in internet exploder!
ColorMatrixFilter : Applying An RGB Value
Hi there,
I'm using the following code to subtract blend a movieclip (b&w image - 'alphaChannel') which is above a colour image of a car, the intended result is to colour the car:
Code:
import flash.filters.BitmapFilter;
import flash.filters.ColorMatrixFilter;
var colourSettings:Array = new Array();
applyColourMatrix(alphaChannel,28,130,200,255);
function applyColourMatrix(src,r,g,b,a) {
var matrix:Array = new Array();
matrix = matrix.concat([r, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, g, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, b, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, a, 0]); // alpha
var filter:BitmapFilter = new ColorMatrixFilter(matrix);
src.filters = new Array(filter);
}
Now i can't seem to get the same effect as when i apply the filter to the actual movieclip at authoring time. The image still shows up as black.
Can someone please explain to me how I could start with an rgb value that i want to use say thats equivalent to teal and then find the correct values to apply to the subtract layer. I have tryed normal rgb values and this formula 255 - value.
Hope someone can help!
Thanks,
DoubleE
Applying A Scrollbar As3.
Hello all!
All I need to do to is apply the scrollbar at the bottom of the code to the text field tContent and I'm so dumb that I cannot figure it out. No need saying that I am very new to this but your help will very much prevent me from going crazy.
Also if I test the movie like this an error will come saying package is unexpected. No idea why.
Thank you very much for your time.
Andres.
Code:
var textContainer:Sprite = new Sprite();
textContainer.x = 30;
textContainer.y = 150;
addChild(textContainer);
var tContent:TextField = new TextField();
tContent.width = 600;
tContent.wordWrap = true;
tContent.autoSize =TextFieldAutoSize.LEFT;
textContainer.addChild(tContent);
var cssLoader:URLLoader = new URLLoader();
var cssRequest:URLRequest = new URLRequest("oceanRowStyle.css");
cssLoader.addEventListener(Event.COMPLETE, cssLoaded);
cssLoader.load(cssRequest);
function cssLoaded(evt:Event):void{
var css:StyleSheet = new StyleSheet();
css.parseCSS(URLLoader(evt.target).data);
tContent.styleSheet = css;
//tContent.htmlText = pageContent;
}
var welcomeLoader:URLLoader = new URLLoader();
var welcomeRequest:URLRequest = new URLRequest("welcome.txt");
welcomeLoader.dataFormat = URLLoaderDataFormat.TEXT;
welcomeLoader.addEventListener(Event.COMPLETE, welcomeLoaded);
welcomeLoader.load(welcomeRequest);
function welcomeLoaded(evt:Event):void {
tContent.text = welcomeLoader.data;
}
//Scrollbar
/**
* Flashscaper Scrollbar Component
* Customizable Scrollbar
*
* @authorLi Jiansheng
* @version1.0.0
* @private
* @website http://www.flashscaper
*/
package {
import caurina.transitions.*;
import flash.display.*;
import flash.events.*;
import flash.geom.*;
public class Scrollbar extends MovieClip {
private var target:MovieClip;
private var top:Number;
private var bottom:Number;
private var dragBot:Number;
private var range:Number;
private var ratio:Number;
private var sPos:Number;
private var sRect:Rectangle;
private var ctrl:Number;//This is to adapt to the target's position
private var trans:String;
private var timing:Number;
private var isUp:Boolean;
private var isDown:Boolean;
private var isArrow:Boolean;
private var arrowMove:Number;
private var upArrowHt:Number;
private var downArrowHt:Number;
private var sBuffer:Number;
public function Scrollbar():void {
scroller.addEventListener(MouseEvent.MOUSE_DOWN, dragScroll);
stage.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
stage.addEventListener(MouseEvent.MOUSE_WHEEL,mouseWheelHandler);
}
//
public function init(t:MovieClip, tr:String,tt:Number,sa:Boolean,b:Number):void {
target = t;
trans = tr;
timing = tt;
isArrow = sa;
sBuffer = b;
if (target.height <= track.height) {
this.visible = false;
}
//
upArrowHt = upArrow.height;
downArrowHt = downArrow.height;
if (isArrow) {
top = scroller.y;
dragBot = (scroller.y + track.height) - scroller.height;
bottom = track.height - (scroller.height/sBuffer);
} else {
top = scroller.y;
dragBot = (scroller.y + track.height) - scroller.height;
bottom = track.height - (scroller.height/sBuffer);
upArrowHt = 0;
downArrowHt = 0;
removeChild(upArrow);
removeChild(downArrow);
}
range = bottom - top;
sRect = new Rectangle(0,top,0,dragBot);
ctrl = target.y;
//set Mask
isUp = false;
isDown = false;
arrowMove = 10;
if (isArrow) {
upArrow.addEventListener(Event.ENTER_FRAME, upArrowHandler);
upArrow.addEventListener(MouseEvent.MOUSE_DOWN, upScroll);
upArrow.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
//
downArrow.addEventListener(Event.ENTER_FRAME, downArrowHandler);
downArrow.addEventListener(MouseEvent.MOUSE_DOWN, downScroll);
downArrow.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
}
var square:Sprite = new Sprite();
square.graphics.beginFill(0xFF0000);
square.graphics.drawRect(target.x, target.y, target.width+5, (track.height+upArrowHt+downArrowHt));
parent.addChild(square);
target.mask = square;
}
public function upScroll(event:MouseEvent):void {
isUp = true;
}
public function downScroll(event:MouseEvent):void {
isDown = true;
}
public function upArrowHandler(event:Event):void {
if (isUp) {
if (scroller.y > top) {
scroller.y-=arrowMove;
if (scroller.y < top) {
scroller.y = top;
}
startScroll();
}
}
}
//
public function downArrowHandler(event:Event):void {
if (isDown) {
if (scroller.y < dragBot) {
scroller.y+=arrowMove;
if (scroller.y > dragBot) {
scroller.y = dragBot;
}
startScroll();
}
}
}
//
public function dragScroll(event:MouseEvent):void {
scroller.startDrag(false, sRect);
stage.addEventListener(MouseEvent.MOUSE_MOVE, moveScroll);
}
//
public function mouseWheelHandler(event:MouseEvent):void {
if (event.delta < 0) {
if (scroller.y < dragBot) {
scroller.y-=(event.delta*2);
if (scroller.y > dragBot) {
scroller.y = dragBot;
}
startScroll();
}
} else {
if (scroller.y > top) {
scroller.y-=(event.delta*2);
if (scroller.y < top) {
scroller.y = top;
}
startScroll();
}
}
}
//
public function stopScroll(event:MouseEvent):void {
isUp = false;
isDown = false;
scroller.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_MOVE, moveScroll);
}
//
public function moveScroll(event:MouseEvent):void {
startScroll();
}
public function startScroll():void {
ratio = (target.height - range)/range;
sPos = (scroller.y * ratio)-ctrl;
Tweener.addTween(target, {y:-sPos, time:timing, transition:trans});
}
}
}
Applying Masking
I'm trying to create masking for 2 text (PR) but for some reason it wont play right... what im trying to do is here i don't want someone to do it for me... what i need is for someone to tell me what im doing wrong hehe
Using: Flash professional 8
Applying Stroke To Text
Hi guys im using flash 5 and was wondering how to apply a Stroke to text??
please help
thankyou
Stu
Applying Multiple Effects?
hi everyone, i just wanted to know if it's not possible to apply more than just one effect to an instance of a symbol? e.g. if i change the alpha of an instance, then also want to change the tint it takes away the initial alpha effect.
thx for your help!
Applying Gradient To Strokes ?
Hey peeps,
Does anyone know if it's possible to apply a gradient to a stroke rather than to a fill in Flash 5 ? i.e. to apply a gradient to a squiggle with the pencil tool.
Love,
Osca xxx
Applying Multiple OnEnterFrame()'s
Wanted to ask anyone out there about an issue I am trying to get to work. Basically I am building a couple of Movieclip.prototypes that can get called anywhere in the timeline. They both draw on instantiating the onEnterFrame script of MX. They work great when they are called alone/separately, however when I try to call more that one simultaneously....only one of them fires.
Does anyone have some experience in creating a code-based solution for this?
Hope this explains the issue.
Cheers,
jw
Applying Actions To Buttons.
This may seem a little infantile to some of the more veteran Flashers here but I need help making my buttons work. I do not know how to make my button on click goto and play a certain frame. I have tryed going to the button editor but it keeps telling me that the object I have selected cannot have actions applied to it. I am using Flash Mx 2004. Thank you for your help.
Applying Scroll To Text
Hello, I´d like to know how could I apply scroll to a text in my movie. I´ve been trying but I´m not able to. Any help will be welcome.
Happy new year for everyone.
Applying Actions To Components
I have a button, that is a component to add paypal compatibility, which is awesome, but I have 1 snag I need to iron out.
my entire site is self contained (700px by 700px), so there's no scrollbars and so when someone clicks the "buy now" button, and is redirected to the paypal page, there's no scrollbar there as well... what would be the easiest way around this? could I add an action to the component to make that pop-up in it's own resizable window? I guess the problem is that since the button's a component, I don't know the url to put in the getUrl action... any ideas??? thanks...
Applying Sound To Buttons
Hi, I'm using flash mx 2004. I've made some buttons and applied sound to the 'down' frame on a new layer...but the sound doesn't seem to work. I've got a loadMovie() function also applied to the button, will this be a reason for it not working? Because I have many other buttons which have sound on them and they work...but don't have the loadMovie script. If this is why, does anyone have an suggestions on how to get around it?
Lisa
Applying AS To Dynamic Text
Is there a way to apply AS to a specific word in dynamic text?
I need to add this AS to a couple of words within a dynamic text box controlled by a scroll bar. when i highlight the words i want to use for the link i only get URL type options. its not a url though rather a load movie command. make sense?
on (release) {
loadMovieNum("testimonials", 2);
}
Duplicating And Applying Code
I want to make it so I can easily duplicate movie clips and make the code apply to it. I'm trying to make a game and have walls.
I'm not sure that I phrased this question right. Please tell me if I need to elaborate.
Identifying Movie Name And Applying It
hello all, this is probably a very basic problem but i cant work it out , im using mx2004 so i guess its an actionscript 2.0 issue.
right i have a file with two layers. layer 1 in frame1 executes a code which means it loads a random file, from image0 through to image 20 in an external folder, into a placeholder called mainimagein. over this plays an animation which also acts as a mask, so the content on layer 1 can only bee seen throught he animation on layer2. this all works as planned.
because of masking issues i cant achieve the effect i want, iv tried many ways and the solution i have come up with is the one i want to achieve. when the animation has finished playing i need a piece of code which basically does this.
finds out what is the name of the SWF that was opened in in mainimagein in frame1 by the randomiser?
tells the SWF that was opened to load into mainimagein again.
i know it might sound a bit of a weird thing but i would really appreicate if anyone could help with the code, i dont know actionscript well enough to put together, iv done a lot of guess work and everytime i think im a little bit off. ive included this code, i know its bang wrong but it kinda of communicates what i want to do.
getProperty(mainimagein,_url)
mainimagein.loadMovie.("_url")
cheers in advance, its almost telling the movie to simply refresh, but i dont know how to do that either
bast
Applying Gradients To Files....?
hi all!
i'm new, so howdy!
i've got a question in regards to how/what kinds of files can you apply gradients to?
i was able to create some text in flash and have a motion tween happen over the text with a moving black/white gradient...creating a moving highlight over the text, very cool looking.
but the text that flash creates is only so good, so i imported a text/file that i created in photoshop as a png.file (because i just want the text on a translucent background). the text looks great against my background but now i can't get the fill transform tool and/or the paint gradient to apply to my new file/text!
so can someone please explain what i'm going to have to do to my file to be able to get that moving highlight thingy to happen over it again?
in advance, thanks soooo much!
Help Applying Drawing Api AS To A Movieclip
hello, ive got stuck trying to do somthing pretty simple.
Using drawing api i have used the following code (below) to allow the user to draw.
The code creates an empty movie clip so the drawing api can work, but this allows the user to draw over everything on screen.
I tried to make it so the code refrenced a movie clip i had on stage instead of creating a empty one, but this did not work. I also tried applying the code inside a movieclip which i placed on stage but this also failed.
Im trying to make it so there is a drawing box on screen (movieclip) and outside of that box the user cannot draw.
How would i edit this code so it works only on a movieclip placed on the stage?
*************************************
_root.createEmptyMovieClip("paintClip", 1);
var thickness:Number = 1;
var colour:Number = 0x000000;
var alpha:Number = 100;
onMouseDown = function () {
paintClip.moveTo(_xmouse, _ymouse);
onMouseMove = function () {
paintClip.lineStyle(thickness, colour, alpha);
paintClip.lineTo(_xmouse, _ymouse);
};
};
onMouseUp = function () {
onMouseMove = null;
};
*************************************
Im using flash8 as2 and the .fla is included.
Thanks,
Vic
Applying Round Corners
I would like to now if there is a way of applying round corners to an existing rectangle.
I need to be able to create the rectangle, then resize it and finally apply the round corners. If I do the corners while first drawing the rectangle, they are distorted when I resize it.
Is there a way?
Applying A Class To All Movieclips
I've created a few basic classes (movement, fade, scaling) that I would like any movieclip to be able to use. I know how to apply a class to an individual movieclip in the properties in the library. Is there a way I can apply a class to all movieclips? Below is a sample class of what I'm talking about. All my classes are similar math type classes for general things.
code:
class Mover extends MovieClip {
private var newX:Number;
private var newY:Number;
private var speed:Number;
public function startMoving(newX:Number, newY:Number, speed:Number):Void {
this.newX = newX;
this.newY = newY;
this.speed = speed;
this.onEnterFrame = this.updatePosition;
}
private function updatePosition():Void {
this._x += (this.newX - this._x) / this.speed;
this._y += (this.newY - this._y) / this.speed;
}
}
If I were to apply the class to say "nav_mc" in the library then I could access it like so.
code:
nav_mc.startMoving(100, 100, 3);
Applying Loaded Fonts
Hello,
I have a problem when trying to apply a font from a movieClip loaded with loadMovie.
Just for testing, I'm trying to apply the text formating in 2 steps:
1. I load the movie pressing the button 1 (fontButton);
2. I apply the new font pressing the button 2 (changeFontButton).
This is how my code look like:
fontButton.onRelease = function() {
loadMovie("arial.swf", fontHolder)
};
changeFontButton.onRelease = function() {
style_fmt.font = fontHolder["Arial"];
dynamic_txt_holder.dynamic_txt.setTextFormat(style _fmt);
};
It doesn't work. How can I solve this problem? Or, is there another way to do the same thing?
Applying Stroke To External Swf
Hi
I'm loading in vector graphics saved as external swfs into my main movie. Is there a way of applying a stroke to these swfs using actionscript?
Thanks
Tom
Applying Acceleration To Movieclip
I am trying to add acceleration to a movieclip called Ground. I have written this code
package {
import flash.display.Stage;
import flash.display.Sprite;
import flash.ui.*;
import flash.events.*;
public class Ground extends Sprite{
private var xVel:Number = 0;
private var xAcc:Number = -0.25;
public function Accelerate()
{
init();
}
private function init():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, go);
}
private function go(event:KeyboardEvent):void
{
if(event.keyCode == Keyboard.UP){
xVel += xAcc;
}
}
}
}
The movieclip loads fine and i get no errors, but when the up button is pressed nothing happens. Can anyone help?
Applying Friction To Movieclip
i have a movieclip that accelerates when you press the up button. when you let go of the up button the movieclip no longer accelerates but carries on at a constant speed. i am trying to add friction to the movieclip so it slows down when the up button is released. i have written this code -
private var friction:Number = 0.5;
stage.addEventListener(KeyboardEvent.KEY_UP, Stop);
private function Stop(evt:KeyboardEvent):void
{
if(evt.keyCode == Keyboard.UP){
xAcc = 0;
xVel *= friction;
}
}
but all this does it slow the movieclip down suddenly and makes it go at a slower constant speed. Can anyone help?
Combining 2 Mc's After Applying A Mask
Hi!
I am looking for a way to combine/convert 2 mc's in one after applyin a mask. Let's say I have 2 mc's and I apply a mask (a third mc). I would like the resulting image (part mc1, part mc2, according to mask) to become an independent mc that I can then manipulate. I want to be able to move, scale only 1 clip and not 3 (mc1, mc2 and mask).
Is it possible?
Thank you!
Applying Gradient To A Text
Hi, can this be done, applying gradient to a text? For example, orange at the bottom and yellow at the top. Can someone tell me how to do this?
Thanks in advance
AS Blur - Applying Time
Hi...could someone tell me how i can send an AS blur effect with a gradual transition. At the moment i have
ActionScript Code:
import flash.filters.BlurFilter;
var blurX:Number = 30;
var blurY:Number = 30;
filter = new BlurFilter(blurX, blurY, 3);
filterArray = new Array();
filterArray.push(filter);
_root.bk.filters = filterArray;
....but i just dont know how i can have a gradual blur over say 3 secs
Applying Code To An Array?
Here is the Code:
Code:
var magnet_radius:Number = 130;
var coefficient:Number = .10;
var GRAVITY:Number = Math.random(.1);
var ball:MovieClip = returnBall();
this.onEnterFrame = run;
function distance( dx:Number, dy:Number ) : Number {
return Math.sqrt( dx * dx + dy * dy );
}
function offset( dist:Number ) : Number {
return ( magnet_radius - dist ) * coefficient;
}
function project( dist:Number, dx:Number, dy:Number ) : Object {
var theta:Number = Math.atan2( dy, dx );
var magnitude:Number = offset( dist );
return { x:Math.cos( theta ) * magnitude, y:Math.sin( theta ) * magnitude };
}
ball.vy = 0;
function run() : Void {
var forceX:Number = 0;
var forceY:Number = GRAVITY;
var dx:Number = magnet._x - ball._x;
var dy:Number = magnet._y - ball._y;
var dist:Number = distance( dx, dy );
if( dist < magnet_radius ) {
var projection:Object = project( dist, dx, dy );
forceX -= projection.x;
forceY -= projection.y;
}
ball.vx += forceX;
ball.vy += forceY;
ball._x += ball.vx;
ball._y += ball.vy;
}
function returnBall() : MovieClip {
return ball;
}
For this code there are 2 objects. Ball and Magnet
Id like this code to be applied to multiple objects. Ball1, Ball2, Ball3 and Magnet1, Magnet2, Magnet3
Any easy way to do this?
Applying Code To A Mc With Attachmovie
Alright, well i applied this code in frame one:
Code:
stop();
_root.attachMovie("char","character",200);
_root.character._x = 150;
_root.character._y = 150;
however, i want to apply this code to the mc:
Code:
onClipEvent(enterFrame){
if(Key.isDown(38)){
this.gotoAndStop("up");
this._y = this._y - 5;
}
if(Key.isDown(87)){
this.gotoAndStop("up");
this._y = this._y - 5;
}
if(Key.isDown(40)){
this.gotoAndStop("down");
this._y = this._y + 5;
}
if(Key.isDown(83)){
this.gotoAndStop("down");
this._y = this._y + 5;
}
if(Key.isDown(37)){
this.gotoAndStop("left");
this._x = this._x - 5;
}
if(Key.isDown(65)){
this.gotoAndStop("left");
this._x = this._x - 5;
}
if(Key.isDown(68)){
this.gotoAndStop("right");
this._x = this._x + 5;
}
if(Key.isDown(39)){
this.gotoAndStop("right");
this._x = this._x + 5;
}
}
how do i apply this code to the MC with attach movie? Do I have to use a function?
|