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




Global Rotation



Hi Guys & Girls,Is there a simple way of determining a nested movieclip's global rotation?I have several nested movieclips that need to know what their rotation is to the main stage.Thanks in advance for the help!Cheers,Dave



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 02-25-2007, 05:42 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

How To Retrieve Global Rotation?
Hey guys,

I did a search but to no avail. What I'm trying to achieve is to get the global rotation of a nested movie clip instance. Much like localToGlobal, except for rotation, not x,y.

The only solution I can think of currently is to add all the parent rotations together with the current rotation.

So something like,


Code:
obj = this;
while (obj.parent != null)
{
totalRotation += obj.rotation;
obj = obj.parent;
}
But I'm not much a fan of this as it is rather cumbersome. I am hoping there is some simple localToGlobal type function for rotation.

Does anyone know of any or a better solution than above?

Your help would be greatly appreciated

Local To Global Problem With Rotation Value
hi,
i can't find a way to retrieve the global rotation value of a mc which is a triangle. the x and y positions works fine. i tried my luck with the rotation value, but it's obviously wrong:
point = new Object();
point.x = tri._x;
point.y = tri._y;
point.rot = tri._rotation;
LocaltoGlobal(point);
xcuadrado = point.x;
ycuadrado = point.y;
rot_tri= point.rot;

is there a way to get the global rotation value?

[CS3] Global Function = Global Variables As Well?
CS3/AS2
if i have a global function with some variables defined within it, are the variables global too? if not how would i make them global too?

_global.function someFunction() {
var cake = 10;
var book = 15;
}

someFunction is global so therefore "cake" and "book" are too?

Global Function, Global Variable
how to declare global function and global variable? if i declare it just in frame 1, then the object in other frame can reach it? thanks for answer..

Rotation Script - Smooth Rotation
I have created a speedometer and on clicking a speed, I can get the needle to rotate around to the speed clicked, using _rotation.

However, the movement is very 'jumpy' and I would like to make it smoother, or better still accelerate/decelerate.

I have tried the following


Quote:




on (release) {
rotation_speed = 0.1;
if (speedo._rotation > -40)
{
do {
rotation_speed = rotation_speed * 1.1;
speedo._rotation = speedo._rotation - rotation_speed;
} while (speedo._rotation > -40);
}
else {
do {
rotation_speed = rotation_speed * 1.1;
speedo._rotation = speedo._rotation + rotation_speed;
} while (speedo._rotation < -40);
}
}




I want to get the needle round to -40, so whilst it is greater rotate is backwards, otherwise rotate forwards, starting with a small rotation and increasing (accelerate).

I found that this was still jumpy. Trying a negative causes Flash warning about script running for too long.
Rotating forwards (else) also overshoots the end position of -40

Any ideas on how to get the needle moving smoothly and finishing on the correct spot??

Are Global Variables Really Global?
Hi everyone!

This might sound like a dumb question, but i've just been struggling with variables (more specifically global variables) for the last 3 hours, and now that i made it work, i'm wondering if my solution is the "normal" one.

From what i gather, when you declare a _global variable, you can just use it from any timeline without using a path, right? I have a variable (whichHoliday) which i initiate in the first frame of the main timeline, this way:
_global.whichHoliday="";

I want to give a new value to this variable inside a MC on that timeline. The only way i could do it was by using:
_global.whichHoliday="whatevervalue";

Shouldn't i have been able to use only: whichHoliday="whatevervalue" ?

Why did i need to use _global again to set the value?

Thanks for any input!

[F8] My Global Variables Are Not Global
Hi
I have a problem, my global variables aren't global, as soon as a new timeline is entered the global variable is undefined. (I read somewhere in a forum that it is only possible to use a couple of global variables for F8, could that be correct?)

I use:

if (_global.thing == true){
thing._visible = true;
}

This works for the timeline where true was set and one more timeline, but as soon a third timeline is entered the global value is set to undefined!

What could be the problem?

I am soo grateful for any suggestions!

Thanks!

My Global Variables Don't Seem So Global
what the hell am i doing wrong!?

heres what i've got:


in my UI class i have this:
#include "ContainerClass.as"
#include "MapClass.as"
#include "ObjectiveClass.as"
#include "SponsorClass.as"
#include "MeasureClass.as"
#include "InitiativeClass.as"
#include "AnalystClass.as"
#include "MilestoneClass.as"
#include "StoryLineClass.as"
#include "CommentsClass.as"
var dbPath = "localhost";
_global.scriptPath = "http://"+dbPath+"/strategymap/scripts/";


