Can't Animate Background Of Button Class
I've made a class that creates a simple button with a label and background. When I rollover the button the background should tween to a color and that's where it's going wrong. It's probably something simple I'm missing but I can't find it.
The text label does tween correctly, but the background doesn't do anything. It also doesn't give any errors when I test it.
ActionScript Code:
package classes
{
import flash.display.Shape;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import gs.TweenFilterLite;
import gs.easing.Circ;
public class NavButton extends Sprite
{
private var _text:String;
private var _background:Sprite;
private var _label:Sprite;
public function NavButton(textLabel:String)
{
_text = textLabel;
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void
{
buttonMode = true;
mouseChildren = false;
addLabel();
drawBackground();
addEventListener(MouseEvent.ROLL_OVER, onOver);
addEventListener(MouseEvent.ROLL_OUT, onOut);
}
private function onOver(e:MouseEvent):void
{
TweenFilterLite.to(_background, 0.2, {tint: 0xfff59b, ease: Circ.easeOut});
TweenFilterLite.to(_label, 0.2, {tint: 0x333333, ease: Circ.easeOut});
}
private function onOut(e:MouseEvent):void
{
TweenFilterLite.to(_background, 0.3, {tint: null, ease: Circ.easeOut});
TweenFilterLite.to(_label, 0.3, {tint: null, ease: Circ.easeOut});
}
private function addLabel():void
{
_label = new Sprite();
var tf:TextField = new TextField();
tf.autoSize = TextFieldAutoSize.LEFT;
tf.selectable = false;
tf.x = 5;
tf.y = 2;
var format:TextFormat = new TextFormat("Arial", 16, 0xffffff, true);
tf.defaultTextFormat = format;
tf.text = _text;
_label.addChild(tf);
addChild(_label);
}
private function drawBackground():void
{
_background = new Sprite();
var w:Number = _label.width + 10;
var h:Number = 24;
_background.graphics.beginFill(0x333333);
_background.graphics.drawRect(0, 0, w, h);
_background.graphics.endFill();
addChildAt(_background, 0);
}
}
}
ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0
Posted on: 09-15-2008, 12:18 PM
View Complete Forum Thread with Replies
Sponsored Links:
Trying To Animate MC On Stage Using Tweener From Within A Custom Class
Hi,
I'm trying to animate a movieclip on stage using a custom class that uses Tweener. I'm not getting error messages... it just not animating. I've posted the class below... any ideas?
Code:
package {
import flash.display.*;
import flash.events.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.motion.easing.*;
import fl.transitions.TweenEvent;
import caurina.transitions.*;
import ButtonSetup;
public class SceneNavigation extends MovieClip {
private var yIn:Number = -820;
private var yOut:Number = -750;
private var widthIn:Number = 6473;
private var heightIn:Number = 610;
private var widthOut:Number = 5942;
private var heightOut:Number = 560;
private var zOutTime:Number = .3;
private var zBlurTime:Number = .1;
private var zUnblurDelay:Number = .45;
private var moveSpeed:Number = .3;
private var zInTime:Number = .75;
private var posOut:Array = new Array(2442, 1452, 460, -530, -1520, -2521);
private var posIn:Array = new Array(2652, 1514, 450, -617, -1713, -2783);
private var posOutStart:Number = posOut[0];
private var posOutEnd:Number = posOut[1];
private var posInStart:Number = posIn[0];
private var posInEnd:Number = posIn[1];
public var btnClicked;
public function SceneNavigation() {
this.width = widthIn;
this.height = heightIn;
this.x = posIn[0];
this.y = yIn;
}
public function whichWay() {
posOutEnd = posOut[btnClicked];
posInEnd = posIn[btnClicked];
/*if (posOutEnd > posOutStart && btnClicked != 0) {
posOutEnd = posOut[btnClicked]-50;
}*/
nextPage();
}
public function nextPage() {
Tweener.addTween(this, {x:posOutStart, y:yOut, width:widthOut, height:heightOut, time:zOutTime, transition:"easeInQuad"});
Tweener.addTween(this.blurStrip, {delay:zOutTime, time:zBlurTime, alpha:1});
Tweener.addTween(this.blurStrip, {delay:zUnblurDelay, time:zBlurTime, alpha:0});
Tweener.addTween(this, {x:posOutEnd, time:moveSpeed, delay:zOutTime, transition:"easeOutQuad"});
Tweener.addTween(this, {x:posInEnd, y:yIn, width:widthIn, height:heightIn, time:zInTime, delay:(zOutTime*2), transition:"easeOutQuad"});
posInStart = posIn[btnClicked];
posOutStart = posOut[btnClicked];
trace(this);
}
}
}
The nextPage() function is supposed to animate a movieclip on stage. I've traced all the variables and they're values are correct. I've tried using "this.parent" and that didn't work either. This works when used from the main timeline. I've tried using a simple Tweener animation from another class on different object and it works fine there as well... I can't figure out what is wrong with this setup. Any help would be greatly appreciated.
UPDATE:
I'm passing in a value for the btnClicked variable from another class... this could be what's causing the problem. When I call the nextPage() function from the constructor the object does animate. Still not sure what's wrong.
View Replies !
View Related
Animate Movie On Movie - Update Background Without Updating Whole Screen
This has got to be a newbie question, because I remeber this being an issue when I once animated in Flash 3.
I have an animation on top of a big ol jpg background. Each time the animation moves , right now the way things are set up, the entire jpg refreshes (I think, since the animation is so jittery). Is there a way to setup the layers, or movie clips so that only the pixels that are changing replace, while the rest of unchanging background remains stable.
This must be possible in some form because there are many rapidly changing animations I see around that are completely smooth on my screen while my animation is jittery.
You can see my example
HERE: http://www.wjamesphoto.com/suesflipb...sflipbook.html
Thanks for any help
AB
View Replies !
View Related
How To Animate A Button ?
animating a button
Hello. This sounds (to me) so easy that i cant really belive im asking it , anyway here goes.
I have a button already on the stage that when you (release) it, several things happen.
I would like the button itself, when it is (release)d , to move to the right a little bit. So therefore, i want to animate it.
How do i convert it to a movie ? do i need to ?
when i ihave tried to convert to a movie, i cant seem to make it (stop), so on the .swf it just starts running through its different buttons states (flashing and doing all kinds of wickedness)
yes i did a search for this here and to no avail.
help please ! thanks !
View Replies !
View Related
Animate Button
Hi guys,
How can I create a button that when I mouse over the animation play and when I mouse out the animation fade away then it gets back to normal?
I hope you understand my question....
It would be nice if you have a Flash sample.
Thanks,
Bobby.
View Replies !
View Related
How To Animate A Navigation Button
Having trouble posting.. hope this isn't a double post..
Hey!
I am not exactly a newbie, more like a rusty since I have not used Flash in a while.. Have not used this list for ages...either.
Anyway, my client wants me to create a button that will do some "shaking".
I have a button that is actually a steering wheel image with a transparent background(made it in Photoshop).
This steering wheel button is for navigation purposes. What the client wants, is to "animate the steering wheels. when mouseover , they should jiggle, a 1/4 turn to the left, back to center, and then 1/4 turn to the right. this should happen fairly quickly."
I am not sure how to do this. I know how to create a regular button. but not sure how to do the animated one.
Thanks so much in advance!
Daph
View Replies !
View Related
Animate A Movieclip With Button
Hi i have the following code.What i want is the movie clip to move across the stage continuoisley but it moves only 10 pixels each time I press the button I want to press the button opnce and have the clip continue to move.
code:
go.onPress = function(){
myMC._x += 10;
myMC._x ++
}
I thought that would do it but I'm stumped.
Thanks
View Replies !
View Related
How To Get A Button Within A Mc To Make That Mc Animate?
hi, i'm trying to make a button within a mc get the mc it resides in to play on rollover, then play in reverse on rollout.
so i'm using _currentframe +/- to move the frames of the mc forwards or backwards, with the onrollover/out commands on the main timeline with the last frame looping to the previous frame to keep getting the +1 frame increments for the mc.
but this isnt working, anyone know how to do this?
thanks.
View Replies !
View Related
How Do I Animate A OnRollout Of A Button?
Im sure this is simple, but here goes...
I have a button. when you roll over it, it rises up about 20 pixels. (very clean animation. It's actually a _mc i put in the over state of the button.
I want to create the reverse effect when you roll out of the button.
How?
here is a link to see what I mean....
www.zunskigraphics.com/KARIZMA/index.html Click on Home
please help, this has been a stump for me since i started working with flash.
thanks
ZG
View Replies !
View Related
How Do I Animate Button On Mouseover
Hi all,
Newcomer to the forum (but a big user of the tutorials for a while now), and self taught in flash 5, meaning I know enough to build a site in flash, but there are random gaps in my knowledge...
What I'm trying to do is this: I'm building a site where the main page is an illustrated office area, and I'm trying to figure out how to create buttons that when you mouse over them, they play a brief animation (some will animate the actual object moused over, and some will play a brief animation within the illsutration) - as an example... when a monitor is moused over, it will "power up" and play a little intro on the screen, or when the phone is moused over, it will ring and the receiver will lift off the base and shiver, and a head will poke into the office door.
It seems I can either create an animation (which has no mouseover option) or a button, which has limitations... is there a way to script it so that a button will still direct to the next scene on release while playing a brief animation when moused over?
I'm having some problems going about how exactly to lay this out - ANY help would be greatly appreciated!!
Thanks!
View Replies !
View Related
Button Animate After Click
Hi, i am fairly new to actionscripting, ive used it before but only using the simple basic stuff like for simple buttons , but now i have a movie clip button problem.
i dont know if this has been talked about before, i tried searching but all that came up were rollover and rollout stuff, which i dont need anymore.
I am trying to make a movie clip button to animate after a user has clicked on it. I already have the rollover and rollout animations with the actionscript on the actions layer, not the actual mc button. however, i cant figure out how to make it animate after a user clicks on it and moves the mouse away. it will animate after its clicked and the mouse is over the mc button, but as soon as i move the mouse away it stops.
the mc button has all the animations using labels, onrollover goes to 'over', onpress goes to 'down', onrollout goes to 'out', and onrelease goes to 'anim', but like i said only when the mouse is over da button.
*sigh* while i was googling i saw something, but dont remember where, about using onclipevent. the help file is very confusing about how to use this and more searching about this leads to loading movies or something.
please help
View Replies !
View Related
How Do I Animate Button On Mouseover
Hi all,
Newcomer to the forum (but a big user of the tutorials for a while now), and self taught in flash 5, meaning I know enough to build a site in flash, but there are random gaps in my knowledge...
What I'm trying to do is this: I'm building a site where the main page is an illustrated office area, and I'm trying to figure out how to create buttons that when you mouse over them, they play a brief animation (some will animate the actual object moused over, and some will play a brief animation within the illsutration) - as an example... when a monitor is moused over, it will "power up" and play a little intro on the screen, or when the phone is moused over, it will ring and the receiver will lift off the base and shiver, and a head will poke into the office door.
It seems I can either create an animation (which has no mouseover option) or a button, which has limitations... is there a way to script it so that a button will still direct to the next scene on release while playing a brief animation when moused over?
I'm having some problems going about how exactly to lay this out - ANY help would be greatly appreciated!!
Thanks!
View Replies !
View Related
Help Making Button Animate
Hey,
I decided to learn a bit more by attempting stuff, so I uploaded my background and a button for my website, but I want to make the button animated like when you roll over it it makes a noise and it does a cool animation, etc etc. Heres a screenshot of my flash project:
Can anyone guide me through how I would do this so I know from now on and can advance in making my website :)
Thanks alot ;)
View Replies !
View Related
MC As Button Won't Animate After I Add OnPress = Function
I've searched and experimented high and low, but cannot find a solution!
I have a movieclip acting as a button. The idea is to have an external .swf load onto the stage once the movieclip is clicked.
The external swf loads fine, just as expected. However, once I assign the instance name to the movieclip/button and add actionscript to frame one (seen below), the movieclip/button loses all of its animation, defeating the purpose.
Here's the script for frame one:
------------------
gallery.onPress = function() {
_root.createEmptyMovieClip("container", 1);
loadMovie("gallery.swf", "container");
holder._x = 50;
holder._y = 40;
};
------------------
Thanks for any input! One of my guesses is that the "onPress" is turning my movieclip/button into a "button" and losing its animation, but I know of no solutions.
View Replies !
View Related
How Do You Animate A Button On A Motion Path
I need to make an animated button that follows a motion path around the page area on a continuous loop but at present it will not work to go to my next scene.
The idea is that viewer will enter the page and see a group of names that he has to click on as they move around on the page and this brings up the photo of the person but I cannot get the button to work, any ideas greatly appreciated.
I have tried putting a movie clip in the buttons first frame but no joy its seems to not allow the button to work even if i put....
on (release) {
tellTarget ("/movie1") {
gotoAndPlay(2);
}
}
View Replies !
View Related
Animate A Button On A Motion Guide
Is this possible I've looked on all the tutorials and cannot seem to find an example...
The scene is a little more complex so you will have to view my .fla file, see link below.
I need to make an animated button that follows a motion path around the page area on a continuous loop but at present it will not work to go to my next scene.
The idea is that viewer will enter the page and see a group of names that he has to click on as they move around on the page and this brings up the photo of the person but I cannot get the button to work, any ideas greatly appreciated.
I have tried putting a movie clip in the buttons first frame but no joy its seems to not allow the button to work even if i put....
on (release) {
tellTarget ("/movie1") {
gotoAndPlay(2);
}
}
I have put a link below to the .fla and .swf file for a look if you can help please. It's just a test at the moment so excuse the bad design.
I just cant get my head round it.
http://homepage.ntlworld.com/rosstamon/anime/anime.htm
If you could code one instance and email it to me that would be amazing and get me out of a hole pile of elephant dung if you get my jist, or you could make me learn the hard way and explain it in a reply and if I can do it and it works I will be you learned disciple forever.
rosstamon@ntlworld.com :{
View Replies !
View Related
Why Does My Button Animate Without Explictly Invoking It ?
I created a user interface with buttons on it that load external swfs.
There are 3 buttons that will load external .swfs but I haven't set that
part of it up yet. I'm stuck on the 1st button.
You can view the .swf at
http://www.jassante.com/charts/starbucks/sbux.html
To view the actual fla file, merely change the "html" to ".fla" minus
the quotes.
I have 2 statements on my actions layer on frame one of the main timeline.
The 1st statement loads an external .swf so that the user
sees a chart as soon as the page loads.
The 2nd statement is a reference to the 1st button who's
instance name is "monthly_mc".
monthly_mc.onRelease = function(){
This is where I invoke the animation of the button (monthly_mc), but since
it's not working right, I took out those statements.
Funny thing is, it's still animating when you mouse over the button
even though there's no code sending the monthly_mc's play
head to a frame label that changes the look of the button (_down). :shock:
}
Can anyone tell me why this is happening ?
Initially, I couldn't seem to click on the button without it changing
states first. I was using onRelease to goto the down state
which uses darker colors on the button's background and stroke.
I also found that I couldn't make the button stay in the down state
after clicking the mouse. It would goto down state when cliking
the mouse, but then revert back to the upstate even though
the statement was a gotoAndStop("_down"). :?:
[/url]
View Replies !
View Related
Animate A Menu Button Momentarily
Hey everyone,
I am relatively new to flash 8, but am ok at it, having learned on mx a while back.
basically my question concerns the following situation:
I have a flash webpage menu, with certain buttons (news, shows, etc.). basically what i am trying to do, is when a button is pressed, not only open a page in a new frame (which i have successfully done), but do a little animation (for example, the button will have flames erupt around it momentarily) as well. the latter is what i'm having trouble with.
if anyone has any ideas or solutions, they'd be much appreciated. thanks for your time.
-keith
View Replies !
View Related
Animated Button Won't Animate When Actions Are Applied
First off, to achieve an animated button effect (fade in on mouseover, fade out on mouseout), I have placed a button inside a movieclip.
I place the movieclip on the main stage and assign the following action:
on (press) {
_root.loginmain.gotoAndPlay(2);
}
The movieclip is assigned as a movieclip and not a button. It functions fine in bringing up the movieclip with the instance name of loginmain, which is the whole idea.
However, the rollover effect in the movieclip itself (the fade in on mouseover, fade out on mouseout) does not work now.
Any ideas? Thanks!
Nevermind I got it!
I had to add this action code to the movieclip along with the code I posted above .... so now the code for the button looks like this ...
on (press) {
_root.loginmain.gotoAndPlay(2);
}
on (rollOver) {
gotoAndPlay(2);
}
on (rollOut) {
gotoAndPlay(10);
}
I had to tell the movieclip to go to itself and play on the rollover and rollout.
If anyone has any additional input, I'd be glad to hear. I'm new at learning this and must say this website is an INCREDIBLE resource.
View Replies !
View Related
Total NOOb Question... How To Animate Button?
attached is a file i am working on.
i can't seem to get the scripts right, and i prbably shouldn't have used a button object. can someone point me to a good tutorial?
1. the "*Application Disk" object should be looping, it is not. (the expanding ring anaimation)
2. the "pole" is "hot", even while masked out - try hovering below the green disc in the .swf, it activates the mov, it shouldn't, only the disc should do that
3. the "pole and flag" should be a button to the URL (which is not set yet), the pole is, but the flag is not.
I think everything is basically there, i am using the green or Application Management as my first button, i can do the rest, just need help on the first...
any help is greatly appreciated!
View Replies !
View Related
Unvable To Animate (tween) Scrollbar / Button Components?
Hi fellows,
I have a contact form within a mc (mcContact) that should glide from top to bottom. Ok, it's gliding, but the submit button and the scrollbar. In the author environment (Flash stage) it works, but when I test it with CONTROL+ENTER the button as well the scrollbar keep stucked in the same position of the first frame. Everything is tweened but they keep there, static.
What's going on????
View Replies !
View Related
Navigation Button Events - Animate Out Existing Contents
Okay, I've searched and I just cannot seem to enter the right text in google or even this site to try to describe what i want to do. I think this is going to be really simple and I'm just not thinking clearly.
Okay, I want to create a navigation bar for my flash website, which I have done successfully. I can click a button and I can get the contents of that button to appear where I want it. So the fundamentals of the navigation bar is good....
What I want to do is to have whatever content is on the screen to fade away (or other animation) before the content for the button I select appears.
Say I have HOME, ABOUT, CONTACT, PORTFOLIO as buttons. I click on CONTACT and the contact content appears. If I click HOME, I want the contact contents to animate away then have the home contents animate in. If I'm on home and click PORTFOLIO I want the home contents to animate away then have the portfolio contents animate in.
So my question is how do you code this? I'm stuck because you never know what screen you are looking at and what button you are going to click next. Does this make sense?
Jason?
View Replies !
View Related
Background Class
I am trying to take all the dumb little tasks that I do daily and pull them together... here is the start of one... I would like you guys to collaborate on what would work well with this class.
Ever want to change the Background color of your movie on the fly... here is my simple solution
ActionScript Code:
/**
* A class representing the Background of your movie, as in the Visual background.
*
* @author Michael Avila
* @version 1.0.0
*
*/
class Background
{
// the background instance...
private static var background : MovieClip;
/**
* Set's the color of your background, and creates a background movieclip with the instanceName "background"
*
* @usage <code>Background.setColor( 0xFF0000, 100 );</code>
* @param The color you want the Background to be.
* @param How transparent you want the background to be, the backing of the SWF will be the background color set in the IDE.
* @return Void
*/
public static function setColor (color : Number, alpha : Number ) : Void
{
if (background == undefined) background = _root.createEmptyMovieClip ("background", -16384);
trace( background.getDepth() );
background.beginFill (color, 100 );
background.lineTo (0, Stage.height);
background.lineTo (Stage.width, Stage.height);
background.lineTo (Stage.width, 0);
background.lineTo (0, 0);
background.endFill ();
if (alpha != undefined) background._alpha = alpha;
}
/**
* Set's the transparency of the Background, again the backing of the SWF will be the background color set in the IDE.
*
* @usage <code>Background.setAlpha( 50 );// 50% transparent</code>
* @param How transparent you want the background to be, the backing of the SWF will be the background color set in the IDE.
* @return Void
*/
public static function setAlpha ( alpha:Number ) : Void
{
background._alpha = alpha;
}
}
So far this is very simple, set the color, set the alpha. What functionality would you guys like?
Michael
View Replies !
View Related
Background Fill Class
I Can't seem to find out why this isn't working. Basically, the string "tile1" isn't being sent to the class for some reason.
Code:
import flash.display.BitmapData;
class BGPattern extends MovieClip {
public function BGPattern(myTile:String) {
trace(myTile);
var tile = BitmapData.loadBitmap(myTile);
_global.curTile = myTile;
destroyBG();
fillBG(tile);
}
/* Function that fills the stage background with tile */
private function fillBG(theTile) {
this.beginBitmapFill(theTile);
this.moveTo(0, 0);
this.lineTo(Stage.width, 0);
this.lineTo(Stage.width, Stage.height);
this.lineTo(0, Stage.height);
this.lineTo(0, 0);
this.endFill();
}
/* Function that destroys the background */
private function destroyBG() {
this.beginFill(0xFFFFFF);
this.moveTo(0, 0);
this.lineTo(Stage.width, 0);
this.lineTo(Stage.width, Stage.height);
this.lineTo(0, Stage.height);
this.lineTo(0, 0);
this.endFill();
}
}
For now I have everything on a movieclip called 'main' that includes the class 'BGPattern'. On the 1st frame of the movieclip 'main', I have this....
Code:
BGPattern("tile1");
If I were to change the class function in such a way...
Code:
var tile = BitmapData.loadBitmap("tile1");
....it would work. So the problem is that the function isn't recieving the variable passed down to it. Can anyone help?
View Replies !
View Related
Tiled Background Class
I'm trying to write a class for background tiling. But I get an error 1136: Incorrect number of arguments. Expected 1. On the last line imageLoaded() in private function res() to be exact, but I don't know of any arguments to give. What am I overlooking?
ActionScript Code:
public class Background extends Sprite{
private var cont:Sprite = new Sprite(); // Making a new Sprite to contain the bg
private var graph:Graphics = cont.graphics; // Setting the graphics of the Sprite
private var gradType:String = GradientType.RADIAL; // Setting the gradient type
private var colors:Array = [0x000000 , 0x000000]; // Setting the collors of the gradient
private var alphas:Array = [0 , .8]; // Setting the alpha's of the gradient
private var ratios:Array = [0 , 255]; // Setting the ratio of the gradient
private var matrix:Matrix = new Matrix(); // Making a new matrix for the gradient
private var spread:String = SpreadMethod.PAD;
public function Background():void
{
var loader:Loader = new Loader;
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
loader.load(new URLRequest("bg/bg1.jpg"));
stage.align = StageAlign.TOP_LEFT; // Setting the stage align
stage.scaleMode = StageScaleMode.NO_SCALE; // Setting the stage scale mode
stage.addEventListener(Event.RESIZE , res); // Ading an event listener for resizing
}
private function imageLoaded(event:Event):void
{
matrix.createGradientBox(stage.stageWidth , stage.stageHeight);
// drawing
with(graph)
{
var image:BitmapData = new BitmapData(event.target.content.width, event.target.content.height);
image.draw(event.target.content);
trace (image)
beginBitmapFill(image);
lineStyle(1 , 0x000000 , 0);
drawRect(0 , 0 , stage.stageWidth , stage.stageHeight);
endFill();
graph.beginGradientFill(gradType , colors , alphas , ratios , matrix , spread);
drawRect(0 , 0 , stage.stageWidth , stage.stageHeight);
}
addChildAt(cont , 0); // Ading the background to the display list
}
private function res():void
{
imageLoaded(); // Redrawing the graphics// <<<<ERROR IS OCCURING HERE
}
}
}
View Replies !
View Related
Class For Background Gradient
I am new to writing classes, but am trying to learn. I want to write a class that creates a gradient for the whole stage. I want to be able to pass in the two color values in the beginning.
Like I said, I am new to this, but here is what I have. Obviously, it is not working yet. What do I need to change?
In my Fla, I have the following:
myBG = new BgColor(0x000000, 0xCCCCCC);
They are not in the same directory. How do I do that? I have a class path to a folder on my desktop. But there is a structure within that. Using the import it would look like this: import com.brianf.BgColor
My class looks like this:
class BgColor
{
public var color01:Number;
public var color02:Number;
private var fillType:String = "linear";
private var colors:Array = [color01, color02];
private var alphas:Array = [100, 100];
private var ratios:Array = [0, 255];
private var matrix:Object = {matrixType:"box", x:0, y:0, w:Stage.width, h:Stage.height, r:(90/180)*Math.PI};
private var spreadMethod:String = "pad";
private var interpolationMethod:String = "linearRGB";
private var focalPointRatio:Number = 1;
public function BgColor()
{
beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio);
moveTo(0, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 0);
endFill();
}
}
What do I need to change to make this work? Right now, the class does not even get instantiated.
Thank you so much for the help!
View Replies !
View Related
Animate Forward, Animate Backward
This seems like it should be easy, but it's beyond my skill.
I have an animation that I want to play forward when I mouse over, and play backward (to the beginning) when I mouse out. Here's the code:
stop();
function zoomMovie(event:MouseEvent):void
{
play();
}
this.addEventListener(MouseEvent.MOUSE_OVER, zoomMovie);
function mouseOut(event:MouseEvent):void
{
function everyFrame(event:Event):void
{
if (currentFrame == 1)
{
stop();
}
else
{
prevFrame();
}
}
this.addEventListener(Event.ENTER_FRAME, everyFrame);
}
this.addEventListener(MouseEvent.MOUSE_OUT, mouseOut);
Any suggestion are very much appreciated
View Replies !
View Related
Noob: Animate, Stop, Animate
basically i'm trying to animate a movie clip from 0 pixel to 550 pixels in x axis, and when i reach 550 pixels in x axis i want it to stop and then animate in y axis from 10 pixels to 100pixels.
how can i do that?
please help me on my problem, it has been bothering me for days.
View Replies !
View Related
Background Sound With SharedObject Class
Hi, i´m trying to put the same sound loop on various html pages. I can´t use frames for it, so i´m trying to use the shareobject class for a continuos play. My not working code for now is :
loop1 = new Sound( MC1 );
loop1.attachSound( "theme" );
this.onEnterFrame = function () {
_root.songDurationText=_root.loop1.duration/1000;
_root.songPositionText=_root.loop1.position/1000;
songDuration = _root.loop1.duration / 1000;
songPosition = _root.loop1.position / 1000;
}
var local_data = SharedObject.getLocal( "sound_position" );
local_data.data.sound_position = _root.loop1.position / 1000
trace( "root sound_position: " + local_data.data.sound_position );
if (stored_sound_position = local_data.data.sound_position) {
playing=true;
loop1.start();}
else loop1.gotoAndPlay (1)
--- New code on fla but not working yet
Help needed.
View Replies !
View Related
Background Sliding/panning Class Help
greetings all,
i am trying to convert an actionscript 2 class into 3
i think i am nearly there but it gives me this error, it was good lesson so far to learn the new tags but i am stuck now.
any help or tips is highly appreciated
Code:
1120: Access of undefined property SliderAS3. source : SliderAS3.main(this);
this is the code
Code:
package {
import flash.display.MovieClip;
import flash.geom.Rectangle;
import flash.geom.Point;
public class SliderAS3 extends MovieClip {
//
private var image:MovieClip;
private var target:MovieClip;
private var mouse:Point;
private var rect:Rectangle;
private var r_img:Rectangle;
private var r_mask:Rectangle;
private var mc_loader:MovieClipLoader;
private var x_pos:Number;
private var y_pos:Number;
private function Slider3(scope:MovieClip,file:String,e:Event) {
//
image= scope.createEmptyMovieClip("image",1);
image.x=0;
image.y=0;
image.cacheAsBitmap=true;
target=scope;
rect=new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
mouse=new Point(0,0);
x_pos=0;
y_pos=0;
load(file);
}
//load the image
private function load(file:String,e:Event) {
//
mc_loader=new MovieClipLoader();
mc_loader.addListener(this);
mc_loader.loadClip(file,image);
}
//
private function onLoadInit(tg:MovieClip,e:Event):void {
//
r_img=new Rectangle(0,0,image.width,image.height);
r_mask=new Rectangle(image.x,image.y,rect.width,rect.height);
start();
trace("done loading the Slider Image : " + DONEL);
}
public function start():void {
//
image.scrollRect=rect;
image.addEventListener(Event.ENTER_FRAME,enterFramer);
}
private function enterFramer(e:Event):void {
//
mouseX=target.mouseX;
mouseY=target.mouseY;
if (r_mask.containsPoint(mouse)) {
x_pos=((Math.abs(image.y - mouseY) / rect.height) * (r_img.height - rect.height));
y_pos=((Math.abs(image.x - mouseX) / rect.width) * (r_img.width - rect.width));
}
rect.x += x_pos - rect.x / 16;
rect.y += y_pos - rect.y / 16;
image.useHandCursor=false;
image.scrollRect=rect;
}
public static function main():void {
//
var app:SliderAS3 = new SliderAS3(_root,"test_swf.swf");
}
}//end public Slider 3
}
//constructor
private function Slider3(scope:MovieClip,file:String,e:Event) {
//
image= scope.createEmptyMovieClip("image",1);
image.x=0;
image.y=0;
image.cacheAsBitmap=true;
target=scope;
rect=new Rectangle(0,0,stage.stageWidth,stage.stageHeight);
mouse=new Point(0,0);
x_pos=0;
y_pos=0;
load(file);
}
//load the image
private function load(file:String,e:Event) {
//
mc_loader=new MovieClipLoader();
mc_loader.addListener(this);
mc_loader.loadClip(file,image);
}
//
private function onLoadInit(tg:MovieClip,e:Event):void {
//
r_img=new Rectangle(0,0,image.width,image.height);
r_mask=new Rectangle(image.x,image.y,rect.width,rect.height);
start();
}
public function start():void {
//
image.scrollRect=rect;
image.addEventListener(Event.ENTER_FRAME,enterFramer);
}
private function enterFramer(e:Event):void {
//
mouseX=target.mouseX;
mouseY=target.mouseY;
if (r_mask.containsPoint(mouse)) {
x_pos=((Math.abs(image.y - mouseY) / rect.height) * (r_img.height - rect.height));
y_pos=((Math.abs(image.x - mouseX) / rect.width) * (r_img.width - rect.width));
}
rect.x += x_pos - rect.x / 16;
rect.y += y_pos - rect.y / 16;
image.useHandCursor=false;
image.scrollRect=rect;
}
public static function main():void {
//
var app:SliderAS3 = new SliderAS3(_root,"testimage.jpg");
}
}
}
to use in the movie do SliderAS3.main(this);
it is based on this nifty piece of class
Code:
import mx.utils.Delegate;
import flash.geom.Rectangle;
import flash.geom.Point;
class Slider2 {
private var image:MovieClip;
private var target:MovieClip;
private var mouse:Point;
private var rect:Rectangle;
private var S_H:MovieClip;
private var r_img:Rectangle;
private var r_mask:Rectangle;
private var mc_loader:MovieClipLoader;
private var x_pos:Number;
private var y_pos:Number;
private var firstClick:Boolean;
private var DONEL:Boolean;
private function Slider2(scope:MovieClip, file:String) {
image = scope.createEmptyMovieClip("image", 1);
image._x = 0;
image._y = 0;
image.cacheAsBitmap = true;
target = scope;
rect = new Rectangle(0, 0, Stage.width, Stage.height);
mouse = new Point(0, 0);
x_pos = 0;
y_pos = 0;
load(file);
}
/**
* Load the image file
*/
private function load(file:String) {
mc_loader = new MovieClipLoader();
mc_loader.addListener(this);
mc_loader.loadClip(file,image);
DONEL = false;
}
/**
* Once image has been loaded
* apply filters to the image movieclip
* and start the animation
*/
private function onLoadInit(tg:MovieClip):Void {
//image.filters = [_drop];
r_img = new Rectangle(0, 0, image._width, image._height);
r_mask = new Rectangle(image._x, image._y, rect.width, rect.height);
start();
}
public function start():Void {
image.scrollRect = rect;
image.onEnterFrame = Delegate.create(this, enterframe);
}
/**
* main enteframe function
* check mouse position and
* scroll the image
*/
private function enterframe():Void {
mouse.x = target._xmouse;
mouse.y = target._ymouse;
if (r_mask.containsPoint(mouse)) {
y_pos = ((Math.abs(image._y-mouse.y)/rect.height)*(r_img.height-rect.height));
x_pos = ((Math.abs(image._x-mouse.x)/rect.width)*(r_img.width-rect.width));
}
rect.x += (x_pos-rect.x)/16;
rect.y += (y_pos-rect.y)/16;
S_H._x += -(x_pos-S_H.x)/32
S_H._y += -(x_pos-S_H.x)/32
image.useHandCursor = false;
image.firstClick = false;
image.scrollRect = rect;
}
/**
* MAIN function entry point
* using '-main' option in mtasc this class will
* be compiled and the static function main will be called
* automatically
*/
public static function main():Void {
//var app:Slider2 = new Slider2(_root, "flash_image01.jpg")
var app:Slider2 = new Slider2(_root, "test_swf.swf");
}
}
use as such : Slider2.main(this);
View Replies !
View Related
Button Created Within Class Cannot Access Class Properties
Hi,
I'm using the following code within a class:
code:
_head_mc.attachMovie("headButton", "head_btn", this.getNextHighestDepth());
_head_mc.head_btn.onRelease = function () {
containingClip_mc._parent._parent.clickedHead(_per sonName);
}
The button gets attached (line 1). This works because I can see the mouse changing to a finger.
The onRelease function is declared and works. I know because if I put a trace in there, it works.
The function it calls (containingClip_mc._parent._parent.clickedHead also works, becuase I can see traces from within it.
But the _personName variable is passed as undefined.
I know that this variable has a value, because I can trace it outside the function, but it seems that this onRelease function is not able to see the variable. It's declared as private, but setting it to public doesn't fix anything.
I imagine there's something I don't understand about the scoping of variables. I've tried _parent references, but that doesn't appear to help either. Is there a better way to do this or a workaround?
Barrette
Added by edit
Okay, I've pretty much determined this is a scoping issue. From the onRelease function, I'm unable to access ANY of the functions within my class. I still would like advice on how to do so..
Barrette
View Replies !
View Related
Button Class Affect The Document Class
I want it so when you click the button, it can make the movie go to the next scene or change a variable in the document class. I can do it on the timeline but I want it as a class instead
And it would be cool if I could figure out how to make seperate packages just for functions and variables so I didn't have to write it all in one document, I just don't want to code in a big pile after I heard you can do this
Cheers
View Replies !
View Related
Button Class Calling Class Method
I have this class to add code to some buttons on the stage, and the class also contains the code for the button actions.
How can I get the button code to call the search() method when the button is pressed?
Code:
class startup.Shell
{
function Shell ()
{
init ();
}
private function init () : Void
{
//buttons
_root.btn_search.onPress = function ()
{
search ();
}
//
public function search () : Void
{
trace("loadsearch");
}
}
View Replies !
View Related
Class Path, Button Class ?
Hello,
If possible I would like to have all objects (buttons in this case) automatically format without scripting each button to get values from the classes.
Like if I place a button on the stage and export the movie, it references the button class.
Will this work if I change the class path, if so how might I go about this?
View Replies !
View Related
Rollover Button Tip "a How Do I Animate On Roll Over Guide"
OK I just came across the best smallest script I've ever found for simple animations for roll overs. And since I've seen my fare share of posts from people asking "how do I get that nice professional roll over look form my buttons" I thought a good way to keep them from asking again and to give a little back the all here who have did the same for me.
All right here we go.
first thing is, this is so dam simple you might wonder why you did not think of it. So all should have no problem what so ever to under standing this. NO BUTS! I don't think this is the only way to use this script so DO experiment.
Just to start out make a ball at frame 1 the make that ball bigger in frame 10
Shape tween that, then make it in to a movie clip. Then paste this script on to the movie NOT the frame. Test it and you see that when you roll over the ball it gos to the last frame in that movie then stops. Just as easily plays back words to frame one after you roll off.
Code:
Scipt:
onClipEvent (enterFrame) {
// Remember the scope of your clip it may not be in _root.
// if the mouse IS over the clip
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
// if the last frame of the tween hasn't been reached...
if (this._currentframe < this._totalframes) {
// keep playing the next frame to the last and stop...
this.nextFrame();
}
// if the mouse is NOT over the clip
} else {
// if we're past the first frame of the tween...
if (this._currentframe > 1) {
// play the previous frame until it reaches frame 1 and stop...
this.prevFrame();
}
}
}
All you have to do is place this ON a movie clip.
Thats it, a very clean transition.
PS: if you need to edit REMEMBER YOUR SCOPE OF THE CODE AND OBJECTS IT"S IN. like this. and _root.
View Replies !
View Related
Button Foreground Over Button Background
Hello, long time reader first time poster (he he he)
anyway, I've created a background as a button in which plays a MC on the UP and OVER states. To be more specific, it's a picture that blurs on RollOver and returns to normal on RollOut.
Also, I have little buttons that float on the foreground which are links to videos. On RollOver these play a short MC. No big deal so far, right?
My problem is that when I RollOver the buttons in the foreground, the button in the background considers this as a RollOut. Resulting in the background effect of blurring in and out to occur in any interaction with the foreground buttons!
Now, is this something that can be solved using actionscript, or is it simply fixed by modifying layers or maybe hit spots(by the way, my hit spot for the background is all over).
All of you are great, keep up the good work and thanks for any help.
View Replies !
View Related
Button No Background
hey AGAIN. i just finished creating a button and was about to add it to my website, but it has a huge background. How to i add just the button ???
Thanks guys, here is the button i created. Here is the HTML Code and the url, hope somebody can help me out.
http://i68.photobucket.com/albums/i15/luishicks/gd1.gif
Attach Code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled-4</title>
</head>
<body bgcolor="#cacaff">
<!--url's used in the movie-->
<!--text used in the movie-->
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="760" height="420" id="Untitled-4" align="middle">
<param name="allowScriptAccess" value="sameDomain" />
<param name="movie" value="Untitled-4.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#cacaff" />
<embed src="Untitled-4.swf" quality="high" bgcolor="#cacaff" width="760" height="420" name="Untitled-4" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
</body>
</html>
Edited: 12/28/2006 at 07:03:04 PM by LuisDesigns
View Replies !
View Related
Changing Background Through A Button
does anyone know how to change the background of flash through the use of a button (on a click)... i am wanting to change the color to a custom color as well. a different button will change the background to a different color. i would appreciate any help you could give me.
thanks,
jeff
View Replies !
View Related
Loading A JPG As Button Background
I'm trying to loading a JPEG as a button background. Depending on the event (up, over, press) I have to strech or mask it. (Attached the effect)
How can I prevent to load the jpeg every time I change event ?
Not using a button but a movie controlled by this function (button is the movie holder, pre is the movie to be changed by the image):
Code:
button.pre.loadMovie(label+".jpg");
preInt = setInterval(preLoad, 500);
function preLoad() {
if (button.pre._width > 0) {
button.onRollOut = function() {
bottone.gotoAndPlay(10);
};
button.onRollOver = function() {
bottone.gotoAndPlay(20);
};
bottone.onPress = function() {
bottone.gotoAndPlay(30);
};
clearInterval(preInt);
}
}
Why does it load the image only once and after an "onSomething" event it forget about it ?
View Replies !
View Related
Button Background Fade
If you look at this page:
http://motion-wave.com/
the background of the buttons in the menu is fading when you roll over/out. Can someone please help me out how you can actionscript that? Maybe you can show with some code example or a tutorial?
Thanks in advance
View Replies !
View Related
Background Acting Like A Button
Hi,
I have created a website with Flash on a Mac. I use dreamweaver to place the flash into an html page. On the Mac the site works fine, but on a PC you have to double click the buttons for them to work. The background is acting like a button but it isn't. The home page doesn't even have a background. The address is: http://www.graceofspringhill.net so you can see what I am talking about.
Any help would be appreciated.
View Replies !
View Related
Button Background Rollover.
Hey Guys,
I am tying to build a nav with some button that overlap, and they have drop shadow on them. How can I create a custom shape that the button uses?
buttonClip.Shape.blabla..
Thanks.
I just nested a clip in the button, and called that in the rollover.
View Replies !
View Related
Flash Button Background
Does anyone know how to replace a background colour of a button with an image? i have tried but with no luck. The code I have tried is;
Code:
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" width="105" height="54" background-image: "url(My%20Documents/Disertation/VB%20Project/Images/background.JPG">
<param name="BGCOLOR" value="">
<param name="movie" value="button1.swf">
<param name="quality" value="high">
<embed src="button1.swf" width="105" height="54" quality="high" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" src="My Documents/Disertation/VB Project/Images/background.JPG" ></embed>
</object>
View Replies !
View Related
Background Scolls On A Click Of A Button
Okay... here's my question.
I want to figure out how to create a site where the background scrolls anytime the user clicks any button on the page.
So I know to create a long image for the background that consists of all of the images I want the background to be. But then how do I scroll it a set amount when a button is pressed?
I have vague notions, but nothing seems to be working in practice.
Flash 5.
Thanks.
Tex
View Replies !
View Related
|