[CS3] Multiple Functions
I'm trying to create two cards that flip when you click them. It works when I have only one 'Card' function but copied the code and named it CardTwo it tells me: 1120: Access of undefined property loader_mc. I realise that you can't duplicate functions but I don't think I am. I've also tried changing 'CardTwo's' types to 'typeTwo' as well as change loader_mc to loader2_mc. Please help.
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Card extends MovieClip
{
private var _type:*;
public function Card()
{
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(event:MouseEvent):void
{
this.play();
}
public function setType(type:*):void
{
_type = type;
loader_mc.addChild(_type);
}
}
public class CardTwo extends MovieClip
{
private var _type:*;
public function CardTwo()
{
this.buttonMode = true;
this.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(event:MouseEvent):void
{
this.play();
}
public function setType(type:*):void
{
_type = type;
loader_mc.addChild(_type);
}
}
}
FlashKit > Flash Help > Flash Newbies
Posted on: 12-13-2008, 01:09 PM
View Complete Forum Thread with Replies
Sponsored Links:
Help With Multiple Functions
Hello again Im using Flah MX.
The effect Im trying to duplicate can be found here
http://www.thisislondonclub.com
I want to create the same sort of roller images (only vertical)
I can get one image to work and move about the stage but not multiple images.
This is what I have:
Actionscript for the function:
Code:
function moveArrow(Xcoord){
this.onEnterFrame=function(){
picone._y+=(Xcoord-picone._y)/10;
}
}
stop();
Action for the button:
Code:
on(press){
moveArrow(59.6);
}
I tried copying the code and just renameing the function but it wont go.
Can any body help me ?
Thanks in advance
Bill
View Replies !
View Related
Multiple Functions?
Hi
I want to have a btn that loads an image into a picHolder.
I but also want that btn to load a dynamic TextField which is linked to an external txt document at the same time.
Is it possible for this one btn to call multiples functions?
What script do i use?
Many Thanks
View Replies !
View Related
Multiple Functions...
Hi there everyone, I've got another one for you guys...
Still a bit of a noob and am trying to figure out the best way to do this.
I am going to try and explain this as concisely as I can...
I have my main timeline with 7 buttons on it. When clicked, each button shows a different piece of information. I want to be able to click a button and a curtain comes across covering what is already there, then depending on what button is pressed, the right information is displayed underneath the curtain, and then the curtain moves away revealing the new information.
I have spent a long time deliberating at the best way to achieve this, I thought about dynamically adding the second curtain to cover things up using the addChild, but could not figure out this way, I thought about then adding the information using the URLLoader class but then this would mean 7 extra external files, which I don't want etc..
I now think that the best way to do this is to have a 3 frame timeline. The first frame has movieclip with the curtain coming across. The second frame has a movieclip with 7 frames in it that represents each piece of information. The final frame has a movieclip with the curtain moving away again and a stop action.
so i need to...
ActionScript Code:
button01_btn.addEventListener(Event:MouseEvent, button01execute);
function button01execute(myevent:MouseEvent):void {
//play first movieclip
//on complete of first movieclip (or when a particular frame label is reached in first movieclip) go to frame 2
//in frame 2, move the playhead of the movieclip with the info in to the right place
//then go to frame 3 where the moving-away-curtain will play for itself and the stop action will stop the playhead.
}
did that make sense? so I will have a bit of code that looks like that for each button... or is there a way so that i can make one piece of code for all the buttons which will be able to change the loaded info depending on the button?
I hope that someone can help me, please.
Thank you all for hopefully taking the time to read this, much appreciated!
View Replies !
View Related
Multiple Functions
Can you use multiple "unnamed" functions in MX situated on the first frame???
This code seems to be ok but for x reason only the code for the web button works... anybody's got a clue as to why the design button function doesn't work? And I've already checked and doublechecked that the naming of my different objects are correct, so that's not it.
Here's my code:
Code:
stop();
/* stop the hand cursor from working*/
btnPortfolio.useHandCursor = false;
_root.portfolioRoot.btnWeb.useHandCursor = false;
_root.portfolioRoot.btnDesign.useHandCursor = false;
/*-----------------------------------*/
/*portfolio button function*/
btnPortfolio.onPress = function() {
if (_root.portfolioPressed == 0){
_root.portfolioRoot.gotoAndPlay(2);
}
if (_root.portfolioPressed == 1){
_root.portfolioRoot.gotoAndPlay(12);
}
};
/*----------------------------------*/
/*web button function*/
_root.portfolioRoot.btnWeb.onPress = function () {
if (_root.webPressed == 0) {
_root.portfolioRoot.menuWeb.gotoAndPlay (2);
}
if (_root.webPressed == 1) {
_root.portfolioRoot.menuWeb.gotoAndPlay (15);
}
};
/*----------------------------------*/
/*Design button function*/
_root.portfolioRoot.btnDesign.onPress = function () {
//trace (popo);
if (_root.designPressed == 0) {
_root.portfolioRoot.menuDesign.gotoAndPlay (2);
}
if (_root.designPressed == 1) {
_root.portfolioRoot.menuDesign.gotoAndPlay (15);
}
};
/*----------------------------------*/
Is everything ok or am I dumb???
View Replies !
View Related
Multiple Functions In One Button...can You Do It?
I have a button in my host movie that is supposed to call a function of another SWF file. When you press the button, it should go to Next Scene. It works fine with this code:
on (release) {
_level14.direction = "forward";
_level14.jumpScene();
}
I have the function placed at the first frame of each scene of the movie I have loaded at level14 with this code:
function jumpScene () {
if (_level14.direction == "forward") {
nextScene ();
//this is for a similar button I also have in host to goto PrevScene
} else {
if (_level14.direction == "back") {
prevScene ();
}
}
}
Now, my problem is that I have many other movies loaded at levels6-13 as well. I've gone into those movies and appropriately written in their level # into the function. But I cant figure out how to call up more than one function at the release of ONE mouse. Here's what I've tried for 2 movies at once:
on (release) {
if (_level14.direction == "forward") {
_level14.jumpScene();
} else {
if (_level13.direction == "forward") {
_level13.jumpScene();
}
}
}
I've also tried this:
on (release) {
_level14.direction == "forward";
_level14.jumpScene();
_level13.direction == "forward";
_level13.jumpScene();
}
What am I doing wrong? How do I make a button play more than one function, depending on which one it is (or where it is in this case)?
Thanks in advanced for any help.
--Darcie
View Replies !
View Related
Button Does Multiple Functions. WHY?
My buttons are doing more than the Action Script asks them to do and I need to know why and how to fix it.
Here's the scenario:
I have created an MC that sits on my main timeline. Within that MC are four buttons. When a button is clicked, it should take me to a specific frame. Here is the script on the first button:
on (release) {
gotoAndPlay(93);
}
The code on all buttons is exactly the same with the only change being the frame number it's asked to go play.
I also have an Actions layer. Each frame a button sends you to has a STOP action on this layer. For example, Frame 93 on my Actions layer has a STOP action.
The buttons work exactly as I need them to - sort of - If the buttons are only clicked once, and not again until another button has been clicked, I'm fine, there is no problem. The problem comes if you click the same button twice in a row. What happens is this. If I click button #1, one time, I'm taken to frame 93 as wanted. If I click it again, I'm taken to frame 99, which is where button two should take me. Clicking it a third time, takes me back to frame 93.
If I had only clicked button #1 once (taking me to frame 93) then clicked on button #2, it would take me to frame 99 as wanted. However, if I had clicked on button #1 twice, before clicking on button #2, a single click on button #2, would take me to frame 105, which is where button #3 should take me. This problem happens with all 4 buttons.
I hope this is easy to understand, but I can't figure out whats wrong.
Any ideas?
Thanks in advance.
View Replies !
View Related
One Button, Multiple Functions
I was wondering if anyone knew of a tutorial explaning how to code a button to preform multiple functions. I am useing simple forward and back buttons to call swf's to an empty movie clip on my stage. It's something like a swf slideshow with buttons resembling a music player. I have over 50 swf "slides" I need the users to be able to thumb through. Any Help out there?
View Replies !
View Related
Functions For Multiple Objects
I was wondering how I could give multiple object the same actions/functions. I think I may need to learn more about OOP and prototypes. As a small test I have just made a few balls all with the same actions just with different speeds.
Thanks.
View Replies !
View Related
Adressing Multiple MC's With Functions.
Hi,
I can post the .fla if you want, but id thought id explain it all first.
Im making a wierd little project with a strange flower that looks crazed and does different stuff.
One of the things it does is have moving petals, i created a random movement code that worked perfectly when applied to each petalMC (i have multiple copies of the MC containing the MC with the code attached so it works on every single one.) But now, i want it to do different things according to different events, and the only way i can see is to use lots of variables at the _root level and LOTS of 'if' checks in the movieclips, which would eat up some system speed.
I tried setting a function with the different actions i want, and applying that to the petalMC from the root level, but for some reason now it only applies to one of the petals, instead of every petal (which it should, because its adressing the MC inside the copies, so every copy should act the same?)
Any idea of how to adress those multiple petals without using lots of check statements or arrays and complicated names,
Thanks for your time,
Alex
EDIT : Oh well, ill add it anyway
View Replies !
View Related
Multiple Functions For 1 Button
Mx2004
Attached is a sample for editing in MX. I am trying to push the button once have it point north, push the button again and have it point east, push it again and have it point south and push it again and have it point west. push it again and it start all over again.
I thought an "if and then statement" would be best, but that didn't pan out. stumped for the time being.
thanks
View Replies !
View Related
Multiple OnRelease Functions?
I'm still very new to action script so please forgive me this question makes no sense. Not sure if I'm describing the problem correctly. Basically, I have a Movie-clip button that plays another nested movie-clip when it is clicked. How would I go about and play the same nested movie clip at a different point in it's time line the second time it is clicked. Can I use an onRelease event handler twice or should I use a listener to detect the mouse click?
Anyway I hope what I'm going after makes some sense. I posted the FLA for reference (for some reason I couldnt atach the file through the forum) so here it is on my idisk--> http://homepage.mac.com/jasoninch/.Public/face.fla.zip . I also included the link that originally inspired me -->http://www.pspartgallery.com/
Basically I would like the "face2" to reset itself back to "original" face after it has been clicked the second time. As it stands now I can only achieve this with an onRollout event.
Any help or reference would be awsome.
Thanks, j
View Replies !
View Related
[F8] Multiple OnEnterFrame Functions
Okay, so if I add a onEnterFrame function....
mc.onEnterFrame = function()
{//code}
Then try to add another onEnterFrame function...
mc.onEnterFrame = function()
{//new code}
Flash deletes the first onEnterFrame function. Is there any way to stop Flash from doing this? Can I name, and thus reference the onEnterFrame functions differently?
Thanks for the help,
Halcyon
View Replies !
View Related
[F8] Multiple Functions For AttachMovie
Hi everyone,
I have a movie that runs 30 slides full screen continuously, no buttons.
Each slide is to have a different pan or zoom effect to make the slideshow a bit more interesting. Each slide fades in above the other.
I am just learning Actionscript, and I would like to stick to the Best Practices of coding. I have this so far on a test file:
-----------------------------
//FUNCTIONS
function fadeIn() {
this._alpha += 2;
if (this._alpha<=0) {
this._alpha = 0;
this.onEnterFrame = null;
}
}
//this event will make the MC move
function panLeft() {
this.onEnterFrame = function() {
//move the MC 1 pixels at a time
this._x += 1;
}
}
this.attachMovie("pic1", "pic1", getNextHighestDepth, _alpha=100)
this.onEnterFrame = (panLeft);
-------------------------------
I would like to add the fadeIn function to the panLeft function, but so far I've only been able to do one OR the other. I'm going this root so I can mix and match effects to the different slides easily, based on the whims of the client.
A nudge in the right direction would be appreciated. Thank you all for your time!
View Replies !
View Related
AS3 - Calling Multiple Functions
Still very new to all this and feeling a bit lost.
I have successfully created several functions (changerow1, changerow2 etc) and assigned them to associated buttons.
I now want to make some buttons that call several of the functions.
I had hoped that the following would work on my button named randomq:
PHP Code:
randomq.addEventListener(MouseEvent.CLICK, (changerow1),(changerow2))
it didn't so I tried making a new function:
PHP Code:
randomq.addEventListener(MouseEvent.CLICK, combinedfunction);
function combinedfunction(event:MouseEvent):void {
(changerow1), (changerow2)
}
I'm sure there is a straightforward solution, but despite considerable searching I cannot find it. Guidance would be gratefully received.
View Replies !
View Related
Multiple Button Functions
i'm making a game, and i'm currently working on the inventory part.
i've got lots of MCs on the screen with instnace names as:
slot0
slot1
slot2
etc.
what i want to do is make it so that on each MC, when hovering over, it goes to frame 2, and when pressed, it goes to frame 3.
i also want to make it so only 1 of the slot MCs can be on frame 3 at a time.
basically, i want to show that it's selected.
i currently have this code on the main timeline for the selection:
code: function itemRelease() {
selecteditem = this.num;
if (this._currentframe == 3){
}
else{
this.gotoAndStop(3);
}
}
function itemOver() {
if (this._currentframe == 3){
}
else{
this.gotoAndStop(2);
}
}
function itemOut() {
if (this._currentframe == 3){
}
else{
this. gotoAndStop(1);
}
}
and on the slot MC, this code:
code: on(rollOver) {
_root.itemOver();
}
on(rollOut) {
_root.itemOut();
}
on(release) {
_root.itemRelease();
}
on the functions, the 'this' part doesn't work, as it's assuming that 'this' means the root as the function was made in the root.
do you know how i can fix this?
also, do you know how i could stop mutliple slots being on frame 3?
thanks,
hucki
View Replies !
View Related
One Button, Multiple Functions
Hi,
I need some help. I can’t figure this out to save my life!
Here’s the deal: I’ve got one button (portfolio_btn) and when you click on it a movie clip of a navigation bar (mc_RightNav) flies out onto the stag. (I’ve got this part working). Next what I want to have happen is if the user clicks on that same button again (portfolio_btn) I want the navigation to fly back off the stage. Is this possible? Below is the script that I’m working with right now. Please some tell me what I’m missing or if there’s another way of doing this. Thanks, in advance!
import fl.transitions.Tween;
import fl.transitions.easing.*;
var tweenDirection:String = "out";
var inTween:Tween;
var outTween:Tween;
mcLeftNav.portfolio_btn.addEventListener(MouseEven t.CLICK, rightNavOut);
mcLeftNav.portfolio_btn.addEventListener(MouseEven t.CLICK, rightNavIn);
function rightNavOut(event:MouseEvent):void
{
outTween = new Tween(mcRightNav,"x",None.easeNone,553,800,.3,true );
}
function rightNavIn(event:MouseEvent):void
{
inTween = new Tween(mcRightNav,"x",None.easeNone,800,553,.3,true );
}
Right now my navigation bar (mc_RightNav) flies in but when I hit the button (portfolio_btn) a second time it just flies in again and I want it to fly out. Any thoughts???
View Replies !
View Related
Multiple Buttons And Functions
Hey there,
I'm in the process of making an interactive family tree. Each of the members in the tree is a button, and when you click on it information and a picture is dynamically loaded into a panel to the side of the tree. To avoid writing a function for each of the buttons (there's about 30 of them) what is the best way of tackling this problem? Is it possible to write a function that will act on behalf of all the buttons, and load the relevant information depending on which button has been pressed.
Quote:
zoomMC.tree.btn1.onRelease = function(){
path = "infotext/";
myData = new LoadVars();
myData.onLoad = function() {
infoPanel.infoBox.text = this.infotext;
}
myData.load(path+info[0]);
}
'info' is the name of an array that stores all the text file names. As you can see this is the code for just one button, 'btn1'.
View Replies !
View Related
Multiple Functions - One Event
Hi, a very simple one here, I found the documentation but I find it difficult without examples of real scenarios. I have two functions and would like both to fire at the click of one button. I cant just merge the functions.
The two functions are drawRoute and getDistance
The listener:
ActionScript Code:
go_btn.addEventListener("click", get_distance);
Thank you
View Replies !
View Related
SetInterval For Multiple Functions - Help
OK -
I want to control a series of functions/events from the one frame, all in AS.
I can get one to work, but as soon as I use setInterval more than once, it stuffs it up!!
Any suggestions on an easy, straightforward way to run a timeline via one frame in script?
Code:
stop();
import mx.transitions.Tween;
import mx.transitions.easing.*;
var alphaFade:Tween;
//Fade car & A1 in...
alphaFade = new Tween(a1_mc, "_alpha", Strong.easeOut, 0, 100, 5, true);
alphaFade = new Tween(car_mc, "_alpha", Strong.easeOut, 0, 100, 5, true);
//Fade text 1 in...
secondFunction = function(){
alphaFade = new Tween(text1_mc, "_alpha", Strong.easeOut, 0, 100, 5, true);
clearInterval(myInterval1);
}
var myInterval1 = setInterval(this,"secondFunction", 2000);
//Fade text 1 out...
thirdFunction = function(){
alphaFade2 = new Tween(text1_mc, "_alpha", Strong.easeOut, 100, 0, 5, true);
clearInterval(myInterval2);
}
var myInterval2 = setInterval(this,"thirdFunction", 2000);
View Replies !
View Related
Multiple Eventlisteners And Functions
Hey, folks.
I just have this code with dozens of buttons, end each one of the has a eventlistener that triggers a video.
I manage do get it working doing the "dumb-way" writing dozens of lines each one of them adding the listerner to the buttom and doing the very same thing with the functions (dozens of them)
I was wondering if there's a more elegant way (i guess using arrays and forloops) to do this instead of:
Code:
_01.addEventListener(MouseEvent.CLICK, onClick01);
...up to...
_30.addEventListener(MouseEvent.CLICK, onClick30);
...and then....
function onClick01(event:MousEvent):void {
do stuff here
}
...up to...
function onClick30(event:MouseEvent):void {
do stuff
}
View Replies !
View Related
Buttons - Multiple Functions Help
hi,
just started having a go at flash, and have got stuck...
basically i want a button to open another scene, but first, play a movie clip.
so, something like....
on (release) {
play movie
then
gotoAndPlay("scene 2", 1);
i just have no idea how to put that in correct actionscript
thanks for your help!!
Tom
View Replies !
View Related
Help With Multiple Wait(); Functions
I have a short sel-running demo with a "proceed" button but want to have the demo proceed on its own if the proceed button isnt clicked. I have this on the first frame -
stop();
function wait1() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 11*1000); // stop for 11 seconds
}
function wait2() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 11*1000); // stop for 11 seconds
}
function wait3() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 17*1000); // stop for 17 seconds
}
function wait4() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 10*1000); // stop for 10 seconds
}
function wait5() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 14*1000); // stop for 14 seconds
}
function wait6() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 12*1000); // stop for 12 seconds
}
function wait7() {
stop();
var myInterval = setInterval(function () {
play();
clearInterval(myInterval);
}, 25*1000); // stop for 25 seconds
}
-------
and on the timeline throughout "wait1();" "wait2();" etc..
the wait(); functions arent "behaving" the first and second seem to wait the corrct amount of time, but then some dont stop, and others dont follow the set ammount of time. Can anyone give me any suggestions? Im a newb.
View Replies !
View Related
Multiple OnEnterFrame Functions
I have a series of functions that i want to add to a movie clip through the OnEnterFrame command, however i cant get more than one to run at the same time. Is it possible to have more than one going when u are dynamically creating them?
Thanks
View Replies !
View Related
Button Have Multiple Functions? On And Off?
Hey all,
I have two simple buttons on my movie clip ('ON' and 'OFF') that when clicked, change the ._visible state of the movie clip. Thing is, I only want ONE button to turn it on and off. Is this possible?
Basically, I would need an if statement or something...like
on (release)
{
if (movieclip is visible)
{ turn visible to false;}
else
{ turn visible to true;}
}
something like that is what I want to do. All code for the same button.
Any help?
Thanks!
Q
View Replies !
View Related
Multiple Functions On A Button
Hi i am trying to do my website and i liked the "blue Jay menu easing effect" , i readjusted the code and the graph to make it go scrolling vertically up and down on the stage. Basically by clicking the buttons a long pic will go up and down and stop with an easing effect. My problem is that i want external movie clips with my pictures load into a specific target on the main , if i am pressing a button i want my main clip to go to his spot an then load the external movie, and then when i press another button the movie already loaded has to stay in his position and roll up or down.I know it's very confusing and since i am a beginner i maybe trying to do something that is out of mu league but if anyone can help it would be great.
Also my english is no so good so i am not sure if i expressed myself properly.
I'll post the Fla and the external(box)
gammacurta.com/movie.zip
Thanks a lot
Massimo
View Replies !
View Related
Button With Multiple Functions
hi guys, ive only started to use flash not so long ago for school so ive a question.
i was wondering if its possible to have more than one function on a button, however the functions have to work one after another. for example if i want the button to play the rest of the frames in "scene 1" and after playing all the frames in "scene 1" i want it to gotoandplay "scene 3".
i tried:
on (release) {
play();
gotoAndPlay("scene 3", 1);
}
but it didnt work lol
thanks in advance
View Replies !
View Related
Help - Multiple Functions From For... Loops
hey guys...
i was hoping you could help me with this next one, iv'e been dancing around it for a while and i have a feeling that the answer is pretty simple.
let's just say that I have 10 buttons which i want to create eventhandlers to
and that i want to loop through a number to create these functions for these buttons and to make stuff easier on myself.
ex.
var i:int = new int();
for (i=1;i<=10;i++)
{
this["button"+i].buttonMode=true;
}
like that... (that's turning out ok)
but my question is, how do i do the same with functions and eventlisteners.
ex.
var i:int = new int();
for (i=1;i<=10;i++)
{
this["button"+i].buttonMode=true;
this["button"+i].addEventListener(MouseEvent.CLICK,this["button"+i+"handler"]);
function this["button"+i](Evt:Event):void
{
this["button"+i].gotoAndPlay("a");
}
}
because that doesn't work
is there a way to create functions and eventlisteners like that? whats that even called? - i don't even know how to name my problem... i know it might sound noobish to some of you, but i could really use some help.
Eldad
View Replies !
View Related
How To Run Multiple Functions Simultanously?
Thanks to b3n, I figured out a way to slowly reveal a missile trajectory using a mask.
In my script, you can fire a missile using a onMouseDown event, which calls a function which creates a movie for the missile trajectory and the mask, and contains an onEnterFrame function that moves the mask.
However, if I want to fire a new missile before the old one has "landed" and the function completed, the old mask stops in its tracks.
The old missile's movie and the mask are still there, but the onEnterFrame function (which moves the mask) seems to quit rnning when the function is called again.
This happens even if I make a copy of the function with a different name, and call it instead -- calling the new function stops the old one in its tracks, it seems ... it's as if I'm missing something obvious ...
How best to get around this?
Here's the code:
Code:
nukeCount = 0; //number of nukes we have fired
fireNuke = function (originX,originY,targetX,targetY,peakX,peakY,nukeCount) { //function to draw missile path and explosion
// Draw the Missile Path as a movie
this.createEmptyMovieClip("aLine"+nukeCount, this.getNextHighestDepth());
this["aLine"+nukeCount]._alpha=0;
this["aLine"+nukeCount].lineStyle( 1, 0xDDEEFF, 100 );
this["aLine"+nukeCount].moveTo(originX, originY);
this["aLine"+nukeCount].curveTo(peakX,peakY,targetX,targetY);
//Draw a blank movie as a mask to hide the missile path (revealing it slowly)
this.createEmptyMovieClip("aMask"+nukeCount, this.getNextHighestDepth());
distanceToTravel = targetX-originX;
this["aMask"+nukeCount]._x = originX-distanceToTravel;
this["aMask"+nukeCount]._y = 0;
this["aMask"+nukeCount].beginFill(0x000000,00);
this["aMask"+nukeCount].moveTo(0,0);
this["aMask"+nukeCount].lineTo(distanceToTravel+10,0);
this["aMask"+nukeCount].lineTo(distanceToTravel+10,600);
this["aMask"+nukeCount].lineTo(0,600);
this["aMask"+nukeCount].lineTo(0,0);
this["aMask"+nukeCount].endFill;
this["aLine"+nukeCount].setMask(this["aMask"+nukeCount]); //set the mask
//A movie that draws a circle, to represent a nuclear explosion. Starts with zero alpha, "going off" after mask reveals whole path.
createEmptyMovieClip("explosion"+nukeCount, this.getNextHighestDepth());
this["explosion"+nukeCount]._x=targetX;
this["explosion"+nukeCount]._y=targetY;
this["explosion"+nukeCount]._alpha=0;
// center point and radius of circle
var r:Number = 6;
var x:Number = 0;
var y:Number = 0;
// constant used in calculation
var A:Number = Math.tan(22.5 * Math.PI/180);
// variables for each of 8 segments
var endx:Number;
var endy:Number;
var cx:Number;
var cy:Number;
this["explosion"+nukeCount].beginFill(0xDDFFFF,75)
this["explosion"+nukeCount].moveTo(x+r, y);
for (var angle:Number = 45; angle<=360; angle += 45) {
// endpoint
endx = r*Math.cos(angle*Math.PI/180);
endy = r*Math.sin(angle*Math.PI/180);
// control:
// (angle-90 is used to give the correct sign)
cx =endx + r* A *Math.cos((angle-90)*Math.PI/180);
cy =endy + r* A *Math.sin((angle-90)*Math.PI/180);
this["explosion"+nukeCount].curveTo(cx+x, cy+y, endx+x, endy+y);
}
this["explosion"+nukeCount].endFill();
//uncover the missile path
i=0; //percentage of missile path revealed
this.onEnterFrame = function () {
i++;
if (i<20) {
this["aLine"+nukeCount]._alpha +=5; //fading in the missile path
}
if (i<100) {
this["aMask"+nukeCount]._x = originX-distanceToTravel + ((distanceToTravel/100)*i); //Move the mask right to reveal missile path
}
else {
this["aLine"+nukeCount].setMask(null); //remove the mask completely
this.onEnterFrame = function () { //uncover the explosion
this["explosion"+nukeCount]._alpha+=10;
}
}
}
}
this.onMouseDown = function () {
nukeCount++;
fireNuke(random(100),random(100)+200,random(100)+400,random(100)+150,250,10,nukeCount);
}
View Replies !
View Related
Functions And Multiple Event Handlers
Can anyone tell me if it is possible to assign a function to a button, to be triggered by two or more event handlers, but using the post Flash 5 syntax eg.
Where you once could once directly add the following:
on (release,releaseOutside) {
//do something
}
You can now write (but with one event only):
mybutton.onPress = function() {
//do something
}
Is there a syntax to avoid having to add the same function to each event?
View Replies !
View Related
One Click Multiple Functions? Aaargh
i really need to learn how to do this...
here it is
lets say i want to do three things with one click on a movie clip.
1/ _alpha=50;
2/ gotoAndStop ("test");
3/ and maybe _y=something or other.
what would i write??
on (press){
???
}
i am so stuck.
i'm guessing i should create a function that''l do it...but how in the heck...ahhh i'm frustrated.
please someone help me out with this!
jt
View Replies !
View Related
Posting Functions On Multiple Buttons
I know this is probably the most basic thing in the world and yet i can't figure it out - I have thirty thumbnails and I want to assign a function to each of them that brings up a specific image. I made an array with a loop that created all of the thumbnail names (thm1, thm2, etc.) but when it came time to actually apply these names to an onRelease call I had no idea to do it. Is there an easy way to do this and make a button (thm1) specific to an image (img1.jpg). Please help. Thank you.
View Replies !
View Related
Assigning Multiple Functions To A Mousebutton
Basicly, I have a button which forms part of a mc called window1. When the button is released, it must move the "window1" mc (and itself, as it is attached to window1) from _x=0 to _x=300. When pressed again, it must return window1 from _x=300 to _x=0, thereby emulating a expand/contract effect.
Any takers?
Thanks,
-fabman
View Replies !
View Related
Multiple Paramaters In Functions Get Them To Work... Help..
Hi guys me again... One last cry for help..
Ok what i'm basicly trying to do is write a function where i can populate several vars at once by hitting a button... my data is coming from an array ported from xml.. the areas in my array are sectional array.
Inspire
Create
Play
and the attributes attached to these
sourcedir
Artist
Etc etc..
so to trace one bit of the bits of information you would call this array code..
trace (createArtist[1]);
this would display
Andrew Newman
So what i'm basicly doing it trying to make the process easier now i'm no action script wizz more of a designer... so i'm wondering how i can get the following bit of code to work.
the sName needs to be an parameter which i can define..
and the same with the sPos..
i'm ov not coding the thing right cause it's coming up undefined when i trace the values..
i'm really confused... can anyone help me???
Code:
//** AREA POPULATION **//
function populateCONTENT(sName:String,sPos:Number):Void;
_root.playMovie = sNamesourcedir[sPos]
_root.artistName = sNameArtist[sPos]
_root.medium = sNameMedium[sPos]
_root.about = sNameAbout[sPos]
_root.project = sNameProject[sPos]
}
trace("video file = "+sNamesourcedir[sPos])
trace("artist name = "+sNameArtist[sPos])
trace("medium = "+sNameMedium[sPos])
trace("about = "+sNameAbout[sPos])
trace("project = "+sNameProject[sPos])
};
//Function Called..
populateCONTENT(sName=Inspire,sPos=3);
View Replies !
View Related
Multiple Rollover Functions On A Single Mc
Hi
I don't know whether this is possible, but can you have two rollover functions on a single mc. For example I have a mc which i want to add a tool tip and then change the colour. I originally had this all in one rollover function but i want to split them as i'd like to reuse the tool tip function for another mc that does not need to change colour.
I've had a search around the forum and internet but couldn't find anything. I'm not sure its even possible, but thought id ask
Thanks
View Replies !
View Related
Multiple OnEnterFrame Functions Stall - LIL HELP?
Hey All,
I've searched this quite a bit and can't seem to find an alternative.
I'm trying to run multiple onEnterFrame functions by using and "if" conditional in one to trigger the next.
Something like.....
onEnterFrame = function () {
various tween like actionscript statements;
if(some condition in the middle of this animation){
someNewFunction();
}
}
function someNewFunction() {
onEnterFrame = function () {
various tween like actionscript statements;
}
}
The result is that when someNewFunction() is called based on conditions met in the first onEnterFrame a second onEnterFrame function [within someNewFunction()] is called and they both stall.
I have created a work around in which all the statements I was going to run in the second onEnterFrame [within someNewFunction()] now fall in the "if" statement of the first.
But I'm thinking there is a better way.
Any help would be Greatly Appreciated!!!!!
jub
View Replies !
View Related
Problem With Multiple OnPress Functions
i'm a bit of a noob using functions, so i need some help. i've got an MC that contains several buttons and depending on where you are in the project, the buttons do different things.
For instance: in frame 1, button_X does ABC. But in frame 10, button_X needs to do XYZ. So, i'm wiring up my button actions using the following code in their respective frames:
Code:
this.remote_mc.button1.onPress = function () {
perform action ABC;
}
So, in frame 10, the same button needs to perform a different action. So, in that frame, I use the same code as above, just changing the action. However, the button won't let go of the original function. It's like my newly defined function doesn't even exist. What am I doing wrong? (proabably a lot!)
thanks for any help-
View Replies !
View Related
Multiple Paramaters In Functions Get Them To Work... Help..
Hi guys me again... One last cry for help..
Ok what i'm basicly trying to do is write a function where i can populate several vars at once by hitting a button... my data is coming from an array ported from xml.. the areas in my array are sectional array.
Inspire
Create
Play
and the attributes attached to these
sourcedir
Artist
Etc etc..
so to trace one bit of the bits of information you would call this array code..
trace (createArtist[1]);
this would display
Andrew Newman
So what i'm basicly doing it trying to make the process easier now i'm no action script wizz more of a designer... so i'm wondering how i can get the following bit of code to work.
the sName needs to be an parameter which i can define..
and the same with the sPos..
i'm ov not coding the thing right cause it's coming up undefined when i trace the values..
i'm really confused... can anyone help me???
Code:
//** AREA POPULATION **//
function populateCONTENT(sName:String,sPos:Number):Void {
_root.playMovie = sNamesourcedir[sPos]
_root.artistName = sNameArtist[sPos]
_root.medium = sNameMedium[sPos]
_root.about = sNameAbout[sPos]
_root.project = sNameProject[sPos]
}
trace("video file = "+sNamesourcedir[sPos])
trace("artist name = "+sNameArtist[sPos])
trace("medium = "+sNameMedium[sPos])
trace("about = "+sNameAbout[sPos])
trace("project = "+sNameProject[sPos])
//Function Called..
populateCONTENT(Inspire,3);
View Replies !
View Related
Multiple Functions Will Not Work Onrelease
Hello! I'm trying to put a portfolio together. I've got all the links working except I thought it would be a good idea to use the component loader to show the pictures. When I click on the button "biaalfa", i set a frame action to go to frame 41 or frame "iaalfa". Flash does this fine, but the pic "Aa1.jpg" that my loader is supposed to load, does not until I click on the button a second time. What am I doing wrong? Thanks.
this.biaalfa.onRelease = function() {
myLoader.contentPath = "Aa1.jpg";
gotoAndStop("iaalfa");
}
View Replies !
View Related
Button To Perform Multiple Functions
Hello all,
I'm a real newbie when it comes to actionscripting so here goes: I have an issue where I have created a page using flash 8, basically its an order page with two products on it with input boxes for the prices and the quantity of those two products...here's what I'm tryin to do with no luck so far...
Product prices – the user will enter the product prices
Sales tax – based on the user’s location
Shipping cost and arrival time – based on the user’s location
Create a Flash movie that will add two product prices together, sales tax, shipping (including estimated arrival time) and output the total.
Customer locations could be one of these (customer will input location):
California (CA)
Texas (TX)
South Carolina (SC)
Add two product prices (customer will enter price)
Product One Price
Product Two Price
Add sales tax (based on customer location)
California – 8.5%
Texas – 4.5%
South Carolina – 5%
Add shipping cost (based on customer location)
California – $20.00
Texas – $15.00
South Carolina – $10.00
Output total
Output Estimated Arrival Time (based on the current date)
California – takes 5 days to arrive
Texas – takes 3 days to arrive
South Carolina – takes 2 days to arrive
PHEW!!...I have but ONE button on the page to perform all these calculations.
Any help at all with coding this would be VERY much appreciated
Thanks
View Replies !
View Related
AddEventListener & Multiple Javascript Functions
I am using working on a Flex application that is going to use an Ajax Bridge to communicate with the MSAjax Preview javascript library. I am passing in javascript functions as handlers for ActionScript events.
The built-in Ajax Bridge works great. Except that when I call addEventListener and add multiple Javascript functions as a listeners it wont queue multiple callbacks to the same function.
For instance if I call addEventListener multiple times passing in the same javascript call back function, only 1 of them gets added to the event list. (im not familiar with the internals of how eventing is handled in actionscript).
The result is a page where I can click a 'Add Handler' HTML button that sends instances of a javascript function to Flex. When I click a 'Fire Event' it only fires the handler function once, even if I added it 5 times.
Debugging Javascript-Actionscript bridged stuff seems extremely difficult but I put a textArea into the flex app to act as a debug console. I can see that addEventListener is being called 5 times in actionscript.
Has anyone else experienced this or know what I might be doing wrong?
p.s. I'm just curious. After about 2 hours beating my head against the wall, I translated the eventing system in the MSAjax library to actionscript. I can create an instance of eventHandlerList and add my callback functions to it then fire events against that and it works as expected.
View Replies !
View Related
Call Multiple Functions From A Cicle
I'd like to call three function from a cicle for
when I trace "carica" inside my cicle it returns the name of my 3 functions but they don't execute,
where is my mistake?
thx
caricare1 = function() {
trace("function1")
}
caricare2 = function() {
trace("function2")
}
caricare3 = function() {
trace("function3")
}
for (i=1;i<4;i++) {
carica="caricare"+i+"()"
this[carica];
// I tried also with carica instead of this[carica] and with this.carica and with [carica] but nothing // works
trace(carica)
}
View Replies !
View Related
Creating Functions For Multiple Objects
Hi all,
once again with this thumbnail stuff!
I now have 10 thumbnails that are automatically generated via a script like this:
PHP Code:
var dif = 90; //difference in px
for(var i=0;i < 11;++i)
{
var inStep = i+1; //required for proper pic numbering
var myVar = "image" + inStep + ".jpg";
tmp = this._parent.holder1.createEmptyMovieClip("holder"+inStep,i);
tmp.LoadMovie(myVar);
tmp._x = dif*i;
}
So that loads 10 images in a row. Now i need to write a function that evaluates what one is pressed and passes a variable back. The variable thing is easy enough, but I don't know how make just one function that
can be called from any of the clips. I don't want to have to write an onRelease function for each of the clips and was wondering how others did things like this?
All i really need now is some function i can stick in one spot that will just trace the name of the clip that was clicked. Any help appreciated
THANKS
mcm
View Replies !
View Related
Giving A Button Multiple Functions
I'm painfully new to actionscript, and having a hard time finding basic information on get Property and set Property, and I'm not even fully sure either of these variable controllers are what I need...
I have five scenes that relate to a basic menu (Home, About, Menu, etc) , and want an image to fade in and out of the background each time the appropriate page/scene opens. I've set up each image fading in as their own movie clip, and same for each image fading out.
I have no problem in fading the image in (I've set the 'image in' movie clip on the first frame of the destination scene), but have no idea how to fade the image out when I hit a button to go somewhere else. Basically, I don't know how to set a button with both a goTo action AND the needed play action for the 'image out' movie clip to play. And I don't know what that 'needed play action' is either.
I hope this makes sense! Any suggestions are appreciated - I've been hitting my head on the wall for a while now!
View Replies !
View Related
Multiple Functions For A Mouse Event?
I have a button class I've created in AS3 which causes a button to grow and glow during Mouse_Over.
As I have it set up, there are individual Event listeners for expand and glow.
Is there any way to combine those two functions under one event listener, so that I would just have two Event listeners and not four?
Attach Code
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.filters.BitmapFilterQuality;
import flash.filters.GlowFilter;
public class Button extends MovieClip
{
var glow:GlowFilter = new GlowFilter();
public function Button()
{
this.addEventListener(MouseEvent.MOUSE_OVER, expand);
this.addEventListener(MouseEvent.MOUSE_OUT, contract);
this.addEventListener(MouseEvent.MOUSE_OVER, glowOn);
this.addEventListener(MouseEvent.MOUSE_OUT, glowOff);
}
private function expand(event:MouseEvent):void
{
this.scaleX = this.scaleY =1.1;
}
private function contract(event:MouseEvent):void
{
this.scaleX = this.scaleY =1;
}
private function glowOn(event:MouseEvent):void
{
glow.color = 0x009922;
glow.alpha = 1;
glow.blurX = 25;
glow.blurY = 25;
glow.quality = BitmapFilterQuality.MEDIUM;
this.filters = [glow];
}
private function glowOff(event:MouseEvent):void
{
glow.color = 0x009922;
glow.alpha = 0;
glow.blurX = 25;
glow.blurY = 25;
glow.quality = BitmapFilterQuality.MEDIUM;
this.filters = [glow];
}
}
}
View Replies !
View Related
SetMask - Multiple Pictures, Functions
I am trying to make an image scrolling program...I had it so the first image worked fine, the mask did it's job, then after that it didnt. Now I have it so you see the mask but it doesnt mask the images like it is supposed to. I have 4 images [image1_mc,image2_mc,image3_mc,image4_mc] I exported them to actionscript and the first frame....I have a mask that is reveal_mc that is also exported to actionscript and the first frame. The reveal_mc is just a simple rectangle growing from small to big.
Here is my code:
PHP Code:
var imagePosition=2; function dynamicMask(spaceInput,toBeMasked){ //unloadMovie(mask); toBeMasked.setMask(null); mask_mc=this.createEmptyMovieClip("mask", 2); var spacing=0; for(var i=0; i<=5;i++){ mask.attachMovie("reveal_mc","reveal_mc"+i,i); mask["reveal_mc"+i]._y=spacing; spacing+=spaceInput; } toBeMasked.setMask(mask); } //images_mc.attachMovie("image1_mc","image1_mc",2); //dynamicMask(25,images_mc.image1_mc); //imageToBack(images_mc.image1_mc); nextImage(); function imageToBack(mc){ var temp="_level0.test."+mc; var counter=0; this.onEnterFrame=function(){ if(counter==50){ back_mc.attachMovie(temp,temp,1); nextImage(); } counter++; } } function nextImage(){ var temp="_level0.test.images_mc.image"+imagePosition+"_mc"; images_mc.attachMovie("image"+imagePosition+"_mc","image"+imagePosition+"_mc",2); dynamicMask(25,temp); if(imagePosition==4){ imagePosition=1; }else{ imagePosition++; } imageToBack("images_mc.image"+imagePosition+"_mc"); }
I keep track of the imagePosition, because I want it to continuously scroll thru...
The first function is SUPPOSED to make 6 copies of the reveal_mc and place them below each other, which is does that fine, but the part it doesn't work fine is to mask the image....
I call the nextImage(); function to start the whole rotation, I commented off some of the other lines I was trying also
nextImage() is attaching the current image, ex image2_mc [the number is derived from the imagePosition variable], then it sends it to the dynamicMask function for it to mask the image, the if statement is just to make sure it doesn't try to load an image that is not there, and start at 1 once it gets to the end...
Then my idea was the imageToBack(); function. I wanted to take the current loaded image (after it is masked and shown) to go to the back_mc, so when I call up the nextImage it gets tranisitioned on top of the underlying image, the counter in the imageToBack() function acts as a clock, to give it some time before processing.....I also put the back_mc on level 1 and the other stuff one level 2...I have tested and tested and I ran out of ideas, so I HOPE someone can help me out!
Thanks for your help !!
Sincerely,
-TJ
View Replies !
View Related
SetMask - Multiple Pictures, Functions
I am trying to make an image scrolling program...I had it so the first image worked fine, the mask did it's job, then after that it didnt. Now I have it so you see the mask but it doesnt mask the images like it is supposed to. I have 4 images [image1_mc,image2_mc,image3_mc,image4_mc] I exported them to actionscript and the first frame....I have a mask that is reveal_mc that is also exported to actionscript and the first frame. The reveal_mc is just a simple rectangle growing from small to big.
Here is my code:
PHP Code:
var imagePosition=2;
function dynamicMask(spaceInput,toBeMasked){
//unloadMovie(mask);
toBeMasked.setMask(null);
mask_mc=this.createEmptyMovieClip("mask", 2);
var spacing=0;
for(var i=0; i<=5;i++){
mask.attachMovie("reveal_mc","reveal_mc"+i,i);
mask["reveal_mc"+i]._y=spacing;
spacing+=spaceInput;
}
toBeMasked.setMask(mask);
}
//images_mc.attachMovie("image1_mc","image1_mc",2);
//dynamicMask(25,images_mc.image1_mc);
//imageToBack(images_mc.image1_mc);
nextImage();
function imageToBack(mc){
var temp="_level0.test."+mc;
var counter=0;
this.onEnterFrame=function(){
if(counter==50){
back_mc.attachMovie(temp,temp,1);
nextImage();
}
counter++;
}
}
function nextImage(){
var temp="_level0.test.images_mc.image"+imagePosition+"_mc";
images_mc.attachMovie("image"+imagePosition+"_mc","image"+imagePosition+"_mc",2);
dynamicMask(25,temp);
if(imagePosition==4){
imagePosition=1;
}else{
imagePosition++;
}
imageToBack("images_mc.image"+imagePosition+"_mc");
}
I keep track of the imagePosition, because I want it to continuously scroll thru...
The first function is SUPPOSED to make 6 copies of the reveal_mc and place them below each other, which is does that fine, but the part it doesn't work fine is to mask the image....
I call the nextImage(); function to start the whole rotation, I commented off some of the other lines I was trying also
nextImage() is attaching the current image, ex image2_mc [the number is derived from the imagePosition variable], then it sends it to the dynamicMask function for it to mask the image, the if statement is just to make sure it doesn't try to load an image that is not there, and start at 1 once it gets to the end...
Then my idea was the imageToBack(); function. I wanted to take the current loaded image (after it is masked and shown) to go to the back_mc, so when I call up the nextImage it gets tranisitioned on top of the underlying image, the counter in the imageToBack() function acts as a clock, to give it some time before processing.....I also put the back_mc on level 1 and the other stuff one level 2...I have tested and tested and I ran out of ideas, so I HOPE someone can help me out!
Thanks for your help !!
Sincerely,
-TJ
View Replies !
View Related
Assigning Multiple Functions Through Loop
Hello one and all.
I have many buttons on my stage that all need to have a different function assigned to them. Each of these buttons lives within a movieClip. Here is the code i am using:
Code:
for (i = 1; i<88; i++){
myClip["btn"+i].onRelease = function (){
_root.callConst([i]);
}
}
The idea is that there is 88 buttons all called btn1-btn88. And i want to assign code to each of them that results in an onRelease function that calls an external function with a variable that corresponds to its button number.
What is happening now is that code is being corresponed to each button (yay!), but the variable that is being passed by all of them is the final value of "i" (or "88" in this particular case).
What am i missing?
Thanks in advance,
newbie
View Replies !
View Related
Reusing Functions For Multiple Movieclips
Hello,
I'm making a simple drag and drop game where a shape moveclip snaps into the location of the target movieclip. I have the code working for one shape, but I don't know how to write the functions so they can be used for multiple shapes. Please refer to my flash file and code below.
Since I have nested movie clips, evt.target.startDrag doesn't work for the onStartDrag function because then only the bTri1_d movieclip attaches to the mouse, not bTri1 (which encompasses both the drag and rotate clips). Could I somehow access the root of bTri1_d so it knows to grab the whole thing?
The onSnapTo function is also problematic. I know I can pass the x and y values of the shapes and their targets to the function and use them as variables in the code, but then when I have to removeEventListeners how do I pass the actual name of the movieclip that needs modifying? I tried doing it as a string but that backfired.
Thanks,
-gwen
Code:
bTri1.bTri1_d.addEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
bTri1.bTri1_d.addEventListener(MouseEvent.MOUSE_UP, onStopDrag);
bTri1.bTri1_r.addEventListener(MouseEvent.MOUSE_DOWN, onRotate);
function onStartDrag(evt:MouseEvent):void {
bTri1.startDrag();
}
function onStopDrag(evt:MouseEvent):void {
bTri1.stopDrag();
onSnapTo();
}
function onRotate(evt:MouseEvent):void {
bTri1.rotation += 90;
}
function onSnapTo():void {
if ( (Math.abs(bTri1_t.x - bTri1.x) < 15) && (Math.abs(bTri1_t.y - bTri1.y) < 15) ) {
//trace("i'm right here");
bTri1.x = bTri1_t.x;
bTri1.y = bTri1_t.y;
bTri1.bTri1_d.removeEventListener(MouseEvent.MOUSE_DOWN, onStartDrag);
bTri1.bTri1_d.removeEventListener(MouseEvent.MOUSE_UP, onStopDrag);
bTri1.bTri1_r.removeEventListener(MouseEvent.MOUSE_DOWN, onRotate);
} else {
//trace("i'm too far away");
}
}
View Replies !
View Related
|