then in all of the included files i have something like:

myloadvars.sendandload(scriptPath+"/filestoload.whatever",x,"POST");;



sometimes i just want to break something. grrrrr!

Rotation At A Given Rotation Point In AS
Hey ya'll.
I was wondering on exactly how would you make an MC rotate with a given rotation center, using AS, obviously. I'd like to know the math behind it, please.
Using _rotation would make it rotate around the mc's center... i'd like to make it rotate around another center, one defined...

Global
Can I use Global variable in action script ?
thanks
Guillaume frechette

Global?
Hi!

Just read an article on actionscript coding standards and came across this: what is _global exactly, and also, when to use _global, _root or this. Really confused about which should be used and when =P

Another question is about playing midi files. Is there a way to sort of use quicktime plug-in to play a midi file in sync with a flash movie, and to control the plug-in from within the movie, i.e., change the music file when a scene changes?

Thanks ^_^

Russ.

Global
O.K. I need help plez! I am trying to make a game but i need help. I need a variable that can be used in main timeline and movie clips, so... I put a _global. in front of the variable def.
_global.score = 0;
.....but now, my dynamic text reads
"level0.score"
I checked everywhere, but still have no clue how to fix this, please help!

Thanx

Global
O.K. I need help plez! I am trying to make a game but i need help. I need a variable that can be used in main timeline and movie clips, so... I put a _global. in front of the variable def.
_global.score = 0;
.....but now, my dynamic text reads
"level0.score"
I checked everywhere, but still have no clue how to fix this, please help!

Thanx

Global
Is there an official place to put global variables and functions; I usually put this stuff in 1st keyframe actionscript.

[CS3] Global Var?
I have the following button that sets the var itemType:

button.onRelease = function():Void {
itemType = "yes";

}


But when I set the itemType using the button I want it to be used outside of the function, how can I get it to intiate a piece of code and use the itemType set by the button?

Global MC?
Is there such a thing? Because I'm loading an external .swf into a movie clip and the flash progresses onto the next scene, I was hoping that I could keep the frame at the same position as before the scene change.

Is this confusing or do I have to pass the _currentframe properties to a variable and tell it on frame 1 of the next scene to go to that frame again, causing a break in the flow of that mc?

Any idea's?

Global Var
Can a var be set as global for use by all functions in a single fla file?

I would like to set a var in any one of 3 functions (dependant upon user choice) and then be able to read it's value in a fourth and fifth function.

something like this:

//----------------------------------------------------------------------------------------------
public var choice1

function onechoice() {
//do something
//set choice1 value
choice1 = "one"
allchoice()
}

function twochoice() {
//do something
//set choice1 value
choice1 = "two"
allchoice()
}

function threechoice() {
//do something
//set choice1 value
choice1 = "three"
allchoice()
}

