Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








[F8] Why Are My Variables Behaving Weird?


hi guys
just run into a problem with my variable use - i am using the variable 'page' to let flash know which page of the website the user is viewing, and therefore which quote should be displayed when the user mouses over something. i am saying...

Code:
if (_root.page == home) {
this.tag.gotoAndStop("quote1");
}
if (_root.page == contact) {
this.tag.gotoAndStop("quote6");

(i have tried loosing the _root.'s before the variables, no different) - what i get is that the quote displayed is always quote6, even though i have defined the var 'page' as home on the home page. i did trying making this an if/else statement - what happened then was that the quote displayed was always quote1! i'm stumped... so if anyone can help i'd be very happy - here's the .fla...
http://myweb.tiscali.co.uk/murderkins/gv/gv04.fla
(the code is within the tagline at the bottom, which changes into the quote when the user mouses over either the line of red text or the name next to it)
thanks!!
emma.




FlashKit > Flash Help > Flash ActionScript
Posted on: 01-29-2007, 11:02 AM


View Complete Forum Thread with Replies

Sponsored Links:

Why Are My Variables Behaving Weird?
hi guys
just run into a problem with my variable use - i am using the variable 'page' to let flash know which page of the website the user is viewing, and therefore which quote should be displayed when the user mouses over something. i am saying...

Code:
if (_root.page == home) {
this.tag.gotoAndStop("quote1");
}
if (_root.page == contact) {
this.tag.gotoAndStop("quote6");
(i have tried loosing the _root.'s before the variables, no different) - what i get is that the quote displayed is always quote6, even though i have defined the var 'page' as home on the home page. i did trying making this an if/else statement - what happened then was that the quote displayed was always quote1! i'm stumped... so if anyone can help i'd be very happy - here's the .fla...
http://myweb.tiscali.co.uk/murderkins/gv/gv04.fla
(the code is within the tagline at the bottom, which changes into the quote when the user mouses over either the line of red text or the name next to it)
thanks!!
emma.

View Replies !    View Related
IE Behaving Very Weird With Flashobject?
Since microsoft's lovely 'click here to activate'- bull**** I use the flashobject to embed my movies. Everything worked fine untill today I discovered that nothing worked anymore...?!
I do it like this:


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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="flashobject.js"> </script>
</head>

<body>
<div id="flash"></div>
<script type="text/javascript">
var fo = new FlashObject("movie.swf", "movie", "642", "260", "7", "#FFFFFF");
fo.write("flash");
</script>
</body>
</html>
Also it only seems to be on my laptop, maybe because that's the only place where I have the latest update...

Anyone have a clue, I really don't think this is funny...
It has always worked, and still works in ff...

View Replies !    View Related
Videos Behaving Weird
Hi everyone,

I have an application, which is essentially a videos/photos gallery...its done, now I am testing it, and i got a weird bug.

I have put my application(swf file) file on a web server, the videos(flv files) and jpg pics are also located on the same server. Now when i am opening the app URL on my system, its working fine, videos are pics are opening, videos are opening through client side streaming. However, on somebody else's system, videos goes fast forward on their own. This is a weird behavior and I have no idea what is causing this.


can anybody tell me, y is this happening?

View Replies !    View Related
Preloader Behaving Weird
Hi,
my preloader is working when its first run, but it doesn't go to the 2nd frame if the page is refreshed. (Its for a swf that has about 9,000 frames but I don't think thats the issue)


ActionScript Code:
onClipEvent (enterFrame) {    mctotal = _root.getBytesTotal();    mcloaded = _root.getBytesLoaded();    mcpercent = Math.round((mcloaded/mctotal)*100);    kb_load = Math.round(mcloaded/1000);    kb_total = Math.round(mctotal/1000);    loadBar._xscale = mcpercent;    loadKb = kb_load + "kb load /" + kb_total + "kb total";    loadText = mcpercent + "%";    if (mcpercent == 99) {        _root.gotoAndPlay(2);            }}


Any suggestions would be greatly appreciated

View Replies !    View Related
Variables Are Behaving Like Strings Instead Of Ints
Can anyone help me, especially as it's christmas?

I am working on something pretty simple, but for some reason have come across Flash being completely unwilling to handle a variable I am using as an integer.

Simply for testing purposes I had vars called

_root.ttpinspection = 0;
_root.inspection = 0;

on my startup script on mt first layer.

Then, when trying to use these vars from a movieclip it seems to want to handle them as strings.
I need to use them in an if(xxx != xx) statement.

Is this a bug because I have done this before, and, frankly, it should work.

View Replies !    View Related
Weird Stuff In AS With Variables
I have a piece of code wich basically comes down to this,


Code:
// EMPTY ARRAY
var varA=new Array();
// MULTI-D-ARRAY WITH INTEGERS
var varB=new Array([1,2,3],[4,5,6],[7,8,9]);
// VAR-A GETS ALL VALUES OF VAR-B
varA=varB;
// ADD 5 TO FIRST INTERGER IN ARRAY VAR-A
varA[0][0]+=5;
// SOMEHOW THIS AFFECTS VAR-B BECAUSE OUTPUT = 6 (1+5)
trace(varB[0][0]);
So i pass the values of one array "varB" into an other "varA" and then mutate array "varA" but this also affects "varB". The help reference tells this,


Quote:




Array assignment is by reference rather than by value: when you assign one array variable to another array variable, both refer to the same array:
ActionScript:

Code:
var oneArray:Array = new Array("a", "b", "c");
var twoArray:Array = oneArray;
// Both array variables refer to the same array. twoArray[0] = "z";
trace(oneArray);
// Output: z,b,c.





Is there a way to pass an array by value to an other array so i can mutate one and keep the original intact.

View Replies !    View Related
Send Variables....weird One
asp page with flash embedded.

im sending mail from flash form. that works fine.
the asp is......

Code:
<%
' change to address of your own SMTP server
strHost = "smtphou.airband.net"
If Request("Send") <> "" Then

Set Mail = Server.CreateObject("Persits.MailSender")
' enter valid SMTP host
Mail.Host = strHost

Mail.From = Request("From") ' From address
Mail.FromName = Request("FromName") ' optional
Mail.AddAddress Request("To")

' message subject
Mail.Subject = Request("Subject")
' message body
Mail.Body = Request("Body")

strErr = ""
bSuccess = False
On Error Resume Next ' catch errors
Mail.Send' send message
If Err <> 0 Then ' error occurred
strErr = Err.Description
strResult = "An Error Has Occurred :" & strErr
else
strResult = "Your Message Has Been Sent"

End If
End If
%>
from within flash i call invoke that by posting all my data with a
loadVariablesNum() function, so that the page doesnt have to refresh.


problem is I have no idea how to bring 'strResult' into flash so that i can no when to quit looping the "sending mail" movie clip and display whether or not the mail was sent.

thx.

View Replies !    View Related
Weird Changing Variables
Hi!

I need urgent help!

URL

Here is the gallery i'm working on. You can click on a gallery and it'll show you the pictures. I have had problems with Flash centering and resizing the photo so now I'm using PHP to send me those coorinates.

But now, try clicking on the same picture VERY fast repeatedly (like double click or those video games...). it disappears after 7-8 clicks... I've made a textbox on top that shows the height the picture is supposed to be and the reported height.

URL

Please take a look and tell me ANY clues u might have!

THANKS IN ADVANCE

View Replies !    View Related
Passing Weird Variables To A URL Using POST
I have a question that is stumping me....

I am trying to POST variables to a website using getURL, which I don't have a problem with, the problem that I have is posting variables that look like this:

acct[first_name] = tafFirstName;
acct[last_name] = tafLastName;
acct[email] = tafEmail;
acct[dphone] = tafTelephone;

getURL("http://www.yoursite.com/order.php", "_blank", "POST");

Because the name of the variables has a bracket "[" they are not being viewed as variables. How can I make it so that the variables being passed through the POST feature look just like these with the brackets included?

I know I can do this with the GET function, but this form will not allow me to send the variables via GET.

Thank you for your help!

View Replies !    View Related
Weird Problem With Variables/menu
Ok, to make a long story short, here's what I have:

A main menu with several buttons. Each button, when pressed, activates a _global variable (let's call it "choice".. or _global.choice) that assigns a number depending of the button you pressed (_global.choice = 1 if you pressed button number 1, and so on).

Then I have a transition scene, basically it hides all the buttons in a very pretty way and in the last frame of this scene, there's some IF's that will take the number assigned to the variable "choice" and depending on the number it sends you to the correct scene.

(i.e. if (_global.choice == 1){ gotoAndPlay("Scene1",1); }

Here's the problem. The last of my buttons on the main menu (I have 6 of them) takes me to an incorrect Scene. Yes, I've doublechecked my variables, the numbers and the IF's conditions. Everything is correct. What puzzles me the most is that I even set a breakpoint (both in the button code and the transition scene code) and when I debugged it, it worked. I proceeded then to hit the "back button and remove the breakpoint (still in the debugger) and try it again.... guess what? It didn't work.

This mysterious bug is driving me crazy. Any help or suggestions are very much welcome and appreciated!

Oh and sorry if I posted this on the wrong forum...

Thanks in advance!

View Replies !    View Related
Weird Problem With Variables/menu
Ok, to make a long story short, here's what I have:

A main menu with several buttons. Each button, when pressed, activates a _global variable (let's call it "choice".. or _global.choice) that assigns a number depending of the button you pressed (_global.choice = 1 if you pressed button number 1, and so on).

Then I have a transition scene, basically it hides all the buttons in a very pretty way and in the last frame of this scene, there's some IF's that will take the number assigned to the variable "choice" and depending on the number it sends you to the correct scene.

(i.e. if (_global.choice == 1){ gotoAndPlay("Scene1",1); }

Here's the problem. The last of my buttons on the main menu (I have 6 of them) takes me to an incorrect Scene. Yes, I've doublechecked my variables, the numbers and the IF's conditions. Everything is correct. What puzzles me the most is that I even set a breakpoint (both in the button code and the transition scene code) and when I debugged it, it worked. I proceeded then to hit the "back button and remove the breakpoint (still in the debugger) and try it again.... guess what? It didn't work.

This mysterious bug is driving me crazy. Any help or suggestions are very much welcome and appreciated!

Oh and sorry if I posted this on the wrong forum...

Thanks in advance!


PS. I'm using Flash MX, by the way!

View Replies !    View Related
Loading Variables From ASP.NET Acting Weird
Here is my AS code:
var urlRequest:URLRequest = new URLRequest("ASP/sample_codebehind.aspx");
var urlLoader:URLLoader = new URLLoader();
urlLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
urlLoader.addEventListener(Event.COMPLETE, urlLoader_complete);
urlLoader.load(urlRequest);

function urlLoader_complete(evt:Event):void
{
trace(urlLoader.data.lastName);
trace(urlLoader.data.firstName);

testInput.text = urlLoader.data.firstName + " " + urlLoader.data.lastName;
}

Here is my .aspx page:
<%@ Page Language="c#" src = "sample_codebehind.aspx.cs"%>

<html>
<head>
<title>Code Behind Example</title>
</head>
<body>
<% Response.Write("&firstName=Jonn&lastName=Jonnnes") ; %>
</body>
</html>

Why is it that I am getting the values 'Jonn' for first name(this is correct), and 'Jonnnes");

</body>

</html>
' for the last name. It is just taking everything after &lastName and assigning that to the variable. Why is this? Thanks!

View Replies !    View Related
Variables From XML And Functions- Weird Things, Please Help?
I have several variables that I am dynamically loading from XML. Weird things are happening.

The variables are loading just fine and dandy from the XML in the first lines of my AS. I'll try a a trace and it says yes- variablebob= 52

Further down in my AS, I need those variables to use in functions. In a regular function and an onEnterFrame function. suddenly variablebob can't be found. I need to ask it to go back to my XMLdocument and redefine the variable.

Is there something I need to know about variables from XML and functions?

View Replies !    View Related
XML Loader, Weird Variables ... And It's Broken
here's the code:


ActionScript Code:
function XML_loader() {
    sectionContent = new XML();
    sectionContent.ignoreWhite = true;
    for (i=1; i<=16; i++) {
        sectionContent.load("xml/s" + i + ".xml");
        trace ("xml/s" + i + ".xml");
    }
    sectionContent.onLoad = function(success) {
        if(success) {
            for (i=1; i<=16; i++) {
                this["s" + i + "_XML"] = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
                trace (s1_XML);
            }
        }
    }
}


When I trace out 's1_XML' it just comes back undefined. It should show the contents of the file 'xml/s1.xml'. Right?

View Replies !    View Related
Passing Variables Between Swf, Weird Stuff Happening...
Ok: I'm making a glossary for a school project, the problem that came up is weird:
I have one main swf : glossary.swf and one search swf : search.swf.
I've got one input field "search_string", and on the "go" button it loads search.swf in like this:

Code:
loadMovieNum ("search.swf?s="+search_string, 10);
gotoAndStop ("load_simple_search");


search.swf picks up the "s" variable (I can see it in a text field)
BUT: I then go on and load the search(within search.swf) with :

Code:
loadVariablesNum ("search.php?search=simple&search_string="+ this.s, 10, "POST");


The search class is working perfectly when loaded in the browser. (So the problem is not there)
Let's say that i pass "s=sale", then the search.php returns 0 results (once again I can see this in a text field), but when I put "sale sale sale" into the search_string field, I get back 15 (wich it should do according to if I look it up in search.php)

Now: why would this happen??
I've tried a lot of combinations on this, I even duplicated search_string 3 times and sent it to search.swf, but it still would not work.......

Can you see anything wrong here?? I've been working myself blind on this problem right now.

Thanks!

View Replies !    View Related
.FLA Not Behaving
Hi all,

Let’s try this one on for size. I’m attempting to have an alphabetized, embedded scrolling list of many items (probably close to 100). And each thing has to link to a different URL. There are two different issues with this one:

1. I got the scroll to work, but the text won’t resize for me. It insists on remaining bigger than I want it, although the properties tab SAYS it’s the right size. Why won’t it save and display in the font size I want? Is there some behind-the-scenes setting when converting to the SWF?

2. I can’t for the life of me get the link box to activate so I can make the lines link to URLs. It’s “grayed out” so that I can’t use it. So then I tried to associate a mouse-down event, but when I convert to SWF it tells me that those events are only for buttons, not text. How can I get each line to link?

The .FLA file is here: http://www.smithcomputer.net/scroller/launch.fla

The .SWF in progress is on the right side of this page: http://www.wallnj.com/new

HELP???

Thank you so much!

View Replies !    View Related
Help: Weird Or Not So Weird Thingy With Dynamic Text Animation
http://www.david.bullaro.com/

there are 3 buttons on the right side education, experience and awards. Each loads an MC that then motion tweens into view from the side. The MC dynamically loads a text file. At the end the text blinks once. I understand the blink because i needed to reload the text for that keyframe but is there anyway around that blink?

TIA.

View Replies !    View Related
Movieclip Not Behaving Right
Can someone tell me what is wrong with this? I have a stick figure, and I have an animation of him walking, both on top of each other, in a movieclip. When the user pushes down one of the arrow keys, the animation of the guy standing still is supposed to disappear, and the one of him walking should appear. But for some reason, it only works for the right arrow key. Anyone know why?

View Replies !    View Related
[fmx] Button Not Behaving Itself
I have made a button - named "menu_btn" this button has up, over, down and hit states. It has no Linkages.

I have a movie clip - named "menu_item" this movie clip contains the "menu_btn" button and has a dynamic text textfeild named "item_caption" on top of the button. It has Linkages, Export for ActionScript, Export in first frame.

I have the following function...

//create menu based on xml file
function makeMenu(sectionMenu) {
//set the initial on screen text to the text of the first section
text_txt.text = sectionMenu.pmntasection[0].pmntasectionText;
//create movie clip to hold menu items
_root.createEmptyMovieClip("tc", 1);
//set the position on screen of the movie clip that holds the menu items
tc._x = 90
tc._y = 110
//loop through adding menu items
for(var i = 0; i < sectionMenu.pmntasection.length; i++) {
//attach item_btn movie clips
var c = tc.attachMovie("item_btn", "chap" + i, i);
//set the position of the item_btn movie clips
c._y = 35 * i;
//put the text on the menu items
c.item_caption.text = sectionMenu.pmntasection[i].pmntasectionName;
c.chapNumber = i;
//add the action to the button
c.onRelease = function() {
text_txt.text = sectionMenu.pmntasection[this.chapNumber].pmntasectionText;
}
}
}

It all works fine except the button states do not change. The squirrel finder example tutorial on Kirupa (http://www.kirupa.com/web/xml/examp...irrelfinder.htm) does what I want to do, and I have made my movie the same - well I must be missing something - but what? where am I going wrong? Please help as I've been trying to crack this all weekend. Thanks.

View Replies !    View Related
[CS3] Button Not Behaving
I'm new to actionscript so please help me if you can.

I've got a main time line with a movie clip called "main" on it. On "main" I have several buttons and each need to set a variable called "destination" to a different value. Then in "main" I aso have another movie clip called "leavinghome".

I've set a variable called "location" on the first frame of "main" and set it equal to 0. This one works perfectly with the code below so when you press the first button, it goes to the frame called "leavinghome".

At the end of the "leavinghome" movieclip timeline, I want the last frame to direct you to a frame called "atRC" back on the timeline of "main".


Here's my code for the first button on "main":

on (release) {
var destination = 1;
if (location == 0) {
gotoAndPlay("leavinghome");
}
if (location == 1) {
gotoAndPlay ("leavingrc");
}
if (location == 2) {
gotoAndPlay ("leavingcontactus");
}
if (location == 3) {
gotoAndPlay ("leavingstudentgrowth");
}
if (location == 4) {
gotoAndPlay ("leavinggallery");
}
if (location == 5) {
gotoAndPlay ("leavingevents");
}

}

and here's my code for the last frame of "leavinghome":

if (destination == 1){
_root.main.gotoAndStop ("atRC");
}


It's playing the "leavinghome" moveclip, but then just repeating it instead of going to the previous level and playing the frame "atRC".
If I take out the "if destination == 1" part, it will work right, but I need it to only work if the variable destination equals 1.

Any ideas?

View Replies !    View Related
The Text Is Not Behaving Well
hi all!

situation:
a production has been developed for some time, a version online on ftp is behaving normally. BUT, uploading the same version again or more recent versions show a problem with the text. Very ambiguous! The project was
originally developed in flash 8.

the problem
my guess isthat the problem itself derives from this line of code:
textStreng = textStreng.split("
").join("");
what it does is that some times the text does NOT break line and some
texts seem to get an EXTRA linebreak (for instance the menu gets twice as long).

now what?
I can't seem to figure out if there is a problem with my .swf's, the browser,
flashPlayer? or something else since the behaviour is some what ambiguous.
I have already tried converting from flash8 to CS3 and back and forth with no luck, just to make sure that working in CS3 has afected the files.

note this
the swf's are working locally just fine, it's when I upload to an ftp that the text stops working. There's no point sending any patches of code now
since I'm not even sure it's a code problem, it worked fine before so...
I am really trying to get my head around this and would like as much help
that I can get!

cheers

View Replies !    View Related
HELP Key.getCode() Is Not Behaving
Create a new Movie and a movie clip with the instance name "deleteClip"

Notice that every key on the keyboard shows a propper keycode now press the delete key it doesn't work. not press CTRL-DELETE wow. what the?

ctrl-delete reports keycode 46 which is the delete key.

anyone know why?


HTML Code:
myObj = new Object();
myObj.onKeyDown = function() {
switch(Key.getCode())
{
case 46:
{
deleteClip.unloadMovie();
trace("KeyPressed: "+Key.getCode());
break;
}
default:
{
trace("KeyPressed: "+Key.getCode());
}
}
}
Key.addListener(myObj);

View Replies !    View Related
Button Not Behaving Itself
I have made a button - named "menu_btn" this button has up, over, down and hit states. It has no Linkages.

I have a movie clip - named "menu_item" this movie clip contains the "menu_btn" button and has a dynamic text textfeild named "item_caption" on top of the button. It has Linkages, Export for ActionScript, Export in first frame.

I have writen the following function...


ActionScript Code:
//create menu based on xml file
function makeMenu(sectionMenu) {
//set the initial on screen text to the text of the first section
text_txt.text = sectionMenu.pmntasection[0].pmntasectionText;
//create movie clip to hold menu items
_root.createEmptyMovieClip("tc", 1);
//set the position on screen of the movie clip that holds the menu items
tc._x = 90
tc._y = 110
//loop through adding menu items
for(var i = 0; i < sectionMenu.pmntasection.length; i++) {
//attach item_btn movie clips
var c = tc.attachMovie("item_btn", "chap" + i, i);
//set the position of the item_btn movie clips
c._y = 35 * i;
//put the text on the menu items
c.item_caption.text = sectionMenu.pmntasection[i].pmntasectionName;
c.chapNumber = i;
//add the action to the button
c.onRelease = function() {
text_txt.text = sectionMenu.pmntasection[this.chapNumber].pmntasectionText;
}   
}
}

It all works fine except the button states do not change. The squirrel finder example on this site (http://www.kirupa.com/web/xml/examp...irrelfinder.htm) does what I want to do, and I have made my movie the same - well I must be missing something - but what? where am I going wrong? Please help as I've been trying to crack this all weekend. Thanks.

View Replies !    View Related
Mc's Behaving Like Buttons
ok i have 5 mc's behaving like buttons (company,vacancies,register,contact and terms) on frame 1 on the main timeline. e.g. company movie clip with this actionscript;

ActionScript Code:
//company button//
CMC_S.onRollOver = function (){
CMC_S.gotoAndStop ("CMCS" )
}

CMC_S.onRollOut = function (){
CMC_S.gotoAndStop ("CMC" )
}


//and within e.g. company movie clip I have 2 frames, on frame 1 is the word company (text) with a frame label "CMC" with this actionscript;//

stop();

//and in frame 2 i have 4 mc's (company_red, company_blur, company_blur_up, company_blur_accross) with a frame label "CMCS" with this actionscript;//

stop();

companytext .onEnterFrame = function () {
        //this makes the clip go crazy
        this._alpha = random(100);
        this._xscale = 100;
        this._yscale = 100;  
};
company3.onEnterFrame = function () {
        //this makes the clip go crazy
        this._alpha = random(100);
        this._xscale = 100;
        this._yscale = 100;  
};
company4.onEnterFrame = function () {
        //this makes the clip go crazy
        this._alpha = random(100);
        this._xscale = 100;
        this._yscale = 100;  
};
company5.onEnterFrame = function () {
        //this makes the clip go crazy
        this._alpha = random(100);
        this._xscale = 100;
        this._yscale = 100;  
}

These codes are the same for all the other (vacancies,register,contact and terms) mc's and for the 4 mc's within these.

What i would like to do is put all these actionscripts on 1 layer in 1 frame on the main timeline and as the actionscript for all the mc's is the same i would like to clean up the actionscript with either an array (not sure) or a prototype but i dont know how too. That is if the actionscript is correct (unless there's an easier way to make my clip's flicker on rollover).

Also how do you disable a movie clip acting as a button once its been pressed

As always any help wouls be appreciated.


"Where to begin, so many questions, so little time"

View Replies !    View Related
[FMX] Help Arrays Not Behaving?
Hello!

Going mad trying to work out why this code is not working... can any ActionScript gurus help a struggling designer?

Basically, the movie consists of a map with a couple of states which act as hotspots/buttons...


Code:

////////// button functions for each state
function stateOver(mc){
trace("stateOver("+mc+")");
mc.tween("_alpha",25,1,"easeoutsine");
}
function stateOut(mc){
trace("stateOut("+mc+")");
mc.tween("_alpha",0,1,"easeoutsine");
}
function stateHit(mc){
trace("stateHit("+mc+")");
mc._alpha = 35;
}
No probs. Next, a function to zoom in and move the map...


Code:
function zoomMap(xPos,yPos,scale){
_root.map_grid.tween(["_x","_y","_xscale","_yscale"],[xPos,yPos,scale,scale],1,"easeoutsine",0);
}
Now I assign those functions to each state...


Code:
function assignButtons(){
stateArray = ["stateWA","stateNT","stateQLD","stateNSW","stateVIC","stateSA","stateTAS"];
scaleArray = [180,220,200,280,330,280,300];
xPosArray = [-132,-426,-691,-1000,-1322,-795,-1055];
yPosArray = [-170,-9,-106,-500,-920,-495,-850];
numStates = stateArray.length;

for(i=0;i<numStates;i++){
_root.map_grid.hotspots[stateArray[i]]._alpha = 0;
_root.map_grid.hotspots[stateArray[i]].useHandCursor = false;

xPos = xPosArray[i];
yPos = yPosArray[i];
scale = scaleArray[i];
trace("xPos: "+xPos+" || yPos: "+yPos+" || scale: "+scale);

_root.map_grid.hotspots[stateArray[i]].onRelease = function(){
stateHit(this);
zoomMap(xPos,yPos,scale);
}
_root.map_grid.hotspots[stateArray[i]].onRollOver = function(){
stateOver(this);
}
_root.map_grid.hotspots[stateArray[i]].onRollOut = function(){
stateOut(this);
}
}

_root.map_grid.oceanZone.onRelease = function(){
zoomMap(0,0,85);
}
}
It's the _root.map_grid.hotspots[stateArray[i]].onRelease function is the one driving me mad. The preceding values for the xPos, yPos and scale correctly trace the corresponding values form their arrays, so why wont those values then be applied to each state in the onRelease function?


Code:
xPos = xPosArray[i];
yPos = yPosArray[i];
scale = scaleArray[i];
trace("xPos: "+xPos+" || yPos: "+yPos+" || scale: "+scale);

_root.map_grid.hotspots[stateArray[i]].onRelease = function(){
stateHit(this);
zoomMap(xPos,yPos,scale);
}
It should be so simple?! I've wasted a whole afternoon trying to work out how to do it. (?¿?)?

Please, if anyone can solve this for me it would be a massive revelation to me.

Thankz!

View Replies !    View Related
[fmx] Button Not Behaving Itself
I have made a button - named "menu_btn" this button has up, over, down and hit states. It has no Linkages.

I have a movie clip - named "menu_item" this movie clip contains the "menu_btn" button and has a dynamic text textfeild named "item_caption" on top of the button. It has Linkages, Export for ActionScript, Export in first frame.

I have writen the following function...

//create menu based on xml file
function makeMenu(sectionMenu) {
//set the initial on screen text to the text of the first section
text_txt.text = sectionMenu.pmntasection[0].pmntasectionText;
//create movie clip to hold menu items
_root.createEmptyMovieClip("tc", 1);
//set the position on screen of the movie clip that holds the menu items
tc._x = 90
tc._y = 110
//loop through adding menu items
for(var i = 0; i < sectionMenu.pmntasection.length; i++) {
//attach item_btn movie clips
var c = tc.attachMovie("item_btn", "chap" + i, i);
//set the position of the item_btn movie clips
c._y = 35 * i;
//put the text on the menu items
c.item_caption.text = sectionMenu.pmntasection[i].pmntasectionName;
c.chapNumber = i;
//add the action to the button
c.onRelease = function() {
text_txt.text = sectionMenu.pmntasection[this.chapNumber].pmntasectionText;
}
}
}

It all works fine except the button states do not change. The squirrel finder example on this site (http://www.kirupa.com/web/xml/exampl...rrelfinder.htm) does what I want to do, and I have made my movie the same - well I must be missing something - but what? where am I going wrong? Please help as I've been trying to crack this all weekend. Thanks.

View Replies !    View Related
[FMX] Help Arrays Not Behaving?
Hello!

Going mad trying to work out why this code is not working... can any ActionScript gurus help a struggling designer?

Basically, the movie consists of a map with a couple of states which act as hotspots/buttons...


Code:

////////// button functions for each state
function stateOver(mc){
trace("stateOver("+mc+")");
mc.tween("_alpha",25,1,"easeoutsine");
}
function stateOut(mc){
trace("stateOut("+mc+")");
mc.tween("_alpha",0,1,"easeoutsine");
}
function stateHit(mc){
trace("stateHit("+mc+")");
mc._alpha = 35;
}
No probs. Next, a function to zoom in and move the map...


Code:
function zoomMap(xPos,yPos,scale){
_root.map_grid.tween(["_x","_y","_xscale","_yscale"],[xPos,yPos,scale,scale],1,"easeoutsine",0);
}
Now I assign those functions to each state...


Code:
function assignButtons(){
stateArray = ["stateWA","stateNT","stateQLD","stateNSW","stateVIC","stateSA","stateTAS"];
scaleArray = [180,220,200,280,330,280,300];
xPosArray = [-132,-426,-691,-1000,-1322,-795,-1055];
yPosArray = [-170,-9,-106,-500,-920,-495,-850];
numStates = stateArray.length;

for(i=0;i<numStates;i++){
_root.map_grid.hotspots[stateArray[i]]._alpha = 0;
_root.map_grid.hotspots[stateArray[i]].useHandCursor = false;

xPos = xPosArray[i];
yPos = yPosArray[i];
scale = scaleArray[i];
trace("xPos: "+xPos+" || yPos: "+yPos+" || scale: "+scale);

_root.map_grid.hotspots[stateArray[i]].onRelease = function(){
stateHit(this);
zoomMap(xPos,yPos,scale);
}
_root.map_grid.hotspots[stateArray[i]].onRollOver = function(){
stateOver(this);
}
_root.map_grid.hotspots[stateArray[i]].onRollOut = function(){
stateOut(this);
}
}

_root.map_grid.oceanZone.onRelease = function(){
zoomMap(0,0,85);
}
}
It's the _root.map_grid.hotspots[stateArray[i]].onRelease function is the one driving me mad. The preceding values for the xPos, yPos and scale correctly trace the corresponding values form their arrays, so why wont those values then be applied to each state in the onRelease function?


Code:
xPos = xPosArray[i];
yPos = yPosArray[i];
scale = scaleArray[i];
trace("xPos: "+xPos+" || yPos: "+yPos+" || scale: "+scale);

_root.map_grid.hotspots[stateArray[i]].onRelease = function(){
stateHit(this);
zoomMap(xPos,yPos,scale);
}
It should be so simple?! I've wasted a whole afternoon trying to work out how to do it. (?¿?)?

Please, if anyone can solve this for me it would be a massive revelation to me.

Thankz!

View Replies !    View Related
[fmx] Button Not Behaving Itself
I have made a button - named "menu_btn" this button has up, over, down and hit states. It has no Linkages.

I have a movie clip - named "menu_item" this movie clip contains the "menu_btn" button and has a dynamic text textfeild named "item_caption" on top of the button. It has Linkages, Export for ActionScript, Export in first frame.

I have writen the following function...

//create menu based on xml file
function makeMenu(sectionMenu) {
//set the initial on screen text to the text of the first section
text_txt.text = sectionMenu.pmntasection[0].pmntasectionText;
//create movie clip to hold menu items
_root.createEmptyMovieClip("tc", 1);
//set the position on screen of the movie clip that holds the menu items
tc._x = 90
tc._y = 110
//loop through adding menu items
for(var i = 0; i < sectionMenu.pmntasection.length; i++) {
//attach item_btn movie clips
var c = tc.attachMovie("item_btn", "chap" + i, i);
//set the position of the item_btn movie clips
c._y = 35 * i;
//put the text on the menu items
c.item_caption.text = sectionMenu.pmntasection[i].pmntasectionName;
c.chapNumber = i;
//add the action to the button
c.onRelease = function() {
text_txt.text = sectionMenu.pmntasection[this.chapNumber].pmntasectionText;
}
}
}

It all works fine except the button states do not change. The squirrel finder example on this site (http://www.kirupa.com/web/xml/exampl...rrelfinder.htm) does what I want to do, and I have made my movie the same - well I must be missing something - but what? where am I going wrong? Please help as I've been trying to crack this all weekend. Thanks.

View Replies !    View Related
Geturl Behaving Funny
Hi,

Did anyone encounter this before? Out of abt 10 times, a button with the action getURL doesn't work? Does anyone know why? Need an urgent answer for this as the client isn't happy abt it.

View Replies !    View Related
Ext Sound FLA Not Behaving In Browser
Problem: I have a movie that I load into level 100 on the main movie during the intro. The loaded movie is simply a sound loop with:
Frame 1 - label=Music Stop action=stop
Frame 5 - label=Music Start
Frame 60 - label=Play Now (and sound loop on the stage)

Frame 5 thru 60 allows for a delay when the main "page" appears, as I want a movie clip on that "page" to end before the sound loop begins.
The AS on that frame is:
if (_root.soundvar == "") {
_root.soundvar = "on";
_level100.gotoAndPlay("music start");
}
stop();

Then a button appears to allow the sound to be turned off.
The off button is a red X. When sound is turned off, the button turns into a green check mark which will turn the sound back on. These 2 buttons are actually in a movie clip.
This MC has 2 frames:
Frame 1 (red X button)
Action:
if (_root.soundvar == "off") {
nextFrame();
}
stop();
Frame 2 (green check button)
Action:
stop();

Action on red X button:
on (release) {
stopAllSounds();
_root.soundvar = "off";
_level100.gotoAndStop("Music Stop");
nextFrame();
}

Action on green check button:
on (release) {
_root.soundvar = "on";
_level100.gotoAndStop("Play Now");
prevFrame();
}

Now all this works perfectly well when I test the movie in MX, but when I upload the files and run it in my browser 2 disconcerting things happen:
1. the sound loop starts without the delay, so is going on at the same time as another MC with sound in it
2. the red X button shows up which when "released" stops the sound loop and changes to the green check button, but the sound will not start again

I am sorry to be so long winded but I thought that if you had all the info perhaps you could spot the problem easier.

Thanks for any help that you can offer.

View Replies !    View Related
Dynamic Text Not Behaving :(
Hi All

Im using MX....

I have a dynamic text box that i have linked to the scroller component. It works well I have embedded the font.

Problem:

I can only have 1 colour for all the text in the dynamic text box and NO formatting, such as bold etc, of my text!!!

Does anyone know why???

Cheers for the help

View Replies !    View Related
Dynamic XML Menu -- Not Behaving Itself
I would like someone to post an XML menu here, (is that allowed?)

I am having trouble with mine, and it would be much easier if I could look at something that is working already.

Thanks!

kevinRYAN

View Replies !    View Related
Preloader Behaving Strange
Hi there,

I made a preloader that seemed to work fine when I only had content on frame2.(main preloader)

When I have content on frame3,4,... the preloader just won't work.

Anyone can tell me what the bug is?

here's my code:

this.onEnterFrame = function() {
ld = _root.getBytesLoaded();
ttl = _root.getBytesTotal();
percent = (ld/ttl)*100;
this.bar._xscale = percent;
//this.percentText_mc._x = this.bar._width-105
this.percentText_mc.percentText.text = Math.floor(percent)+"%"
if (percent >= 100) {
_root.gotoAndPlay(2);
}
}

Grtz,

View Replies !    View Related
Expression Behaving Like String?
Here's the scoop

MC 1: is basically an invoice that contiunuously references a variable, _root.subtotal, from the main time line and then computes tax and total

MC 2: is an individual product that when selected, goes to a frame with the following action, where "cost" is a variable on it's movie clip

_root.subtotal = _root.subtotal + cost;

so now the subtotal is the sum of as many products (multiple MC 2s) as you select.

So Far So Good, the problem is needing to override the price and have the subtotal respond. The override is an imput field in a child mc on the product (MC2's) timeline that executes the following code when accepted

_root.subtotal = _root.subtotal + _parent.cost;

But instead of adding the newly entered cost, it's sticking those numbers on the end of the old as if it were a string instead of an expression, for example:
207 + 100 doesn't = 307
207 + 100 = 207100

There are a lot of clips referencing each other and the root timeline, so i hope this is clear. Does anyone have any idea what i might be doing wrong

View Replies !    View Related
Animated Button Not Behaving
Hello
I have an animated button which only works once, and which only works once with the rest of the timeline.
With the "about us" button (animated) you can see that the animation functions and thats about it.
However, I have not animated the other buttons and they work constantly.
The code on a layer on its own above the button (which is within an mc named clpA) is :


Code:

_root.clpA.btnA.onRelease = function(){
_root.clpA.play();
};
and the code within the mc on the button (btnA) is

Code:

on (release) {
if (_root.clicked == true) {
_root.gotoAndStop("aboutText");
this.gotoAndPlay(1);
} else {
_root.gotoAndPlay("banner");
this.gotoAndPlay(1);


}
}
i have attached the .fla for better detail thanks a lot.
as you can see, i have the animation working, but it only responds every two clicks. i have tried all day on this one !

View Replies !    View Related
[F5] Music Player Not Behaving
Hello,

I editted this music player from another player I found here at FlashKit. It has everything I need.. except a couple of things. I have spent days trying to figure out how to do them myself but I'm just too much of a newbie to figure it out. If anyone would like to take a crack at it, I would really appreciate it.

I am going to be making a single movie that has several of these players. I would like each player to be replaced by another player when a link is clicked. I haven't even gotten to that part yet, though. I need to get the player itself working properly. It does everything I need EXCEPT, I don't want the music clips to loop, I want them to play a clip and move onto the next clip. The only problem with that is there is actiontext and equalizer actionscript that need to be added/changed/updated in order for it to work properly.

When I change from loop to play-once, the music stops but the equalizer(random, not real) keeps going and I don't know how to script the actiontext to display that it has stopped and/or moved onto the next clip.

I would also LOVE to have a REAL working equalizer and to be able to load the mp3s externally and have the main movie listening to whether or not each one is loaded, but it's not necessary. One of my movies is going to have 11 clips of 30-second-long music and that's going to be pretty huge; as it is now, the whole thing has to load before it will play instead of song by song/movie by movie.

Click here to download the zip file

The player.fla would have been 16MB if I had left the music in it. Taking the music out did not affect the scripting but just made it easier for you (as my flash angel helper) to download it faster. I did include the music in the player.swf file. The files named "blank" are the main movie, just a few frames that tell it what to load and stuff. Like I said, I'm a newbie, so if anything looks messed up, please feel free to fix it.

Thank you in advance,
Franki

View Replies !    View Related
[F8] Swf File Behaving Differently On Web
Hi,

I was hoping I could get some help with this code for a thumbnail gallery, the data is loaded from an XML file, http://www.julianbenjamin.co.uk/.

All the thumbnails are loading on the stage correctly and in the correct order when playing movie locally, but as soon as I try Simulate Download or view the movie from the web page the thumbnails lose there order.

can anyone help? here is the code and the FLA is attached


function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
itemname = [];
description = [];
thumbnails = [];

total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
itemname[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("commercial.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
disPos = 1;
YPos = 0;
XPos = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
//preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
preloader._visible = true;
picture._alpha = 0;
picture.loadMovie(image[p],1);
name_txt.text = itemname[p];
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p],1);
name_txt.text = itemname[p];
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0],1);
name_txt.text = itemname[0];
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;

}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller",1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._heig ht)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k,thumbnail_ mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {

target_mc._x = (target_mc._width+2)*disPos;

target_mc.pictureValue = k;
target_mc._alpha = 30;
disPos++;
//trace((target_mc._width+2)*disPos);
//trace(k);
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
preloader._visible = true;
};
target_mc.onRollOver = function() {
this.onEnterFrame = function() {
if (this._alpha<100) {
this._alpha += 10;
} else {
this._alpha = 100;
}
};
thumbNailScroller();
name_teaser.text = itemname[k];
};
target_mc.onRollOut = function() {
this.onEnterFrame = function() {
if (this._alpha>30) {
this._alpha -= 10;
} else {
this._alpha = 30;
}
};
name_teaser.text = "";
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k],"thumbnail_mc.t"+k);
}

View Replies !    View Related
My Buttons Aren't Behaving
Im not really to new to flash, but I just recently started building with it again. I did have flash 5 down pretty well, but I digress. Real simple setup..

The scene has 3 frames.
Frame one is the main page. This page has buttons 1 and 2
Frame two is the link for button 1 from the main page
Frame three is the link for button 2 from the main page.

For some stupid reason that I cant seem to troubleshoot, Even though I differentiate the script for each button. Both buttons are linking to frame 3.
I have all the necessary script telling the movie to stop playing, so its not just playing to the end.

Button 1's script roughly reads
On (press) {
GotoAndPlay(2);
}

Button 2's script
On (press) {
GotoAndPlay(3);
}

*the script is right in flash, I dont know if I typed it correct in here.

I am a little stumped, if you need anymore information please let me know. Thank you in advace.

View Replies !    View Related
Objects Behaving Badly...
Hi all. Having a little issue with the Object class.

The problem:

Code:
var objA:Object = {3:3,2:2,1:1};
for (var a:String in objA) {
trace (a); //1,2,3 -- this seems okay.
}
var objB:Object = {165:1,168:3,169:2};
for (var b:String in objB) {
trace (b); //168,169,165 -- what?!
}

Not only is the iteration in the wrong numerical order on objB, it's not even in alphabetical order.
Sure, I could convert it to an array and sort it, but then I'd lose the (crucial) keys; they'd be reset to 0,1,2. Sure, I could pass it in with the keys I want as properties, but why have the extra search overhead every time I want to find one?

Can anyone explain why the iteration gets weird in this case and ...what to do about it?

Thanks!
Josh

View Replies !    View Related
Contact Form Not Behaving
Below is the code. When the visitor clicks the send btn a new window (home page) opens up. I've taken out the "_blank" in the 'geturl' line and the form couldn't be sent. I also tried taking out the "+_parent.serv" (on the same line) and that didn't work either. Any suggestions? BTW this originated from a monstertemplate item.


on (rollOver) {
this.gotoAndPlay("s1");
}
on (releaseOutside, rollOut) {
this.gotoAndPlay("s2");
}
on (release) {
for (i=1; i<_parent.fields_descriptions.length; i++) {
if (_parent[_parent.fields_descriptions[i][1]] != _parent.fields_descriptions[i][2]) {
this[_parent.fields_descriptions[i][1]] = _parent[_parent.fields_descriptions[i][1]]+","+_parent.fields_descriptions[i][2];
}
_parent.reset_txt(_parent["t"+i], _parent.fields_descriptions[i][1], _parent.fields_descriptions[i][2]);
}
this.recipient = _parent.rec;
getURL("gdform."+_parent.serv, "_blank", "POST");
}
on (release) {
getURL("thanks2.html", "_blank");
}

View Replies !    View Related
OnMouseMove Behaving Strangely
First, I'd like to say that I'm pretty much entirely new to Flash, which may be the problem here. I think this is written in ActionScript 2 (I wrote it in Flash 8), but I don't know for sure. Basically, I wanted to write a color picker and it was all working out perfectly until it came to adding a MovieClip that would function as a color preview.

It seemed easy enough, add an onMouseMove to each color swatch that would set the preview MovieClip to the color of the swatch. After all, I had just done it with the onRelease event, so it should have worked. But it didn't. And I've spent the last couple days trying everything I can to figure out what's wrong, but I just don't know. When I move the mouse over a color swatch, the preview flickers back and forth between the black and white, but never the value of the color beneath the cursor. I don't know what I'm doing wrong. Just to see if it was a coding error, I changed the onMouseMove to onRelease (meaning that if I clicked the swatch, it would change the preview swatch), and it worked perfectly. So if anyone could offer some insight into why it doesn't work onMouseMove, I'd really appreciate the help.


PHP Code:



class ColorPicker
{
    private var stage:MovieClip;
    private var currentSwatch:MovieClip;
    private var swatchStage:MovieClip;
    private var isOpen:Boolean = false;
    private var sampleSwatch:MovieClip;
    
    public function ColorPicker()
    {
        // Generate the stage.
        this.stage = _root.createEmptyMovieClip('colorPickerStage', 0);
    }
    
    public function getColor():Number
    {
        var tmpColor:Color = new Color(_root.colorPickerStage.currentSwatch);
        return tmpColor.getRGB();
    }
    
    public function renderColorPicker(xpos, ypos)
    {
        // Generate the large swatch showing the current color.
        this.currentSwatch = this.stage.createEmptyMovieClip('currentSwatch', 1);
        this.currentSwatch._x = xpos;
        this.currentSwatch._y = ypos;
        this.currentSwatch.lineStyle(1,0x000000);
        this.currentSwatch.beginFill(0x000000);
        this.currentSwatch.moveTo(0,0);
        this.currentSwatch.lineTo(0,20);
        this.currentSwatch.lineTo(20,20);
        this.currentSwatch.lineTo(20,0);
        this.currentSwatch.lineTo(0,0);
        this.currentSwatch.endFill();
        // Create a reference from the swatch to this object so that
        //  we can interact with the object in the future.
        this.currentSwatch.objRef = this;
        this.currentSwatch.renderPosX = xpos;
        this.currentSwatch.renderPosY = ypos;
        this.currentSwatch.onRelease = function()
        {
            if( this.objRef.isOpen == false )
            {
                //trace('Swatch panel is not shown, showing...');
                this.objRef.renderColorSwatches(this.renderPosX, this.renderPosY);
                this.objRef.isOpen = true;
            } else {
                //trace('Swatch panel is shown, hiding...');
                removeMovieClip(this.objRef.swatchStage);
                this.objRef.isOpen = false;
            }
        }
        
        this.swatchStage = this.stage.createEmptyMovieClip('swatchStage', 3);
        //trace('Rendering at (' + xpos + ',' + ypos + ')');
        // Generate a preview swatch.
        this.sampleSwatch = this.swatchStage.createEmptyMovieClip('sampleSwatc  h', 4);
        this.sampleSwatch.lineStyle(1,0x000000);
        this.sampleSwatch.beginFill(0x000000);
        this.sampleSwatch.moveTo(xpos,ypos + 20);
        this.sampleSwatch.lineTo(xpos + 20, ypos + 20);
        this.sampleSwatch.lineTo(xpos + 20, ypos + 40);
        this.sampleSwatch.lineTo(xpos,ypos + 40);
        this.sampleSwatch.lineTo(xpos,ypos + 20);
        this.sampleSwatch.endFill();
        this.sampleSwatch._width = 20;
        this.sampleSwatch._height = 20;
    }
    
    public function renderColorSwatches(xpos, ypos)
    {
        // Generate color swatches.
        var base_x:Number = xpos + 20;
        var base_y:Number = ypos;
        var i:Number = 0;
        var j:Number = 0;
        var k:Number = 0;
        var xiter:Number = 0;
        var yiter:Number = 0;
        var tempColor:Number;
        var newSwatch:MovieClip;
        for( i = 0x00; i <= 0xFF; i += 0x33 )
        {
            for( j = 0x00; j <= 0xFF; j += 0x33 )
            {
                for( k = 0x00; k <= 0xFF; k += 0x33 )
                {
                    tempColor = Number('0x' + (i > 0 ? i.toString(16) : '00') + (j > 0 ? j.toString(16) : '00') + (k > 0 ? k.toString(16) : '00'));
                    //trace('0x' + tempColor.toString(16));
                    
                    // Draw the swatch.
                    newSwatch = this.swatchStage.createEmptyMovieClip('colorSwatch  ',this.swatchStage.getNextHighestDepth());
                    newSwatch._x = base_x + 10 * xiter;
                    newSwatch._y = base_y + 10 * yiter;
                    newSwatch.moveTo(0,0);
                    newSwatch.lineStyle(1, 0x000000);
                    newSwatch.beginFill(tempColor);
                    newSwatch.lineTo(0,10);
                    newSwatch.lineTo(10,10);
                    newSwatch.lineTo(10,0);
                    newSwatch.lineTo(0,0);
                    newSwatch.endFill();
                    newSwatch.innerColor = tempColor;
                    newSwatch.swatchRef = this.currentSwatch;
                    newSwatch.swatchStageRef = this.swatchStage;
                    newSwatch.sampleRef = this.sampleSwatch;
                    newSwatch.objRef = this;
                    newSwatch._width = 10;
                    newSwatch._height = 10;
                    
                    newSwatch.onMouseMove = function()
                    {
                        var tmpColor = new Color(this.sampleRef);
                        tmpColor.setRGB(this.innerColor);
                        updateAfterEvent();
                    }
                    
                    newSwatch.onRelease = function()
                    {
                        if( this.objRef.isOpen == false )
                        {
                            // This should *never* happen because if the swatches are showing,
                            //  the color picker is open.
                            trace('The color picker panel is not open, but one of the swatches was clicked.');
                            this.objRef.isOpen = true;
                        } else {
                            this.objRef.isOpen = false;
                            var tmpColor:Color = new Color(this.swatchRef);
                            tmpColor.setRGB(this.innerColor);
                            removeMovieClip(this.swatchStageRef);
                        }
                    }
                    
                    xiter++;
                }
                
                // New line needed
                xiter = 0;
                yiter++;
            }
            
            // New block needed
            yiter = 0;
            base_x += 60;
            
            if( i == 0x66 )
            {
                base_x = xpos + 20;
                base_y += 60;
            }
        }
    }


View Replies !    View Related
Script Not Behaving As Expected.
Simple thing. 4 movieclips on the stage with instance namesof cake_mc, cake2_mc, cake3_mc, cake4_mc. All I am trying to do is play each individual clip when it is clicked on. The following code has worked b4 in similar situations but not now. Maybe I am missing something simple. I have tried doing a trace of event.target.name within the enlarge function but all I get is 'instance1' or something, not the mc instance name. Any insight would be appreciated.

Cheers


PHP Code:



//Array to store menu buttons
var imgmenu:Array = [cake_mc, cake2_mc, cake3_mc, cake4_mc];

// add listeners to the menu array
for each (var element:MovieClip in imgmenu)
{
    element.addEventListener(MouseEvent.CLICK, enlarge);
    element.buttonMode = true;
}

// Action when button is pressed
function enlarge(event:MouseEvent):void
{
    event.target.play();    
}
    

stop(); 

View Replies !    View Related
Preloader Not Behaving Correctly
I am creating a website, in my main movie i have a movieclip named content_mc which gets loaded with different swf's. I am using a simple preloader when loading the different swf's to be displayed.

Here is an example of the code:

ActionScript Code:
var loadit:Loader = new Loader();
content_mc.addChild(loadit);
var contentURL:URLRequest = new URLRequest("home.swf");
loadit.load(contentURL);

loadit.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
loadit.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
loadit.contentLoaderInfo.addEventListener(Event.COMPLETE,showContent);

var myPreloader:Preloader = new Preloader();

function showPreloader(event:Event):void {
    content_mc.addChild(myPreloader);
    myPreloader.x = 900;
    myPreloader.y = 300;
}

function showProgress(event:ProgressEvent):void {
    var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
    myPreloader.loading_txt.text = "Loading - " + Math.round(percentLoaded * 100) + "%";
    myPreloader.bar_mc.width = 131.7 * percentLoaded;
}

function showContent(event:Event):void {
    content_mc.removeChild(myPreloader);
    content_mc.addChild(loadit);
}

My problem is that often the swf is displayed before the preloader is finished. If i display a rather large swf (3.5mb) the swf is displayed when the preloader is around 80%.

So my thoughts were that i must have done something wrong in the calculation. Is it not correct to use Event.COMPLETE on the loader?

I hope someone can help me with this.

Thank you!

View Replies !    View Related
Video Import Isn't Behaving Itself: Now What?
My client just discovered that none of their customers have installed Player 7, nor can they be relied upon to do so. Hence, I must embed 25 flvs in swfs in order to present them in Player 6.

As I understood it, All I Needed To Do was
- create an empty fla per flv, the same aspect and frame rate as the flv
- choose >File>import>import to stage
and the flv would be embedded in the fla. A dialog box would come up saying, "the video needs XXX more frame to be added to the fla," or something like it. I'd agree. The deed would be done. Then, I'd insert a keyframe at the end with "stop();" in it, name the fla, save it, and that would be that. In fact, I'd swear I did just that, two or three times.

When I inserted the 'stop()' keyframe, the extension dialog box popped up. I clicked "No, thanks", for I am extremely polite in these situations. The dialog box went away, and I saved the fla and moved on.

Now, however, when I import the flv, I get no expansion of the fla, and no dialog box offering it.

I've looked up "flv" in Help, and that's what it says to do. I've looked up "Importing Video",too. It doesn't talk about flvs.

Any help would be gratefully appreciated.

- Paul

** "Any statement that begins with the phrase 'All you've got to do' is a lie. The only thing that's true about it is that you're going to do it. Whoever's talking is going home." **

View Replies !    View Related
Rotation Behaving Unexpectedly
Hi,

I have been having a problem with an actionscript in my flash movie; it rotates an object when a 'handle' is pressed and dragged; the problem I am having is that when the mouse buttonis released, it keeps on rotating!

I'm sure that I'm missing something simple - here is my code for the rotation:


Code:
this.onPress = function() {
x_orig = this._x;
y_orig = this._y;
startDrag(this, false);
this.onMouseMove = function() {
// get the current mouse position, relative to the clip origin
mousex = _root._xmouse - this._parent._x;
mousey = _root._ymouse - this._parent._y;
//
// calculate the angle (in Radians) using the built-in atan2 function
thetaRad = Math.atan2(mousey, mousex);
// convert this result to degrees
thetaDeg = (thetaRad*180)/Math.PI;
//
// set the rotation of the clip
this._parent._rotation = thetaDeg;
//
// reset the position of the handle
this._x = x_orig;
this._y = y_orig;
}
}

this.onRelease = function() {
stopDrag();
}

I have tried putting the onRelease handler at various points in the code but I still don't prevent the thing from rotating. Any ideas?

Thanks in advance,

Peter

View Replies !    View Related
Links Behaving Badly In IE
I'm building a site with several flash buttons and a couple other Flash elements in it. The buttons and links work fine when tested on Safari, Netscape and Firefox, but don't work at all in IE.

Also on some PC's I checked them on, the type does not appear in the buttons, and on another PC, there's a big ugly box around the swf file in IE.

Does anyone have an idea why this might be happening and what could be done to remedy it?

thanks!

View Replies !    View Related
Videos Behaving Wierd
Hi everyone,

this forum helped me a lot for creating my app, which is essentially a videos/photos gallery...its done, now I am testing it, and i got a weird bug.

I have put my application(swf file) file on a web server, the videos(flv files) and jpg pics are also located on the same server. Now when i am opening the app URL on my system, its working fine, videos are pics are opening, videos are opening through client side streaming. However, on somebody else's system, videos goes fast forward on their own. This is a weird behavior and I have no idea what is causing this.


can anybody tell me, y is this happening?

View Replies !    View Related
Videos Behaving Wierd
Hi everyone,

this forum helped me a lot for creating my app, which is essentially a videos/photos gallery...its done, now I am testing it, and i got a weird bug.

I have put my application(swf file) file on a web server, the videos(flv files) and jpg pics are also located on the same server. Now when i am opening the app URL on my system, its working fine, videos are pics are opening, videos are opening through client side streaming. However, on somebody else's system, videos goes fast forward on their own. This is a weird behavior and I have no idea what is causing this.


can anybody tell me, y is this happening?

View Replies !    View Related
Swf Is Behaving Differently On Different Computers
If you want to view the swf I'm talking about, you can see it here: http://kurtcom.com/actionscript3/PhotoProgram.swfText

On my Vista machine (which may not be relevant) the swf will only load 3 thumbnails from the photos.xml file. You can view the xml file at the address in the code (relative to the swf). The thing that gets me is that when i test the same exact swf on my linux machine, all the thumbnails from the xml file will load in the way i have intended them to. I'm also having the issue: when I click on a thumbnail, and all the thumbnails tween to the left, they don't all go to the x coordinate as I have coded. That only happens on my vista machine, not on my linux machine. I wonder if my flash player on my Vista machine needs to be reinstalled (done that before) or if a corrupted file on my Vista machine is somehow tampering with the Flash player? Ever since I bought this computer, I've had the feeling that Vista is tampering with the Flash Player, but don't have the technical know-how to figure out whether that's true.

Also, if you have any input on my code, and the way I am doing things, I am still learning and would greatly appreciate any input you might have. Thanks!







Attach Code

package {
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.xml.*;
import flash.display.Loader;
import flash.filters.DropShadowFilter;
import flash.geom.ColorTransform;
import flash.utils.Timer;
import flash.events.TimerEvent;

[SWF(backgroundColor="#EEEEEE")]

public class PhotoProgram extends Sprite {
private var thumbLoader:Loader;
private var picLoader:Loader;
private var xmlLoader:URLLoader = new URLLoader();
private var tf:TextField = new TextField();
private var imageName:TextField = new TextField();
private var xml:XML = new XML();
private var xmlList:XMLList = new XMLList();
private var photoContainer:Sprite;
private var imageHeight:uint = 50;
private var thumbY:uint = 0;
private var thumbX:uint = 0;
private var thumbMoveToX:uint = 5;
private var randX:uint;
private var randY:uint;
private var dropShadow:DropShadowFilter = new DropShadowFilter();
private var moveThumbLeft:Tween;
private var organizeThumbY:Tween;
private var thumbFadeIn:Tween;
private var photoBGScaleHeight:Tween;
private var photoScaleHeightYoyo:Tween;
private var photoFadeIn:Tween;
private var photoFadeOut:Tween;
private var timer:Timer;
private var thumbOrganizerTimer:Timer;
private var thumbNum:uint = 0;
private var moveToY:uint = 12;
private var initialClick:Boolean = false;
private var currentPhoto:String;
private var picNum:uint = 0;
private var loadedThumb:uint = 0;

public function PhotoProgram() {
init();
}

private function init():void {

dropShadow.alpha = .5;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

xmlLoader.load(new URLRequest("xml/photos.xml"));
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

photoContainer = new Sprite();
photoContainer.graphics.beginFill(0xFFFFFF);
photoContainer.graphics.drawRect(0,0, 600, 400);
photoContainer.graphics.endFill();
photoContainer.x = 10;
photoContainer.y = 10;
addChild(photoContainer);

imageName.width = 100;
imageName.height = 20;
imageName.text = "";
addChild(imageName);


tf.width = 200;
tf.height = 50;
tf.border = true;
tf.multiline = true;
tf.x = 10;
tf.y = 20;
//tf.x = stage.stageWidth / 20;
//tf.y = stage.stageHeight / 20;
tf.text = "blah blah blah blah blah blah blah blah blah blah blah blah blah blah";
addChild(tf);

//timers for organizing thumbs smoothly
timer = new Timer(25, 17);
timer.addEventListener(TimerEvent.TIMER, moveAllThumbs);
thumbOrganizerTimer = new Timer(25, 17);
thumbOrganizerTimer.addEventListener(TimerEvent.TIMER, organizeThumbs);
}

private function xmlLoaded(event:Event):void {

//tf.text = event.target.data;
xml = XML(event.target.data);
xmlList = xml.children();
for (var i:int = 0; i < xmlList.length(); i++) {

randX = Math.floor(Math.random() * 500);
randY = Math.floor(Math.random() * 300);
thumbLoader = new Loader();
thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
thumbLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
thumbLoader.name = xmlList[i].attribute("source");
thumbLoader.addEventListener(MouseEvent.ROLL_OVER, onThumbOver);
thumbLoader.addEventListener(MouseEvent.ROLL_OUT, onThumbOut);
thumbLoader.addEventListener(MouseEvent.CLICK, onThumbClick);
//make invis so it can fade in on completed loading
//thumbLoader.alpha = 0;
thumbLoader.x = randX;
thumbLoader.y = randY;
thumbLoader.filters = [dropShadow];
photoContainer.addChild(thumbLoader);
tf.appendText(thumbLoader.name);
}

}

private function onThumbClick(event:MouseEvent):void {
if (initialClick == false) {
timer.start();
initialClick = true;

picLoader = new Loader();
picLoader.load(new URLRequest(event.target.name));
picLoader.x = 80;
picLoader.y = 25;
picLoader.filters = [dropShadow];
photoContainer.addChildAt(picLoader, photoContainer.numChildren);
picLoader.name = "pic" + picNum;
currentPhoto = picLoader.name;

photoFadeIn = new Tween(picLoader, "alpha", Regular.easeIn, 0, 1, 1, true);

//move the imageName text to the main image
imageName.x = 85;
imageName.y = 385;
} else {
//load the picture because thumbs are organized
addChild(imageName);
photoFadeOut = new Tween(photoContainer.getChildAt(photoContainer.numChildren - 1),"alpha", Regular.easeIn, 1, 0, 10);
photoFadeOut.addEventListener(TweenEvent.MOTION_FINISH, fadeInNext);
//tf.text = String(photoContainer.numChildren);
picLoader = new Loader();
picLoader.load(new URLRequest(event.target.name));
picLoader.x = 80;
picLoader.y = 25;
picLoader.alpha = 0;
picLoader.filters = [dropShadow];
photoContainer.addChild(picLoader);

//set the image text to the description in xml file

for(var j:uint = 0; j < xmlList.length(); j++) {
if (xmlList[j].attribute("source") == event.target.name) {
imageName.text = xmlList[j];
}
}
}
//tf.text = String(event.target.name);
}

private function onThumbOver(event:MouseEvent):void {
//imageName.y = uint(event.target.y) + 5;
//imageName.x = Math.random() * (photoContainer.width - 50);
//imageName.y = Math.random() * (photoContainer.height - 50);
}

private function onThumbOut(event:MouseEvent):void {
}

private function moveAllThumbs(event:TimerEvent):void {
thumbX = photoContainer.getChildAt(thumbNum).x;
moveThumbLeft = new Tween(photoContainer.getChildAt(thumbNum),"x", Elastic.easeOut, thumbX,5,1,true);
if (thumbNum == 16) {
moveThumbLeft.addEventListener(TweenEvent.MOTION_FINISH, startThumbOrganizerTimer);
}
thumbNum++;
}

private function organizeThumbs(event:Event):void {
thumbY = photoContainer.getChildAt(thumbNum).y;
organizeThumbY = new Tween(photoContainer.getChildAt(thumbNum),"y",Elastic.easeOut, thumbY,moveToY,2,true);
moveToY += 21;
}

private function startThumbOrganizerTimer(event:TweenEvent):void {
/* this function is called only when the last thumbnails has moved over to the left.
the last thumbnail has a motion event MOTION_FINISH that calls this function.
this function starts the organzer timer, that organized images to the proper y values */

thumbOrganizerTimer.start();

/* sets thumbNum = 0 because it is reused to iterate through thumbs in the thumbOrganizerTimer function calls */

thumbNum = 0;
}
private function fadeInNext(event:TweenEvent):void {
/* swap last two items in the photocontainer display array
so that you can remove the last element of the array
*/
photoContainer.swapChildrenAt(photoContainer.numChildren - 2,photoContainer.numChildren - 1);

/* now remove the last element of the array which should be the photo that was
last displayed
*/
photoContainer.removeChildAt(photoContainer.numChildren - 1);

/*now that the last part of the array has been cut off
the last part of the array is the las image added
which needs to be tweened via alpha
*/
photoFadeIn = new Tween(photoContainer.getChildAt(photoContainer.numChildren - 1), "alpha", Regular.easeIn, 0, 1, 10);
}
private function thumbLoaded(event:Event):void {
//tf.text = "thumb loaded: " + event.target.name;
thumbFadeIn = new Tween(event.target.loader, "alpha", Regular.easeIn, 0, 1, 1, true);
loadedThumb++;
}
}
}

View Replies !    View Related
Preloading - Behaving Weirdly
I don't know if it's just me, but when i test the preloading on Flash's "test movie", the preloading bar extends smoothly. I tested with the supposed 56k, dsl, and t1 and all of the bar runs smoothly. But when i upload it to the website, it's far from smooth. I get symptoms like, 1) progress bar starts load 3/4 full rather than 0 full. 2.) sometimes the bar looks LONGER than it's boundary. The code i'm using was from http://tutorials.flashvacuum.com/art...404c555dbd8489

if someone could please help....

View Replies !    View Related
LoadMovie Is Behaving Strange
Hi. I have this code on my site:

on(rollOver){
_root.container.loadMovie("producers.swf");
}
on(rollOut){
_root.container.unloadMovie();
}

When I roll over the image(movieclip) do I want a movie to be shown in the empty movieclip "container".

The strange thing is that it looks nice when I ctrl+enter from flash mx 2004, the little movie is shown in the container while roll over. But when I export the movie, and checkes it in my browser (mozilla & IE 6), the roll-over-movie wont show ("producers.swf")! What can be the problem behind this strange behavior? Other flash applications has worked fine for me!

regards

henrik, sweden

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved