Quick Question For Cleaner Code
Just need some advice on how to clean this code up. I know there has got to be a way to combine the 2 movieclips....Basically I have 4 movieClip buttons. currently only the first is working.... How would I add the other f2, f3, f4 MC's without having to write a function for each one?Here is the code I have:Code: f1.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);f1.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);f2.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);f2.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);f3.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);f3.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);f4.addEventListener(MouseEvent.MOUSE_OVER, hoverOver);f4.addEventListener(MouseEvent.MOUSE_OUT, hoverOut);function hoverOver(event:MouseEvent):void{ f1.gotoAndPlay(2);}function hoverOut(event:MouseEvent):void{ f1.gotoAndStop(11);}f1.buttonMode = true;f2.buttonMode = true;f3.buttonMode = true;f4.buttonMode = true;
Actionscript 3.0
Posted on: Tue Feb 19, 2008 8:59 pm
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Cleaner Code
I have a code that consolidates current moneys into the least amount of tokens possible. It works but the actual code is extremely bulky, i was wondering if anyone has a tip or sees something that can be removed/replaced for less code
Thanks
code: C_Amount = _root.betTotal;
if(C_Amount < 25)
{
NumLeft = C_Amount % 10;
if(NumLeft < 5)
{
dollar_1 = NumLeft;
dollar_10 = (C_Amount - NumLeft) / 10;
}else{
NumLeft1 = NumLeft % 5;
dollar_1 = NumLeft1;
dollar_5 = (NumLeft - NumLeft1) / 5;
dollar_10 = (C_Amount - NumLeft) / 10;
}
}
[CS3] Cleaner Code
Hi,
Is there an easier, cleaner way to write:
type = _root.page;
if (_root.pageOn == 1)
{
if (type == 'ftp')
{
_root.content.ftp.filters = [myBlurFilter];
_root.content.ftp._alpha = 50;
}
if (type == 'news')
{
_root.content.news.filters = [myBlurFilter];
_root.content.news._alpha = 50;
}
if (type == 'hello')
{
_root.content.hello.filters = [myBlurFilter];
_root.content.hello._alpha = 50;
}
if (type == 'contact')
{
_root.content.contact.filters = [myBlurFilter];
_root.content.contact._alpha = 50;
}
if (type == 'exhibitions')
{
_root.content.exhibitions.filters = [myBlurFilter];
_root.content.exhibitions._alpha = 50;
}
if (type == 'interiors')
{
_root.content.interiors.filters = [myBlurFilter];
_root.content.interiors._alpha = 50;
}
if (type == 'conferences')
{
_root.content.conferences.filters = [myBlurFilter];
_root.content.conferences._alpha = 50;
}
if (type == 'live_events')
{
_root.content.live_events.filters = [myBlurFilter];
_root.content.live_events._alpha = 50;
}
if (type == 'new_media')
{
_root.content.new_media.filters = [myBlurFilter];
_root.content.new_media._alpha = 50;
}
if (type == 'people')
{
_root.content.people.filters = [myBlurFilter];
_root.content.people._alpha = 50;
}
if (type == 'clients')
{
_root.content.clients.filters = [myBlurFilter];
_root.content.clients._alpha = 50;
}
}
Cleaner Code
Hi all, I'm currently working on creating a simulated training flash-based presentation and I'm looking to improve my coding habits.
Part of the simulation was to create a custom cursor that functions just as any data entry cursor would. Here's where I need to improve:
The user is restricted to only entering uppercase glyphs at this point, so the cursor should only respond if a letter character is pressed. All other characters should be ignored. I've figured a method to do this, and it works just fine, but the code is very repetitive and long. I'm guessing that there is a better way to do this by referencing a list of key codes in the conditional statement, but I'm not sure how to go about it. Here's what the code looks like
Thanks
Code:
onClipEvent(keyDown) {
//ignore tab
if (key.isDown(9)) {
this._x = this._x;
} else if (key.isDown(12)) {
this._x = this._x;
} else if (key.isDown(13)) {
this._x = this._x;
} else if (key.isDown(16)) {
this._x = this._x;
} else if (key.isDown(17)) {
this._x = this._x;
} else if (key.isDown(112)) {
this._x = this._x;
} else if (key.isDown(113)) {
this._x = this._x;
} else if (key.isDown(114)) {
this._x = this._x;
} else if (key.isDown(115)) {
this._x = this._x;
} else if (key.isDown(116)) {
this._x = this._x;
} else if (key.isDown(117)) {
this._x = this._x;
} else if (key.isDown(118)) {
this._x = this._x;
} else if (key.isDown(119)) {
this._x = this._x;
} else if (key.isDown(120)) {
this._x = this._x;
} else if (key.isDown(121)) {
this._x = this._x;
} else if (key.isDown(122)) {
this._x = this._x;
} else if (key.isDown(123)) {
this._x = this._x;
} else if (key.isDown(124)) {
this._x = this._x;
} else if (key.isDown(48)) {
this._x = this._x;
} else if (key.isDown(49)) {
this._x = this._x;
} else if (key.isDown(50)) {
this._x = this._x;
} else if (key.isDown(51)) {
this._x = this._x;
} else if (key.isDown(52)) {
this._x = this._x;
} else if (key.isDown(53)) {
this._x = this._x;
} else if (key.isDown(54)) {
this._x = this._x;
} else if (key.isDown(55)) {
this._x = this._x;
} else if (key.isDown(56)) {
this._x = this._x;
} else if (key.isDown(57)) {
this._x = this._x;
} else if (key.isDown(186)) {
this._x = this._x;
} else if (key.isDown(187)) {
this._x = this._x;
} else if (key.isDown(188)) {
this._x = this._x;
} else if (key.isDown(189)) {
this._x = this._x;
} else if (key.isDown(190)) {
this._x = this._x;
} else if (key.isDown(191)) {
this._x = this._x;
} else if (key.isDown(192)) {
this._x = this._x;
} else if (key.isDown(219)) {
this._x = this._x;
} else if (key.isDown(220)) {
this._x = this._x;
} else if (key.isDown(221)) {
this._x = this._x;
} else if (key.isDown(222)) {
this._x = this._x;
} else if (key.isDown(32)) {
this._x = this._x;
} else if (key.isDown(37)) {
this._x = this._x;
} else if (key.isDown(38)) {
this._x = this._x;
} else if (key.isDown(39)) {
this._x = this._x;
} else if (key.isDown(40)) {
this._x = this._x;
} else if (key.isDown(20)) {
this._x = this._x;
} else if (key.isDown(106)) {
this._x = this._x;
} else if (key.isDown(107)) {
this._x = this._x;
//don't move left of original position
} else if (key.isDown(8)) {
if (this._x > 104) {
this._x -= 10;
}
//don't move right of new position
} else if (this._x < 112) {
this._x += 10;
}
}
If/Else - Is There A Cleaner Code?
Hello all,
I am currently working on a flash file and I'm an intermediate user. My actionscript abilities are probably close to beginner, but I'm a quick learner (most of what I have learned with actionscript has been self taught).
In my flash file I have an animation of a rotating globe. Each frame of the rotation is a separate raster image - I don't know how you would represent a rotating globe otherwise, not really something that can be tweened (suggestions are welcome).
I have different locations off to the side of the globe. When the user mouses over a location, the globe spins to that location. When they roll out, the globe spins back to a static starting point.
I wanted the animation of the globe to be as smooth as possible, so, I have a }else{ statement for every possible frame. IE - if the globe animation is rotating back from a position and the user mouses over a new location before the animation stops, it doesn't jump back to the starting static position, it seemlessly flows from the position it is currently at to the new position the user has moused over.
Make sense?
It works flawlessly as is. I've spent quite a bit of time testing it. However, the code is bulky in appearance and according to the size report bulky in bytes as well.
Is there a differnent way to set this up to cut down on size - mainly byte size if possible?
I will include a bit of code so you can see what I'm talking about:
on (rollOver) {
if (_root.EarthClip._currentframe == 1) {
_root.EarthClip.gotoAndPlay(140);
} else { if (_root.EarthClip._currentframe == 160) {
_root.EarthClip.gotoAndPlay(156);
} else { if (_root.EarthClip._currentframe == 161) {
_root.EarthClip.gotoAndPlay(155);
} else { if (_root.EarthClip._currentframe == 161) {
_root.EarthClip.gotoAndPlay(154);
} else { if (_root.EarthClip._currentframe == 163) {
_root.EarthClip.gotoAndPlay(153);
and so on, and so on . . .
Any help would be greatly appreciated.
Thank you in advance.
-MShetler
Cleaner
Hi
Just wondering if anyone uses Cleaner EZ which comes with Premier etc to compress their video files into Quicktime?
Im stuck on selecting the right settings...I need the video to be fairly small but it ALWAYS ends up being too blurred...
Thanks!
Can This Be Cleaner?
this is a movieclip that can move threw a maze of objects. if the user hits an object the movieclip jumps to frame that shows it crashing. Everything works. my question is.. can the code be cleaner or wrapped up in a function?
onClipEvent (enterFrame) {
if (Key.isDown(37)&& hitTest(_level0.wall)==false) {
_x=_x-4;
}
if (Key.isDown(38)&& hitTest(_level0.wall)==false) {
_y=_y-4;
}
if (Key.isDown(39)&& hitTest(_level0.wall)==false) {
_x=_x+4;
}
if (Key.isDown(40)&& hitTest(_level0.wall)==false) {
_y=_y+4;
}
if (hitTest(_level0.wall)==true) {
this.gotoAndPlay("hit");
}
if (hitTest(_level0.wall2)==true) {
this.gotoAndPlay("hit");
}
if (hitTest(_level0.wall3)==true) {
this.gotoAndPlay("hit");
}
}
[F8] Is There A Cleaner Way To Do This?
This code works just fine for restricting the area I can draw in, but it seems very inefficient. Is there a better way?
Code:
onMouseMove = function () {
if (_xmouse>32 && _ymouse>32 && _xmouse<607 && _ymouse<397) {
drawingArea.lineTo(_xmouse, _ymouse);
}
};
My movie actually uses close to 100% CPU after scribbling a lot, and I think it might be this code thats doing it.
AS2 - URL Cleaner
Hello, this is a great tool that i use to filter path to test locally.
the function:
function cleanVBLE(vble)
{
a = new String(vble);
b = a.split("/");
return b.pop();
}
the usage:
trace(cleanVBLE("/formas/80094/canalune.swf"));
Cleaner Animation
I am trying to make a movie which will play fullscreen with a small area with 20% opacity visible in the center. Now my character (any image) will erase the black background so that a clear picture becomes visible.
Pls. help. urgent
Cleaner Scripting
I think the code says it all. For a current project I need to use a hit area to start an animation when a mouse rolls over a _mc.
If I use the movie clip instead of a button I can simplify the script by using the first section of the attached code. In the simplified code I only have to define one over and one out state and then I can use a this statement to control the action.
For any number of _mc's I just need one set of functions.
Using buttons, each _mc needs it's own over and out definition and it's own unique set of functions.
I've tried using a bunch of if (grnMC_button.onRollOver = true) {this statements apply only to grn_mc} (not really code) but I can't find anything that works. It would be a great time saver if I could because in the final project I've got about 75 movie clips to control with over functions.
One more thing. I can't use the movie based code because the animations move out from under the buttons and the mouse over area gets big and overlaps the other "buttons". I guess I'm really looking for a way to define a hit area and still keep the code simple.
Attach Code
Movie driven _mc sample code:
˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜
// over-out definitions
grn_mc.onRollOver = over;
grn_mc.onRollOut = out;
blu_mc.onRollOver = over;
blu_mc.onRollOut = out;
red_mc.onRollOver = over;
red_mc.onRollOut = out;
// onRollOver functions
function over () {
this.overThis = true;
this.gotoAndPlay("start");
}
// onRollOut functions
function out () {
this.overThis = false;
Button driven _mc sample code:
˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜˜
// button definitions
grn_btn.onRollOver = over_grn;
grn_btn.onRollOut = out_grn;
blu_btn.onRollOver = over_blu;
blu_btn.onRollOut = out_blu;
red_btn.onRollOver = over_red;
red_btn.onRollOut = out_red;
// onRollOver functions
function over_grn () {
grn_mc.overThis = true;
grn_mc.gotoAndPlay("start");
}
function over_blu () {
blu_mc.overThis = true;
blu_mc.gotoAndPlay("start");
}
function over_red () {
red_mc.overThis = true;
red_mc.gotoAndPlay("start");
}
// onRollOut functions
function out_grn () {
grn_mc.overThis = false;
}
function out_blu () {
blu_mc.overThis = false;
}
function out_red () {
red_mc.overThis = false;
}
Edited: 05/16/2007 at 11:25:53 AM by Rick Gerard
Cleaner, Crisper Text
can anyone explain how to get cleaner, crisper text in FlashMX. Thank you.
LoriSchlitz
Cleaner 6 Or Sorenson Squeeze?
hi
I have cleaner 6, but a friend says sorenson squeeze it a better compressor for use of video in flash. Shoul i get a copy? or will cleaner suffice??
Techniques To A Cleaner Program
Hi, Im not an expert in flash, but I do on occasion help some buddies out if they want a menu or something on their webpage. When I am making these files, it seems like my organization and technique is sloppy. Any comments / suggestions / flames are welcome on how I could better organize this and other projects in the future.
~Thanks
Link to File:
http://www.geocities.com/matteoelbow/SR_Menu1.fla
Link to movie:
http://www.geocities.com/matteoelbow/SR_Menu1.swf
Quick Code Help
i++;
// i = i+1 or i+=1
duplicateMovieClip ("txt0", "txt" + i, i);
//duplicate the movieclip txt0 cand call its text plus i which is increasing
set ("txt" + i + ":txta", substring(text, i, 1));
// No idea
setProperty ("txt" + i, _x, getProperty("txt" + (i-1), _x)+10);
// not 100 percent sure about that get property crap.
Quick Php Code Please
I know this should be like 3-5 lines at the most.
I would like the php code that will add an email to a text file that contains...emails.
in my flash file I ask for people's emails and want to add them to the already existing list with php.
Could someone send me a quick fix? I know it's simple, but I am missing some brain cells right now.
Thanks!
Some Quick Code Help.
Ok. So I'm writing this code for a menu, and then I go to check it, and it says there needs to be a '(' and a ')' on lines 5 and 6. I have abousloutly no idea where these need to go. Could you help me?
Code:
onClipEvent(enterFrame) {
if.xpos=50
root.arror.gotoAndPlay(2)
}
[F8] Quick Help With Code
I have this attached file
www.thinking-tank.com/files/preloader.fla
I am trying to make this preloader mc named "loader" to work with the MCL action. Can some one shed some light into how I can make this work ?
Thanks
[CS3] Help Need A Cleaner Way To Write This Array Of Buttons
Hi there,
not sure how difficult this is going to be, but I have 30 movie clips, which will all be sequentially numbered. (pos1, pos2, pos3......pos30).
They will all have the same functions, with the only change being the number.
I know there is a more efficient way to write this code using arrays, but I will need help with it. I would rather have 10 lines of code than 150.
I also need help with writing the code, that will disable all other movie clips, once the first one is clicked.
Also, not sure how tricky the javascript part will be.
Below is the code i am trying to achieve, but the long version.
PHP Code:
pos1.onRelease=function(){
this.gotoAndStop("selected");
getURL("Javascript:JSposition('',1)");
(all other buttons).enabled = false;
}
pos2.onRelease=function(){
this.gotoAndStop("selected");
getURL("Javascript:JSposition('',2)");
(all other buttons).enabled = false;
}
pos3.onRelease=function(){
this.gotoAndStop("selected");
getURL("Javascript:JSposition('',3)");
(all other buttons).enabled = false;
}
pos4.onRelease=function(){
this.gotoAndStop("selected");
getURL("Javascript:JSposition('',4)");
(all other buttons).enabled = false;
}
... all the way to
pos30.onRelease=function(){
this.gotoAndStop("selected");
getURL("Javascript:JSposition('',30)");
(all other buttons).enabled = false;
}
AS Guru's please help!!!
Thanks.
Cleaner Movie Clip Dragging
I briefly remember seeing a tutorial for this somewhere but I cant find it anywhere. But is there a way to drag movie clips around using startDrag but with a cleaner more fluent motion as it a bit jolty when moving?
Anydony know the answer?
Flash Media Cleaner Addons
I'm looking for an add-on lilke Sorenson Squeeze for Flash, but this is a little pricey for me.
http://www.sorensonstore.com/product.../sq4mfwin.html
Does anyone know of something comparable for less? I know. You get what you pay for, but I need something to get me by while I'm learning Flash.
I'm not looking for shareware, etc. Just an inexpensive, nifty program to get me started as a newbie.
Thanks in advance for any help.
Can I just say I'm loving Flash. I just starting using it a few days ago, and I'm hooked! This is so much nicer when embedding video to webpages. Whoa!
Edit:
Does anyone know if the addon comes with Studio MX 2004? Because I plan on upgrading very soon. I definately don't want to dish out $119.00 for the addon if it ships with Macro's latest studio.
Quick Code Question...
Hi all,
can anyone tell me how I make the following code gotoAndPlay - a scene?
ie: what replaces "home"
on(release){
_level0.section="Contact";
tellTarget("_level0") {
gotoAndPlay("home");
}
}
Thanks
Skribble.
[F8] Need Quick Fix For Code Error
Hi. I have a movieclip button which when pressed directs the playhead to another frame. This is the code I use:
PHP Code:
_root.submit.onRelease = function() {
if (answer == "silence") {
gotoAndPlay("correct");
result += 1;
questionNum++;
} else {
gotoAndPlay("incorrect");
questionNum++;
}
}
However, I also need to add a keypress action.
This is the code I used:
PHP Code:
_root.submit.on(release, keyPress "<Enter>") = function() {
if (answer == "silence") {
gotoAndPlay("correct");
result += 1;
questionNum++;
} else {
gotoAndPlay("incorrect");
questionNum++;
}
}
IT DOESN'T WORK!
Returns a 'expected field name after (.).
How would I write this simple bit of code?
Cheers folks!
Quick Code Re-write (as2-as3)
Let me preface my post by saying that I am not an AS writer. I find it much easier to come here and get the stuff I need from all of you AS geniuses. I have this little piece of script that I need to re-write in AS 3. I'm using the FlashEff plugin on a banner ad, but need it re-write the get URL portion of the button in AS3 in order for it to work. Here's that code:
on (release) {
getURL(_root.clickTAG, "_blank");
}
Can someone show me the AS3 version of this? Thanks!!!
Quick Tidy Up Of Code
Does anyone know of a way to tidy up this code? seems to be an awful lot of repeated code here but i have no clue as to how i can simplyfy it all???
var bottom_level_nav_loc:String = "bottom_pages/";
bottom_menu.buttons.homepage.addEventListener(Mous eEvent.CLICK, mainClick_homepage);
bottom_menu.buttons.about_us.addEventListener(Mous eEvent.CLICK, mainClick_about_us);
bottom_menu.buttons.dealer_enquiries.addEventListe ner(MouseEvent.CLICK, mainClick_dealer_enquiries);
bottom_menu.buttons.gallery.addEventListener(Mouse Event.CLICK, mainClick_gallery);
bottom_menu.buttons.help_n_support.addEventListene r(MouseEvent.CLICK, mainClick_help_n_support);
//GENERALL MOUSE SETTINGS
var c:Color=new Color();
bottom_menu.buttons.homepage.addEventListener(Mous eEvent.MOUSE_OVER, mouse_over_homepage);
bottom_menu.buttons.about_us.addEventListener(Mous eEvent.MOUSE_OVER, mouse_over_about_us);
bottom_menu.buttons.dealer_enquiries.addEventListe ner(MouseEvent.MOUSE_OVER, mouse_over_dealer_enquiries);
bottom_menu.buttons.gallery.addEventListener(Mouse Event.MOUSE_OVER, mouse_over_gallery);
bottom_menu.buttons.help_n_support.addEventListene r(MouseEvent.MOUSE_OVER, mouse_over_help_n_support);
//MOUSE OVER SETTINGS
var over_settings_1:uint = 0xff0000;
var over_settings_2:Number = .8;
bottom_menu.buttons.homepage.addEventListener(Mous eEvent.MOUSE_OUT, mouse_out_homepage);
bottom_menu.buttons.about_us.addEventListener(Mous eEvent.MOUSE_OUT, mouse_out_about_us);
bottom_menu.buttons.dealer_enquiries.addEventListe ner(MouseEvent.MOUSE_OUT, mouse_out_dealer_enquiries);
bottom_menu.buttons.gallery.addEventListener(Mouse Event.MOUSE_OUT, mouse_out_gallery);
bottom_menu.buttons.help_n_support.addEventListene r(MouseEvent.MOUSE_OUT, mouse_out_help_n_support);
//MOUSE OUT SETTINGS
var out_settings_1:uint = 0xcccccc;
var out_settings_2:Number = 0;
bottom_menu.buttons.homepage.buttonMode = true;
bottom_menu.buttons.homepage.useHandCursor = true;
bottom_menu.buttons.about_us.buttonMode = true;
bottom_menu.buttons.about_us.useHandCursor = true;
bottom_menu.buttons.dealer_enquiries.buttonMode = true;
bottom_menu.buttons.dealer_enquiries.useHandCursor = true;
bottom_menu.buttons.gallery.buttonMode = true;
bottom_menu.buttons.gallery.useHandCursor = true;
bottom_menu.buttons.help_n_support.buttonMode = true;
bottom_menu.buttons.help_n_support.useHandCursor = true;
// MAIN CLICK FUNCTIONS
function mainClick_homepage(e:Event):void {
i.load(new URLRequest("index.swf"));
container.content_container.addChild(i);
menu_mc.sub_nav.gotoAndStop(0);
}
function mainClick_about_us(e:Event):void {
i.load(new URLRequest(bottom_level_nav_loc+"about_us.swf"));
container.content_container.addChild(i);
menu_mc.sub_nav.gotoAndStop(0);
}
function mainClick_dealer_enquiries(e:Event):void {
i.load(new URLRequest(bottom_level_nav_loc+"dealer_enquiries. swf"));
container.content_container.addChild(i);
menu_mc.sub_nav.gotoAndStop(0);
}
function mainClick_gallery(e:Event):void {
i.load(new URLRequest(bottom_level_nav_loc+"gallery.swf"));
container.content_container.addChild(i);
menu_mc.sub_nav.gotoAndStop(0);
}
function mainClick_help_n_support(e:Event):void {
i.load(new URLRequest(bottom_level_nav_loc+"help_n_support.sw f"));
container.content_container.addChild(i);
menu_mc.sub_nav.gotoAndStop(0);
}
//MOUSE OVER FUNCTIONS
function mouse_over_homepage(e:Event):void {
c.setTint(over_settings_1, over_settings_2);
bottom_menu.buttons.homepage.transform.colorTransf orm=c; //mc is a MovieClip
}
function mouse_over_about_us(e:Event):void {
c.setTint(over_settings_1, over_settings_2);
bottom_menu.buttons.about_us.transform.colorTransf orm=c; //mc is a MovieClip
}
function mouse_over_dealer_enquiries(e:Event):void {
c.setTint(over_settings_1, over_settings_2);
bottom_menu.buttons.dealer_enquiries.transform.col orTransform=c; //mc is a MovieClip
}
function mouse_over_gallery(e:Event):void {
c.setTint(over_settings_1, over_settings_2);
bottom_menu.buttons.gallery.transform.colorTransfo rm=c; //mc is a MovieClip
}
function mouse_over_help_n_support(e:Event):void {
c.setTint(over_settings_1, over_settings_2);
bottom_menu.buttons.help_n_support.transform.color Transform=c; //mc is a MovieClip
}
//MOUSE OUT FUNCTIONS
function mouse_out_homepage(e:Event):void {
c.setTint(out_settings_1, out_settings_2);
bottom_menu.buttons.homepage.transform.colorTransf orm=c; //mc is a MovieClip
}
function mouse_out_about_us(e:Event):void {
c.setTint(out_settings_1, out_settings_2);
bottom_menu.buttons.about_us.transform.colorTransf orm=c; //mc is a MovieClip
}
function mouse_out_dealer_enquiries(e:Event):void {
c.setTint(out_settings_1, out_settings_2);
bottom_menu.buttons.dealer_enquiries.transform.col orTransform=c; //mc is a MovieClip
}
function mouse_out_gallery(e:Event):void {
c.setTint(out_settings_1, out_settings_2);
bottom_menu.buttons.gallery.transform.colorTransfo rm=c; //mc is a MovieClip
}
function mouse_out_help_n_support(e:Event):void {
c.setTint(out_settings_1, out_settings_2);
bottom_menu.buttons.help_n_support.transform.color Transform=c; //mc is a MovieClip
}
Quick Code Snippet Help.
Not even high doses of caffeine have helped me figure this one out. I am almost bald with hair pulling now. =)
Should be easy, tried everything. I want to populate the outside variable login_auth.
Here's the code:
login_auth ='';
login.submit_btn.onRelease = function(){
if (login.user_login.text != "" && login.pass_login.text != "") {
//status = "Begin Login Process - Wait...";
lognVars = new LoadVars();
lognVars.u = login.user_login.text
lognVars.p = login.pass_login.text
lognVars.sC = coupon.md5()
lognVars.sendAndLoad(php_file, lognVars, 'POST');
lognVars.onLoad = function(){
login_auth = this.uu;
}
}
track_display_mc.display_txt.text = login_auth;
login._visible = false;
enableButtons();
}
no matter how I try with using _root or _parent or _parent._parent or _level0 or just like it is, the variable login_auth outside the function never gets populated/changed when the submit button is clicked the first time. To make this even more frustrating I can see it changing locally in the lognVars.onLoad function correctly, and if I then click the submit button again a second time it populates the outside login_auth variable just fine. The code above only works every other one... always on the second click of the button. Help! thank You!
Quick Cfc Code Check Please.
ActionScript Code:
import mx.remoting.*
import mx.rpc.*
var myresponder:RelayResponder = new RelayResponder(this,"getCombobox_con_Result","getCombobox_con_Fault");
var getCombobox_con:Service = new Service("http://localhost/flashservices/gateway",null,"getData_uf",null,myresponder);
var pc:PendingCall = getCombobox_con.getComboxitems();
function getCombobox_con_Result(result){
// display successful result
trace(getCombobox_con.results.getLength())
}
function getCombobox_con_Fault(fault){
trace("error")
}
is there something I am missing to get the result back as a recordset obj? I am getting undefined.
in my cfc I have the returntype="query" do I have to change that?
when using the remoting connector component its fine but I rather do it manually.
is relay responder the quickest way to have a function called when the results get back?
thanks.
Quick Code Conversion Help, Please
The problem is that this code was written (obviously) to be on a button, but I'm now using a keyListener instead and for the life of me, I can't get this code to convert away from the on(release) aspect to regular code.
Could someone please fix this for me so that the code works with:
KeyListener = new Object();
KeyListener.onKeyDown = function() {
if (Key.getAscii() == 13) {
checkMe();
}
};
Key.addListener(KeyListener);
Attach Code
onClipEvent (load) {
playOrder = new Array(1,2,3,4,5,6,7,8,9,10).sort(shuffle);
position = 0;
function shuffle():Number {
return Math.floor(Math.random() * 3) - 1;
}
}
on (release) {
_root.gotoAndStop(playOrder[position]);
this.gotoAndPlay(playOrder[position++]);
_root.txtAnswer.text = " "
if (position >= playOrder.length) {
_root.gotoAndStop(11);
playOrder.sort(shuffle);
position = 0;
}
}
Quick Code Question
I know this is VERY basic and easy, so forgive me, but I just need to know how to change this code. What I tried didn't work.
I'm using a tutorial to make a menu, and in the tutorial it assumes that you're starting with a new .fla, but instead I made a movie clip for the menu within an .fla I was already working on, for a header.
The code I was supposed to use was this one, for the invisible button:
Code:
on (rollOver) {
_root.mouse_over_company_mc= true;
}
on (rollOut) {
_root.mouse_over_company_mc= fstartlse;
}
on (release){
getURL(”http://www.mysite.com/”);
}
and for the main action script, this:
Code:
_root.company_mc.onEnterFrame = function() {
if (mouse_over_company_mc) {
_root.company_mc.nextFrame();
} else {
_root.company_mc.prevFrame();
}
};
So what I did was everytime I saw "_root", I changed it to "menu_mc." but it didn't work.
Also, even though I put a stop action on my menu movie clip, the animation keeps going and doesn't stop.
Sorry again for the n00biest question....
thanks!
Scripting Is Supposed Flash Movie Much Cleaner
Scripting is supposed flash movie much cleaner, there should be a straight forward way to do this.
the example we can call "test.swf"
the movie clip we will call "fade" which resides inside the library
"fade" extends over 50 frames the first 30 have a snazzy animation upon a mouse click on a button in the main menu.
I would like to use this movie clip again just starting at frame 30. My question is can you reference a frame label inside the "fade" clip from the "test.swf?"
Note tell target is usefull by adding a ../ script you can exit a movie clip. Can you preform this code to enter in a clip?
Much thanks
aspiring asssstronaught
Quick Question About This Timer Code
does anyone know if this timer code eats up a lot of CPU? and is there any easier way to go about this?
Code:
_global.timeReset=function(){
start = getTimer();
limit=1;
};
_global.cTimer = function(){
elapsed=Math.round((getTimer()-start)/1000)
_root.timeRemain=left=limit-elapsed
_root.timeleft = left;
if(left<=0){
counter = 0;
}
};
setInterval(cTimer, 25);
Quick Question. Confused About This Code.
I am trying to figure out one of Senocular's fla's.
http://www.interactive.toolblast.com...&ucat=2&kind=2
This is a small segment of code that is confusing me. The only thing you need to know is that that "next" is a variable.
buttonHandling = function () { if (next == this._parent.movie) {return;}if (next) {if (next._currentframe != 11) {return;}......
What does "if (next)" mean? I am used to seeing statements like "if (next == mcCow" or whatever. But ive never seen "if (variable)". If someon could clarify that for me then i'll be able to figure out the rest of the .fla. THANKS!
Quick Code For Storing Variables
I need a quick script that can allow me to store data in an external file (such as a .txt file) then load it up the next time I run the movie. These events both happen after a button press.
Any help is appreciated.
Real Quick Code For Popup
I created a flash site which opens a new browser box using:
on (release) {
getURL ("JavaScriptop();");
}
As the action.
In the HTML page i have.....
function pop() {
window.open("http://www.thewoj.com/main.html","","height=550,width=790,left=0,top=0") ;
}
It all works fine, HOWEVER.... I don't know the code to use to CLOSE this popup box with a flash button.
Anyone know??
-Steve
Quick Q: On Draw Circ Code
so this prototype draws circles:
PHP Code:
MovieClip.prototype.dc=function(x,y,r){
var a=r*0.414213562;
var b=r*0.707106781;
this.moveTo(x+r,y);
this.curveTo(x+r,y-a,x+b,y-b);
this.curveTo(x+a,y-r,x,y-r);
this.curveTo(x-a,y-r,x-b,y-b);
this.curveTo(x-r,y-a,x-r,y);
this.curveTo(x-r,y+a,x-b,y+b);
this.curveTo(x-a,y+r,x,y+r);
this.curveTo(x+a,y+r,x+b,y+b);
this.curveTo(x+r,y+a,x+r,y);
}
im curious to why those two #'s 0.414213562 & 0.707106781 ???
thnx !!~~
Check My Preloader Code Please? (very Quick)
Hi folks.
Need help before I can post my files, not feeling very confident I've done this right, but it seems to work just fine so...
Would somebody check my code please and make sure there isn't something catastrophically bad in it:
1st frame of main timeline:
this.onEnterFrame = function() {
filesize = content.getBytesTotal();
loaded = content.getBytesLoaded();
preloaderMC._visible = true;
if (loaded != filesize) {
preloaderMC.loadBar._xscale = 100*loaded/filesize;
} else {
preloaderMC._visible = false;
content._visible = true;
}
}
That's it, that's all I have. I don't remove the onEnterFrame if I'm loading say 100 jpgs, right?
Thanks so much!
-Beanpie
Frame Rate Quick Code
WoW... i've writen code so much harder... this seems so simple but i cant figure out the logic or commands to do it.
Q. How would i make a movieclip with a text box inside called FrameRate show the frame rate.
To make it easy im just going to put the code on the movieclip itself.
Thanks Guys in advanced.
AS3 Quick Code Snippet Needed
I've been looking but since I don't really know my end result, it's hard to search correctly.
I basically need
Code:
onRelease {
this.gotoAndPlay (2)
}
converted to AS 3. I mildly understand classes / functions but just don't know enough AS3 yet. Any help is appreciated.
This is my current code.
Code:
this.menuBox_mc.contact_btn.addEventListener(MouseEvent.MOUSE_DOWN,rotateImage);
-----
function rotateImage (e:MouseEvent) {
_root.images.gotoAndPlay(2);
}
Check My Preloader Code Please? (very Quick)
Hi folks.
Need help before I can post my files, not feeling very confident I've done this right, but it seems to work just fine so...
Would somebody check my code please and make sure there isn't something catastrophically bad in it:
1st frame of main timeline:
this.onEnterFrame = function() {
filesize = content.getBytesTotal();
loaded = content.getBytesLoaded();
preloaderMC._visible = true;
if (loaded != filesize) {
preloaderMC.loadBar._xscale = 100*loaded/filesize;
} else {
preloaderMC._visible = false;
content._visible = true;
}
}
That's it, that's all I have. I don't remove the onEnterFrame if I'm loading say 100 jpgs, right?
Thanks so much!
-Beanpie
Frame Rate Quick Code
WoW... i've writen code so much harder... this seems so simple but i cant figure out the logic or commands to do it.
Q. How would i make a movieclip with a text box inside called FrameRate show the frame rate.
To make it easy im just going to put the code on the movieclip itself.
Thanks Guys in advanced.
Quick Question Regarding Sound Effects Code.....
I have a pretty quick question, hopefully gonna be an easy one to answer.
I have a function created to play background sounds, this basically implements the "attachSound", sound.start(); code however, when i want to play specific sound effects i would like to pause this background loop so that the sound effect can be heard clearly without interference.
To do this i have set up a basic variable which is set to "true" when the sound.start(); code is used, this defines that the sound loop IS playing.
Then when I want to stop the sound loop and play a sound effect i know i can use a simple "if" statement which stops the loop if the value is "true" and then play a sound effect.
BUT my problem is: how can i get it to recognise when the sound effect has finished playing, so that the background loop starts up automatically? I hope i have explained myself well enough
Quick Email Form Code Question
I went to actionscript.org and checked out the code for a contact form in flash. This template already had a contact form there, but no code in it.
I took the code I found from actionscript.org, and used it in the template, but I think I might be missing something small here.
Could someone help me by looking at the file?
Thanks in advance!
http://www.lastdaydesigns.com/PODD2/main.zip
AS3 Writing Concise Code - Quick Question
mc1.alpha=.5;
mc2.alpha=.5;
mc3.alpha=.5;
etc.
Can be shortened to:
mc1.alpha=mc2.alpha=mc3.alpha=.5;
Can this be shortened even more? I would ideally like to write my property only once.
[MX04] A Not So Quick Favor - Looking For Somone To Edit My Code
Hey gang,
I know you all are busy people and this post may not go anywhere beyond this point, but I was wondering if there was a brave soul out there with a bit of time on his or her hands that would be so kind as to take a look at my code for a website I'm building and see if there are any places where I can tighten it up. I'm having a bit of performance issues and I'd like to make sure my code is as clean as possible to ensure a smoother site. Currently the code is 1134 lines long, and the .swf is 204k, which isn't terrible, but could stand to be looked at.
Rather than post the code here, I thought I'd just put the request out there. If you are feeling kind enough to take a look, please PM me and I'll send it along.
The code all works, BTW... it's just a little dirty.
Anyway, if nothing more comes of this post, that's totally cool. I know I'm asking a lot and am greatful to any person who wants to take a stab at it.
Thanks in advance!
-Sandy
HElp QUick PLEase Load In Html Code To Be Displayed In Htmlbox
HEY!
i have a dead line due very soon on a project and a part i though would be veary easy isent...
im opening this page to import variables:
http://www.valj.nu/live/script/show.php
that variable is being read in by
ActionScript Code:
kc = new LoadVars();kc.load("http://www.valj.nu/live/script/show.php");if (kc.loaded==true){ trace("done"); kc.onLoad = function() { trace(this.hej); info_txt.text=this.hej; };};
done traces, and then inbetween it traces blank spaces...
info_txt.text
is a dynamic textbox with the html button pressed.
why is nothing showing?
thanks
//VoS
Quick Code Fix For Externally Loaded Flash File
hi there, i know that someone out there can easily take a look at my problem and know immediately what i did wrong. but that's not me!
i have a test website here which has externally loaded files coming into the container on the main index page. the code on the buttons at the top right hand corner have this code on each of them for the externally loaded .swf files to come in:
on (release) {
if (_root.currMovie == undefined) {
_root.currMovie = "contact";
container.loadMovie("contact.swf");
} else if (_root.currMovie != "contact") {
if (container._currentframe>= container.midframe) {
_root.currMovie = "contact";
container.play();
}
}
}
and that all works perfectly fine. what my problem is is when i click on the "contact" button and i'm on that page. on the left hand side column towards the bottom, i have a block of text with one red word. i want that word to bring in the f.a.q. page (and replace the contact page i'm currently looking at) which can also be accessed from the top nav. just a little thing, but i wanted to learn how to do it.
i've put the same code into the invisible button that says "faq" which is identical to the code listed above except i changed all instances of "_root" to "_parent" but that didn't do it. i think it's something like that that would have to do with the problem. any help is appreciated!
thanks,
denise
[quick N Dirty Code Snippet] Text Ticker
Here you go.... a text ticker, often asked for - pretty basic but very easy code:
ActionScript Code:
createTextField("content3_txt",this.getNextHighestDepth(),0,0,Stage.width,200);
content1="-- You bet on Black? ----- It came up Red? ----- For an affordable debt solution visit Grabbit & Run Associates......";
tcount = 0;
content2 = " ";
tlength = 50;
secs = 0.05;
for(i=0;i<=tlength;i++){
content1+=" ";
}
init(2);
//
function init(num){
myTInt = setInterval(scrollT, secs*1000);
loops=num
}
function scrollT() {
content2 = content1.substring(tcount-tlength, tcount+1);
content3_txt.text = content2;
tcount++;
if(tcount==content1.length){
if(loops==1){
clearInterval(myTInt)
trace("finished");
}else{
tcount=0
loops-=1;
}
}
}
Questions? None? Good.....
Problematic Flash Files: "Cleaner" Needed (Paid)
Hello all,
I've hit a wall in several small Flash movies that are integrated into one online course, things that I'm sure I can figure out with time, but time is something I ain't got. I need a Flash wiz who can figure out what I've done wrong, improve the actionscripting where necessary, and also finish off some elements that have me stumped (and tell me what I've done wrong in the process). It's actually pretty basic stuff...and all the major groundwork has been done...but there might be a few challenges. You need to be familiar with video/audio integration...everything else is standard stuff.
If you're interested, please send me an e-mail and let me know your preferred method of payment: hourly or project-basis...and if you prefer hourly, please let me know your hourly rate since I have to get approval. Also, please include a link to your Flash portfolio.
BTW - This could possibly lead to a long-term project-basis work relationship.
Thanks! I hope to hear from you!
John
|