function allchoice() {
if (choice1 !=undefined){
checkchoice()
}

function checkchoice() {
//do something
//set choice1 value
switch (choice1) {
case "one" :
//do this
case "two" :
//do this
case "three" :
//do this

}
//end checkchoice
}
//--------------------------------------------------------------------------------------------------------------




Is this possible?

Global CSS
hello,
i have something like "3-level" depth project of .swf movies loading into the main .swf.
i have one CSS style in root of the main .swf

----------------------------------------
var flashCSS:TextField.StyleSheet = new TextField.StyleSheet();
_global.flashCSS.setStyle("p",
{color:'#000000',
fontFamily:'Verdana, Geneva, Arial, Helvetica, sans-serif',
fontWeight:'normal',
fontSize:'10'}
);
_global.flashCSS.setStyle(".hdl",
{color:'#959595',
fontFamily:'Verdana, Geneva, Arial, Helvetica, sans-serif',
fontWeight:'normal',
fontSize:'10'}
);
...
----------------------------------------

i would like to apply this CSS to ANY textfield in ALL levels of the project ...
but if i apply the CSS in some loaded (external) .swf like this:

----------------------------------------
textWindow.styleSheet = flashCSS;
textWindow.htmlText = "<span class='hdl'>Example Example Example</span>";
----------------------------------------

it does not work at all and CSS is not applied

does anyone know how to use one CSS globally in all levels of the project (including loaded external .swf)?

Global Value...
Hello all..
I need a help for my current project.....
actually i have nearly 5 swf's in different levels.
i need to use all these swf's and some common variables or values...
as there is no option for variable passing b/w levels i'm not able to do that...
is there any alternatives to access the variable (i need to update or change the values of varables).

can anybody suggest a solution...
solutions will be highly appreciated...thanks in advance...

I Need A Global Var?
Hello again, i have this code.


PHP Code:



import flash.display.*;import flash.events.*;import flash.utils.*;import flash.display.Loader;import flash.display.MovieClip;import flash.display.LoaderInfo;import flash.net.URLRequest;import flash.text.TextField;import flash.events.Event;import flash.events.ProgressEvent;import caurina.transitions.Tweener;import flash.display.MovieClip;import flash.display.StageAlign;import flash.display.StageScaleMode;stage.align=StageAlign.TOP_LEFT;stage.scaleMode=StageScaleMode.NO_SCALE;stage.addEventListener(Event.RESIZE, resizeHandler);addEventListener(Event.ENTER_FRAME, resizeHandler);var aCarregar:Loader = new Loader();carregarSwf("count");function resizeHandler(event:Event):void {  preloaderBarra.x = (stage.stageWidth/2); preloaderBase.x = (stage.stageWidth/2); preloaderLogo.x = (stage.stageWidth/2); menuTopo.x = (stage.stageWidth)/2; footerTexto.x = (stage.stageWidth)/2; footer.width=(stage.stageWidth); footer.align=StageAlign.LEFT; var externalMovie = MovieClip (aCarregar.content); trace("externalMovie "+externalMovie); if (externalMovie!=null){  trace("nao ha")  }  else{   externalMovie.centro.x=(stage.stageWidth/2);   }}function carregarSwf(teste:String) { var swfACarregar:String=teste; var swfQueCarrega:URLRequest = new URLRequest(swfACarregar+".swf"); preloaderBarra.alpha=0; preloaderBase.alpha=0; preloaderLogo.alpha=0; menuTopo.y=menuTopo.y-70; aCarregar.load(swfQueCarrega); aCarregar.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader); aCarregar.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);  }function showPreloader(evt:Event):void { Tweener.addTween(preloaderLogo, {alpha:1, time:0.5, transition:"easeOutBounce"}); }function showProgress(evt:ProgressEvent):void { var numero:uint = (evt.bytesLoaded/evt.bytesTotal)*100; preloaderBarra.width = (numero*1.55);}function showLoadResult(evt:Event):void { preloaderLogo.visible=false; preloaderBase.visible=false; preloaderBarra.visible=false; var externalMovie = MovieClip (aCarregar.content); stage.addChildAt(externalMovie,0); } 





How can i resize the extenalMovie, i cant call function resizeHandler with externalMovie inside, can someone help me?

Sorry de bad english

Global Variables Within MCs
ive used this code on a button:

selectedscene = "begincontactus";

and at the endd of the current scene ive said:


gotoAndPlay(selectedscene);

this works fine when the button is on the main timeline but when i put it wihtin an mc on the main timeline it doesnt work. do i have to use targets for gloabl variables? how?

Global Variables
ive used this code on a button:

selectedscene = "begincontactus";

and at the endd of the current scene ive said:


gotoAndPlay(selectedscene);

this works fine when the button is on the main timeline but when i put it wihtin an mc on the main timeline it doesnt work. do i have to use targets for gloabl variables? how?

Local To Global Example For D/l
I made a quick example for n8w over at Were-Here, who was asking about this. I know it's pretty straight forward, but if it helps anyone, you are welcome to d/l it. It's in the downloads section (duh) at:

http://www.developette.com

hope it helps someone...

Global Variables
ive used this code on a button:

selectedscene = "begincontactus";

and at the endd of the current scene ive said:


gotoAndPlay(selectedscene);

this works fine when the button is on the main timeline but when i put it wihtin an mc on the main timeline it doesnt work. do i have to use targets for gloabl variables? how?

Global Variables
ive used this code on a button:

_root.selectedscene = "begincontactus";

and at the end of the current scene ive said:

gotoAndPlay(_root.selectedscene);

this works fine when the button is on the main timeline but when i put it witin an mc on the main timeline it doesnt work. do i have to use targets for gloabl variables? how?

actually i have five MCs wtihin an MC on the main timline.
there is a button within each of the five MCs. an action on the buttons changes the variable. so ive created the variable first in the main timeline and refered to it from within the buttons' actionscripts. so i created

_root.selectedscene = "empty"

on the first frame of the movie just to create it.

why isnt it working??????????

Global Variable
how do i set a global variable??>??

i've been stuck with var statment...than after hours i found out that var is a local... variable

than i try set variable statment... and when i trace it... i can't get the variable...

acturally..
//i set a variable call interval
onClipEvent(load)[
interval = 20;
]

than inside that clip when i trace interval i get 20...
but inside the block

tellTarget ("_root.menu.web") {
trace (interval);
}
i get nothing...


[Edited by remote on 07-17-2001 at 09:00 PM]

Local And Global
hi...

can someone explain me the diff. between a normal variable & a variable created by var

i mean:
a = "name"
var a = "name"

i understand that its a local variable but wats the scope... the guide says its lasts in curly brackets only...

but can we use them across the frames...? on one timeline... or what...?

slightly confusing... i only use var for variables in loop like For (var i=0; i<=10; i++)

thanks
arpit

Global Variables
hi there,

how can i properly define global variables, meaning variables which can be seen from any scene in my movie?

if i start defining it (like normal) with "var myVar = 42" i can access it only from within this scene. if i just use it without defining it, i can access it from any other scene too, but it doesn't look very clean to me, so is there a better solution for this problem?

bye, stevie.

Global Varibles
how can i declare global varibles, used in the same movie but by different sequences? thanks, claudia

Global Var Declaration
I am trying to have variables accessable globally

I have declared then on frame 1 like this

hello = 450;

by using trace I can see that hello retains its value in frame two. so far so good

I wish to access my variable hello from within a button.
THe variable does not seem to parse here.

I place trace after an onrelase event and the variable comes up as empty and not 450.
I need to use this variable within my button script

What can I do? thanks in advance

Which Vars Are Global?
I have a movie in _root which has the ability to load a form that is contained in its own movie into _level1.

When this form sends the data to the server, it's sending a **LOT of information along with it. Some of this is good, some is a waste of bandwidth.

How do I know which variables will be submitted? I understand that global variables will go, does this mean all variables defined in _root, or will variables defined in _level1 go too?

Is there a common practice on where to store your variables so that they are not arbitrarily sent to the server? If so, how can I selectively send my vars to the server?

I thought that maybe I could load a different movie into _level1, and put variables there. Then load my form into _level2. Will this help?

Thanks,
Matt

Global Variables?
Simple, easy question that I can't seem to find the answer to: How do you declare and change a global variable? Thanks

-Llama

Global Varibles
Does anyone know if there is any way to set a global variable from within a function?

Here's a link to the page that I'm having a problem with: http://www.kawaguchi.ca/georev/main.html
Basically, what I need is a way to retain which primary section is rolled over. If anyone has any idea, I'd love to hear them.

Thanks in advance.

Variable In MC As A Global
Hi again,
here is another problem:
in my MC's (embeded a button) I am working with various variables which need to interact with one another, say if one variable is 2 another MC cannot be used anymore..:
on (release) {
door = door+1;
if (door == 1) {
setProperty ("/door-movie", _x, 327);
counter == counter+1;
trace(counter);
}
if (door == 2) {
door = 0;
counter = counter-1;
setProperty ("/door-movie", _x, -100);
}
if (counter>2) {
setProperty ("/door-movie", _x, -100);
door = 0;
counter = 2;
}
}
but my counter-variable is not traced.... what can I do???
(did you understand what I mean????)

Global Variables
I'm trying to do an Audio ONOFF button for my scene. This is what I did:
-Created a movie instance containing the wav file.
-Assigned the above instance to an object with "new Sound" command in first timeline frame:

suono = new Sound(audio); *audio IS THE WAV INSTANCE*
aa=true; *this global variable is intended to be used for the switch behaviour*

-Created a second key frame on time line and placed "Stop()" command.
-Created a switch button.
-Assignet the following script to the button instance:

on (release) {
aa=!aa;
if (aa==false) {
suono.stop();
}
else {suono.start()};

}


When first I press the button, the music stops, but after that I cant let it start again. The global variable "aa" works at the beginning, but seems that it cant keep the "false" value after the mouse leaves the button. This is what I think. Maybe the debugger would give great help in this matter, but I cant see the "aa" variable on it.
Any idea?

Global Variables
Hi,
I have two issues.I would greatly appreciate if someone can help. First thing, How do I create global variables like. I have created some variables by loading a xml file while loading the movie. I want to reuse them in the movie clip mousedown events. Now I am again loading it unnecessarily.
Secondly how do I reuse the functions I created in one movie in another. Now I am needlessly typing the same function in all the MCs.

Please help

Thanks
-r-

Global Data Or Not?
If I have a loadvariable on the 1st frame on the 1st scene, will all the variable imported still be kept in all subsequent scenes?

Thanks

Set Global Variable
hello...

i need to set a global variable from within a movie clip.

what i want to happen is when this particular movie clip plays, it sets this variable. i want the variable to be available the entire time (and throughout the movie), the clip is active on the stage. i then want to be able to reference this variable from anywhere else in the movie. can someone show me the way?

thanks...

Global Variabels
I have built my self into a corner. Is there some way for me to keep a variabels value alive when the movie starts over or to pass its value to the movies startframe.

Global Variable?
hi, here my problem:

i want to show a text-file in my swf, so i set the variable which contains the text.

in the main-scene it works, but in movie-clips, the variable is no longer set.

how can i set a variable global, or how can i put the variable from the main-scene in a movieclip?

sorry for my english

Global Variables?
Are there any way of making global variables in Flash 5??
I want to set some variables and access them in a couple of different scenes.

/Micke

Global Variables
Hi

How can i set a global variable at the beginning of a flash movie, so that the values are available to all other frames and MCs within it?

I tried using set variable commands in the first frame, but found that subsequent frames did not retain those values.

Your help appreciated.

BoB.

Global Variables
Maybe this is too much of a VB concept but can I create a Global Variable in flash. By that I mean one that will be recognized in all of the movie clips with out using _root???

Any help would be greatly appricated.

Global Variable HELP
I am trying to use the "if , else" function to get a page to play an audio only once -- just the first time a user opens the page, which is inside loaded inside another movie (a navigation system).

I've looked at trying to set a global variable after the audio is played for the first time which would communicate that it has been played to the script the next time this page opens.

I just can't figure it out.

I hope I have explained clearly enough.

Thanks!!!
-Rob

Global Variables
Hello,
i'm trying to construct a menu and need to have global variables that i change when the menu item is loaded

i have a global function for loading animations on scene 1 and before that function i instance the varaibles. in my case the variables are always reloaded with the same value

Where should i instance the variables ?

Thanks

Global Function
Does anyone know how to make a function available globally?
I'm using movies loaded in movies so _root isn't an option, and it's a pain having to keep going _parent._parent._parent... all the time.

Can An Array Be A Global Var ?
Hi,

can i declare:

var /:Site = new Array();

and that array will be a global var (can be reached at all time lines beneath) ?

Thanks in advance,
Maya.

Global Variables?
Hello All!

Ok, I need help with a variable for controlling a button / Movie clip.

Here is the movie I am working on...
http://isaid.com/test/mmibt_main002.html

If you take a look at the movie you will notice that when you roll over the button(s) the doors for the box on the page close and then when you click the button the doors open back up with new content.

With that said here is my problem.

If you roll ever the button but you do not click it and then you roll over the next button the doors close again.

This is what I am trying to stop.

Once the doors are closed I want them to remain closed until you click a button.

This is the script I currently have on the button to open and close the doors.

on (rollOver) {
_root.mainDoors_in.gotoAndPlay(30);
}
on (press) {
_root.mainDoors_in.gotoAndPlay(60);
}

Pretty straight forward.

Now here is what I was playing with to try and set a variable to keep them closed.

on (rollOver) {
set (IsDoorClosed,True);
if (IsDoorClosed==False)
{
_root.mainDoors_in.gotoAndPlay(30);
IsDoorClosed=True;
}
}
on (press) {
if (IsDoorClosed==True)
{
_root.mainDoors_in.gotoAndPlay(120);
IsDoorClosed=False;
}
}

When this is in use the buttons do not function at all.

plus I think this is wrong anyway as I believe it would be a local variable and I think need a global variable.

I have limited knowledge of scripting so I hope I am at least on the right track.

Can anyone help me in this dilemma??

Much thanks!!!!

Rick

Global Variables...
I'm a little confused. I've been reading a lot about global variables in flash. Now, from what I've read, if I define, for example, a variable in the first frame in the first scene of my project, like so test="0"; then I should be able to access it from anywhere in the movie, right?

I've also noticed you don't need to declare a variable type in any way. (Like int test=0; or string test=”boohoo” Does Flash determine what variable type is desired by the contents of the variable itself?

I know these seem like little kid’s questions but I really want to get a good understanding of basics in Flash. I’m one of those “do it yourself-ers” so I’m teaching myself the language. (Also because I cant afford classes or books, LOL.) This site has indeed been a lifesaver!

If anybody knows any good websites with comprehensive flash basics (Like the question I’m asking above.) I’d appreciate it. The help files that come with Flash itself aren’t too comprehensive.

Thanks!

Copyright © 2005-08 www.BigResource.com, All rights reserved