Music Doesn't Go Out Of Scope?
Hi all,
I have a movieclip A which loads music via actionscript:
ActionScript Code: var Music:Sound = new Sound();Music.attachSound("Tune");Music.start(0);
Movieclip B then has an instance of Movieclip A on one frame.
Why does the music continue to play after the instance of Moveclip A has been destroyed? And more importantly, how do I stop it?
Thanks, Lister
Ultrashock Forums > Flash > ActionScript
Posted on: 2005-06-03
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
SetInterval: Scope Works Then Doesn't Work
I've created loads of classes that use setInterval. Each time I use the following syntax:
Code:
class myClass{
private var myInterval:Number;
public function myClass() {
setInt();
}
private function setInt():Void {
myInterval = setInterval(this,"foobar",100);
}
private function foobar():Void {
trace(this);
}
}
I would get :
[Object Object] over and over and over
which would be expected.
And usually that works...but today I had a class that wouldn't work that way. When i ran the code above, it didn't set the interval at all. To get it to work I needed to write it like this:
Code:
class myClass{
private var myInterval:Number;
public function myClass() {
setInt();
}
private function setInt():Void {
myInterval = setInterval(foobar,100);
}
private function foobar():Void {
trace(this);
}
}
the interval is called but the trace says undefined. if I pass an argument into the code:
Code:
class myClass{
private var myInterval:Number;
public function myClass() {
setInt();
}
private function setInt():Void {
myInterval = setInterval(foobar,100,this);
}
private function foobar(passedItem:Object):Void {
trace(passedItem);
}
}
It traces [Object Object] again
The first code seems kosher and works everywhere but not in one class. anyone have a problem similar to this?
-D
Music Doesn't Stop, It Does But....
Ok, I'm in trouble once again: I made a MC with some music, everything is fine, I created a button for music on/off, fine. Starts the movie, I turn off the music and go on connecting to other frames in the scene, but when I go back to the main page the music starts again even though the button is off, what's wrong with it??? I'm going insane. Thanx for your help!!!
Music Doesn't Stop Until I Close The Browser
Hey people, I'm sorry I'm posting this again, but I still haven't found the solution to my problem and, on top of that, I guess my previous post didn't make a lot of sense to those of you who use PCs only. Anyway, on a Mac you can have a browser (or, for that matter, any program) started but no window (existing or new document) open. So, let's say I have the browser open and a window in which the HTML page containing my flash movie (with its background music) playing. Then I have other pages open in separate windows in the same browser. When I close the window containing the flash movie with the background music, the music doesn't stop. I have to close (quit) the browser (which closes all my other open pages) in order to have the music stop. This happens only on a Mac. Sorry if I was vague in my previous post and I really hope somebody knows what this is all about This is not the first time I see this happen and I am not the only one having experienced this Thanks for all your help, Flash gurus!
Music Doesn't Play From Web But Works From Localhost
Okay, I'm using:
loading = true
mymusic = new Sound()
mymusic.setVolume(100)
mymusic.loadSound("mp3/music01.mp3", false)
and elsewhere:
if (mymusic.getBytesLoaded() == mymusic.getBytesTotal()) {
mymusic.start(0,100)
}
Now this works great from the local machine, but once it goes up on a site, it doesn't always start playing as soon as it's loaded.. but the thing is, sometimes it plays as soon as it's loaded, and sometimes I have to wait until it's loaded, then click on the play button a second time in order to hear anything.
Anyone able to help?
Thanx.
HELP Preloader Doesn't Preload Mc's That Will Load Music,AS Etc..
i have about 10 mcs in the stage that will load music in volume0 cause i'm gonna start them later..
my preloader used to work well before i add those mcs and some other stuff that will load in stage (swfs etc)
now i can see the preloader just in 99% and then the movie starts!
i tried a lot of preloaders with no luck ,the same thing happens
i'm sure that is because of the mcs with the music and the AS that calls swfs to load on the stage
so the preloader doesn't see a lot of stuff in the main movie timeline (where the preloader goes) and get confused...
what to do??
it was a well made preloader with mask but right now i don;t care much ,i need something to preload the 600kb content..the visitor will see just a blank movie (as it loads) and will go
i had a tricky program in the past (swf lock&load) that does external preloaders
it worked,preloaded the main movie BUT ALL the sounds that supposed to load in mcs disappeared
so i'm sure that the problem is there..
what should i do?
Music Player Actionscript Doesn't Work With Loadmovie
Hi,
I made a music player a nd it works fine as a swf but when I load this movie into another swf, it doesn't work.
Here is the as that I add to play button;
on (release) {
mysound = new Sound();
mysound.attachSound("music1");
mysound.start(0,1000);
}
I guess something changes when I load it but I have no idea what?
Do you have an idea?
Thanks in advance.
Loading Music When Server Doesn't Support Streaming
I am trying to load my music into my flash player.
I have the correct code and stuff because it works when I use my home computer.
But once I upload it to the server it does not work
The % bar which indicates loading progress reads %100
but the music is not playing
I know my server does not support streaming of music
But I thought that it would not matter because the flash player would play it once it loaded
Please help
Thanks
[flash8] Is This An Issue With Scope? No, Not Bad Breath, The Other Kind Of Scope
I feel like such an idiot. This *should* have been a really simple operation and it's turned into an hour-long issue. I've been trying to migrate from putting my button code on buttons and move the code onto the timeline instead. However in this instance it no workie . The following code, specified for cancelMC affects every other button in this scene as if I'd written the code with(this){.
If someone would please just scan this code, and/or look at the picture and tell me what key ingredient I am missing I would really appreciate it:
ActionScript Code:
with(this.cancelMC){ onRollOver = function(){ this.ExplainMC.gotoAndStop("cancel"); } onRollOut = function(){ this.ExplainMC.gotoAndStop("void"); } onRelease = onReleaseOutside = function(){ _root.searchPanelMC.gotoAndStop(15); gotoAndStop("user"); } }
the code is on the timeline and so is the button (cancelMC). However, the code is on the first frame and the button exists on multiple frames thereafter. Does this matter? Does that put the button outside the scope of the code? I tried an onEnterFrame to no effect.
Music Doesn't Play On "replay" Of Movie..
Please help!
I've got a f8 movie with song in bkg. When the replay button is released at the end, the movie replays... but without the music.
If you can help in any way, I'd be so grateful. Thanks!
My Music Doesn't Play On "replay" Of Movie.. Help
Please help!
I've got a f8 movie with song in bkg. When the replay button is released at the end, the movie replays... but without the music.
If you can help in any way, I'd be so grateful. Thanks!
*** I found my problem.. thanks.
GotoAndPlay ("scene 1", "music") Doesn't Work Within A Twain?
Hi. I'm trying to use the gotoAndPlay function. So far, so good.
On my main scene1 screen, the gotoAndPlay ("music") works.
But if I have a twain object (double click to go into twain), I need the twain object's action to link back to the main scene, so I put
gotoAndPlay("scene 1", "music") but it doesn't work.
If I specify gotoAndPlay ("scene 1", 110), it works.
Is there a limitation to specifying labels? I prefer to goto a label as I am then not restricted to remembering what to change when I change frames.
p/s: music is a label for one of the frames.
Hope the above is clear :P
Music Loads.."Off" Button Works But "On" Doesn't?
I've got the index page running fine. When opened the music loads the way it should. I created buttons to allow for "on" and "off" choices for the user. The "Off" button works fine, but if I click "on" nothing happens. Here's the link to the page;
http://www.shakeyhands.com/BunnyB/index.swf
Here's the actionscript i'm using. It's on the sounds frame, not the buttons themselves.
bgSound = new Sound(this);
bgSound.attachSound("rebel");
musicon_btn.enabled=false;
musicoff_btn.onRelease = function() {
bgSound.stop();
musicon_btn.enabled=true;
musicoff_btn.enabled=false;
};
musicon_btn.onRelease = function() {
bgSound.start();
musicon_btn.enabled=false;
musicoff_btn.enabled=true;
};
How To Change Buttons On Music Player Depending On Whether Music Is Playing Or Stoppe
When my music is playing, I want my play button to be blackened in. When the music is stopped, I want my stop button to be blackened but my play button to go back to it's original state.
Right now, when my cursor is over the button, it will change the rollover state. That's easy to do.
How can this be accomplished...do i need multiple layers?
Can I Loop A Specific Section Of Music In Flash After The Music Intro Plays?
Hi! My question involves looping audio in flash. I already know how to make a section of audio in an audio-editing program that loops and make it loop continuosly in Flash. What I would like to do now is take an audio clip that has an intro section and a "body" section and after the intro has played, loop back to the beginning of the "body" section continously. I assume it would involve sending it back to a specific millisecond?
Anyway, can anyone help me out with this one? Or is it even possible?
Thanks,
aswhitehead
How To Make MC Clip Play When Music Starts, Stop MC When Music Stops
Hey,
I've got a audio player on my flash website and I want to have a audio spectrum analyser (those little squares that move up and down randomly) start playing when the user starts playing music and then stop when they stop the music.
Is there a simple way to do this?
Cheers
Max
Display Music's Details As The Music Playing?
Hi
I saw something similiar at Flashkit - Sound FX, when you click on it, you would be able to play the music yet at the same time, display the music "detail", when the it high tone, the display go up high when the tone is low, the display go down?(Hope im not wrong in describing it)
http://www.flashkit.com/soundfx/Interfaces/
Can someone teach me how it work? Thanks
Huh?: MyFunc = {func:func, Scope:scope, Args:args }
Hi,
I've seen this strang syntax used for functions (I think that's what I've seen anyway). Things like:
Code:
myFunc = {func:func, scope:scope, args:args };
in the above I think func is a function and scope is the critter that is supposed to call the function and args are the arguments? But I dont really understand how it works. How do you call myFunc in the above? How do you write a function using this syntax?
Or am I totally off here?
Can anyone help?
Preload Music And Fade In Music
Hi, i'm looking for a script that preloads my music. once it's loaded it should start playing the music with a fade in.
Anybody can help me with this. My actionscript-skills are very poor.
This is the code that i'm using for the moment, without preload and fadein. It uses a random of 3 tracks.
Loops = new Array("track01.mp3","track02.mp3","track03.mp3");
choice = random(Loops.length);
mySound = new Sound();
mySound.loadSound(Loops[choice], true);
thx
scarlac
I Need Some Scope (pu)
Howdy
I'm doing a dyn. .txt based "news-reader"...
5 dyn txt files, 5 buttons, one dyn text field (box)
with variable name of "display".
My site is based on a main page at level_0, and I load swf's throughout to
various levels. My news reader works great in a stand alone config (when
testing in ie or flash player). When in the main movie, it fails to load txt files when i call it up to
a level, although it does load the buttons and it's
graphical elements. Code is as written
Heres the code on the _root of the news reader:
frame 1 of root,
loadVariablesNum ("content.txt", 0);
loadVariablesNum ("content2.txt", 0);
loadVariablesNum ("content3.txt", 0);
loadVariablesNum ("content4.txt", 0);
loadVariablesNum ("content5.txt", 0);
this._x=170
this._y=20
txt's are named as above...content.txt, etc.
first line inside the text files read:
dynamicText=<HTML><BODY>This is where we go to drink ale...(snip)
dynamicText2=<HTML><BODY>That is where we go to sober up...(snip)
etc.
button code goes:
on (release) {
display = dynamicText5, 5;
}
etc.
Again, this thang works great as long as I fire it up by itself. Inside my
main movie, it loads to the level to which I call it, including all graphic
elements, but onRelease, nothing happens with the txt's which should rear
their beautious heads.
Ideally, I would have my main page at level_0,
a nav swf at level_1 that has a button that calls the reader into level_3.
I've got the feeling this is a variable scope issue, but alas, rank amature
here...
Thanks in advance for any comments, codes or critiques.
Willy B.
(ps, this "txt.reader" is closely based on the "Regenerate" tutorial
in foe nmf 2002 annual).
Scope
Ok, maybe I am having a scope problem here?
can't get...
_level20.button1_mc.onRelease = function() {
play();
};
to give me the hand cursor. This code is on level 1. "interface.swf" is in level 20 and loads (I see the graphics). MC, instance name, "button1_mc" is on level 20's root. Yet, I rollover it...nothin'. But this works in a swf without using levels. (minus the_level20. code)
Can you have that code on level one, defining an event for a button on level 20? What's wrong?
??
Thanks,
rez
Scope
i'm makin a fps shooter where u use a sniper in 1 level and iono how 2 make one. i figure u have 2 say sumthin in the actionscript to tell it to go to a certain magnifacation if its in a certain area (where the scope is) but iono how 2 do this. can anyone help me. P.S. i was gonna put this question on games but it seemed 2 be a newbie kind of qwestion. iono. mayB i shuldnt have. srry
A Little Scope Help?
Hi all,
Think I could use a little scope help here. My function below splits a string, then attaches an mc for each item in the resulting array. A trace of the array contents returns correctly in the loadNavItems function. Within this function I have an onRelease function, but cannot seem to target the array the same way - trace returns undefined. What am I missing?
ActionScript Code:
function loadNavItems(navItems:String) {
var navItems_array:Array = navItems.split(",");
for (var i = 0; i<navItems_array.length; i++) {
trace(navItems_array[i]); // traces correctly
var navTxt:Object = dfSite.navHolder_mc.nav_mc.attachMovie("navTxt_mc", "navTxt"+i, i);
navTxt.navBtn_mc.onRelease = function(){
trace("linkTo "+navItems_array[i]); // undefined
}
}
}
Thanks for any help.
Scope
I am trying to understand the scope of different things and have written a simple class and fla to use it.
Code:
class instance {
public function getScope(){
trace("from class: " + _root);
trace("from class: this._parent);
trace("from class: " + this);
}
}
Code:
trace(_root);
trace(this);
var scope:instance = new instance();
scope.getScope();
The output I get it:
Code:
_level0
_level0
from class: _level0
undefined
from class: [object Object]
It all makes sense except for the last line, why does it say that? Everything is a subclass of object right? So I guess it makes sense for this intstance, but say I change me class to extend MovieClip, then it would seem that the last line in the out put should say object MovieClip or something like that.
And then why does this._parent return undefined? Isn't that the same as _root in this case?
Scope In As2
Im running into a scope issue with the below (only constructor shown)
Code:
function Excel() {
//constructor
trace("Excel Importer built");
this.swapDepths(5);
this.state = "in";
this.bttnClose.onPress = function() {
if (_parent.state == "in") {
var myTween = new Tween(_parent, "_x", mx.transitions.easing.Regular.easeOut, -626.5, 0, 1, true);
} else {
var myTween = new Tween(_parent, "_x", mx.transitions.easing.Regular.easeOut, 0, -626.5, 1, true);
}
this.enabled = false;
//trace("myTween "+myTween);
myTween.onMotionFinished = function() {
trace("state "+state);
if (_parent.state == "out") {
_parent.state = "in";
_parent.bttnClose.enabled = true;
} else {
_parent.state = "out";
_parent.bttnClose.enabled = true;
}
};
};
}
the tween onMotionFinished seems to have its own scope and i cant refer to find out what "state" is
is this a delegate.create thing ?
thanks
Scope:help
Hi everyone,
I'm a bit of a newbie to flash, and i'm not sure-how do u ensure that your variables are scoped locally to a scene only, and does not exist for all scenes?
-Nsmarina
The Scope Of This In AS3
Hi
I am just trying to understand the scope of this in AS3 for example in AS2
basicM_btn.onRelease = function() {
this._visible = false;
}
Would have made the button invisible
In AS3 I was expecting to write the same thing as this
function clickHandler(event:MouseEvent):void {
this.visible = false;
}
menuA_btn.addEventListener(MouseEvent.CLICK, clickHandler);
However this sets all of the content on the stage to visible = false
Is there a difference in the way that this works in AS3
Thanks for your help
Scope
Hi guys
I am developing a mobile application for the new Nokia N95 but i am having some problems. This is Flash Lite 2.0 by the way.
I want to use the softkeys to unload movieclips so that i can go back.
I have for instance, 2 classes
This is my infoClass. As you can see i am sending a _root.container_mc to my softKeyClass's constructor. This is all good and works fine.
PHP Code:
class infoClass extends MovieClip { private var container_mc:MovieClip; public function infoClass() { softKeys(); trace("constructor is running"); } public function softKeys() { var mySoftKey:softKeyClass = new softKeyClass(_root.container_mc); } }
But, then i wants put that into my softkeys and this is where it goes bad. I know that i am out of my scope becuase i am in the object.
PHP Code:
class softKeyClass extends MovieClip { private var _target_mc:MovieClip; private var test_btn:Button; private var info_mc:MovieClip; public function softKeyClass(target_mc:MovieClip) { _target_mc = target_mc; trace(target_mc +" target_mc"); trace(_target_mc + " _target_mc"); fscommand2 ("SetSoftKeys", "quit", "send"); fscommand2 ("FullScreen", true); var myListener:Object = new Object (); myListener.onKeyDown = function () { if (Key.getCode () == ExtendedKey.SOFT1) { // Handle left soft keypress event. //_root.target_mc.unloadMovie(); trace("left soft key"); } else if (Key.getCode () == ExtendedKey.SOFT2) { // Handle right soft keypress event. _target_mc.unloadMovie(); trace("right soft key"); } } Key.addListener (myListener); }}
I thought to my self, why not use the delegate class, but i cant get it to work. Is there anyone who can help me out?
This is what i tried with the delegate class.
PHP Code:
import mx.utils.Delegate;class softKeyClass extends MovieClip { private var _target_mc:MovieClip; private var test_btn:Button; private var info_mc:MovieClip; public function softKeyClass(target_mc:MovieClip) { _target_mc = target_mc; trace(target_mc +" target_mc"); trace(_target_mc + " _target_mc"); fscommand2 ("SetSoftKeys", "quit", "send"); fscommand2 ("FullScreen", true); //Key.addListener(Delegate.create("onKeydown", this, getKey)); var myListener:Object = new Object (); myListener.onKeyDown = Delegate.create(this, getKey); } private function getKey() { if (Key.getCode () == ExtendedKey.SOFT1) { // Handle left soft keypress event. //_root.target_mc.unloadMovie(); trace("left soft key"); } else if (Key.getCode () == ExtendedKey.SOFT2) { // Handle right soft keypress event. _target_mc.unloadMovie(); trace(_class._target_mc + " med parent"); trace("right soft key"); } Key.addListener (myListener); }}
I am sorry for my bad English, i hope you guys understand what i am trying to do.
/Morten
Scope When Using New
i'm not sure how scope works in actionscript - am i doing something wrong in the code below?
the loop runs 3 times, so there should be 3 movieclip loader objects and 3 listeners. but in the output, there is only 1 "loaded" trace. i.e. only one of the listener objects has called the onLoadInit function.
any advice appreciated!
CODEtrace("length "+content_xml.firstChild.childNodes.length);
for (var i = 0; i < content_xml.firstChild.childNodes.length; i++) {
var lo = new Object();
var mcl = new MovieClipLoader();
createEmptyMovieClip("floorplan"+i, this.getNextHighestDepth());
mcl.addListener(new Object());
lo.onLoadInit = function() {
trace("loaded");
floorplans[i]._width = floorplanWidth;
floorplans[i]._height = floorplanHeight;
floorplans[i]._x = offStageRight;
floorplans[i]._y = floorplanY;
};
trace("loading "+content_xml.firstChild.childNodes[i].attributes.image);
mcl.loadClip(content_xml.firstChild.childNodes[i].attributes.image, eval("floorplan"+i));
}
Scope Of Variables
Hey, Flash maniacs!
In all the books that I'm reading it says that a variable is scoped to its timeline, but they all talk about the root timeline as one timeline. What if there are 2 or more scenes in my movie? If I initialize the variables in scene one, can I still use their values in the other scenes or since these are different timelines I have to reassign values to them?
Thanks for enlightening me whenever I need it! This is a great forum!
Have fun!
Functions: What Is Their Scope?
If I write my own function, what is it's scope?
Say if it's in the main timeline...
Or if it's in a movie in a movie that is onw the main time line...?
What is it's scope?
Any help would be appreciated.
Thanks.
Nav
Scope Issues - Please Help
I am following along with O'reilly's Actionscript, the definitive guide, and having trouble with very basic scope problems I'm sure someone can help me with. On frame 1 of my main timeline I have the code :
trace (square.x);
trace (circle.y);
and I also have instances [named square and circle] of 2 symbols on this frame. On each symbols main timeline [frame 1] I have this code:
var y;
y = 4;
and
var x;
x = 3;
And for some reason that the book doesn't explain this wont work. It prints out blank, like my dot syntax is wrong or something. However when I move the code on frame one of the main timeline to frame 2 it works. Why is this and how can I fix it?
Thanks a lot!
Jeremy
Programming Art
http://www.programmingart.com
Scope And Rotation
Ok I have tried two other threads and no one can answer this for me maybe it is so hard I don't know but its bugging me out I can do it in flash 5 code but I wanted to get used to flashMX code so I tried this but it just isn't working. I have got the dots to attach and space out right but I wanted each of them to have a rotational value according to the mouse. But I think I have the scope all wrong can anyone please help
Code:
clipDistance = 40;
xRow = 6;
yRow = 3;
total = xRow*yRow;
for (i=0; i<xRow; i++) {
for (j=0; j<yRow; j++) {
movieNum++;
tempClip = _root.attachMovie("dot", "dot"+i+j, movieNum);
tempClip._x = 200+(clipDistance*j);
tempClip._y = 100+(clipDistance*i);
}
}
with (tempclip) {
tempclip.onEnterFrame = function() {
this.rot = (Math.atan2(_root._ymouse-tempclip._y, _root._xmouse-tempclip._x)/Math.PI)*180;
_root.dot._rotation = this.rot;
};
}
Function Scope
I have defined a function the first frame of my timeline but components inside MC's are not picking it up. Any idea's? Do I have to have my function in the first scene?
Variable Scope
If I declare a variable in a movie clip, can I access it in another movie clip? If so, how?
Ya-Tin
Variable Scope
Hello --
I hope someone can help me -- I seem to be losing the value in an some variables I have:
I am new to Flash and am trying to make a simple (or so I thought!) movie with a text box displaying a list of current events, one by one. I want to store the events in an array, and have the first one display in a dynamic text box for a few seconds (maybe scroll across the screen), then display the next array item (next current event), then the next, and so on.
I have a movie with 2 layers: Actions and Display. My code so far is in the first frame of the actions layer.
The Display layer contains a dynamic text box set to the variable "newsitem" - this is where I want to display my events.
I have a text file (news.txt) containing the events, each event separated by a carat ("^").
Contents of text file:
txtmsg=October 20-21, 2002 FIN User Conference, Van Nuys, CA^November 2-3, 2002 Vancouver Tech Conference, Vancouver, BC
I load the text file into a Flash variable (txtmsg) (this part works fine). I then use the split function to separate out each event into its own array item. Here's my code from frame 1 of the actions layer:
loadVariablesNum ("news.txt", 0, "POST");
mycounter = 0;
newsarray = txtmsg.split('^');
newsitem=newsarray[mycounter];
This works fine (meaning when I test the movie, and choose Debug - List Variables, each event is listed as an array item.)
BUT when I go on to the next step, and add 20 frames to each layer(where the first newsarray item would display in the text box newsitem), and add this piece of code in frame 20 of the actions layer to bring in the next array item and display it in the text box newsitem:
mycounter++;
newsitem=newsarray[mycounter];
gotoAndPlay (2);
When I add this code, and test the movie, the variable newsarray is "undefined", as is newsitem. The variable "txtmsg" which contains the unsplit text straight from the text file, still contains its original value.
I don't know if somehow the variable containing the array is going out of scope, or what!
Can someone please tell me what I'm doing wrong?
Thanks!
Kathy
Scope Issue
if i create an onLoad function for an MC in it's parent MC and call a function in the onLoad that exists in the child, how do I reference that funciton...here's the set up
two MC's: A, B
in A I write:
//
function init() {
foo()
}
B.onLoad = init;
in B I write:
//
function foo() {
trace("init");
}
since foos is defined in B, should I call it like so B.foo or as is?
tx
Embedded MC Scope
How can you call an Object method from an embedded MC onEnterFrame Event. Its another problem with scope that i cant figure out
Code:
function newTarget()
{
this.MyClip=attachMovie( "fly", "fly1",100);
this.MyClip.onEnterFrame=function()
{
//'this' here refers to the MyClip Instance, i need to target its object parent
this.Update()
}
}
newTarget.prototype.Update=function()
{
trace("called")
}
newClip=new newTarget()
I've tried various different solutions and cant get it to work. Any help or pointers appreciated.
Cheers
Object Scope From MC
How can you call an Object method from an embedded MC onEnterFrame Event. Its another problem with scope that i cant figure out
Code:
function newTarget()
{
this.MyClip=attachMovie( "fly", "fly1",100);
this.MyClip.onEnterFrame=function()
{
//'this' here refers to the MyClip Instance, i need to target its object parent
this.Update()
}
}
newTarget.prototype.Update=function()
{
trace("called")
}
newClip=new newTarget()
I've tried various different solutions and cant get it to work. Any help or pointers appreciated.
Cheers
Variable Scope
Hello,
nice easy one for ya
I have a function on the main time line that basicly creates and array
All I wan't do is access that array from within another function - should be easy but cant remember for the life of me how to do it????
I'll include a bit of an example for clarity -
//function 1
function makeArray(){
dest = -10 + random(780);
speed = 10+ random(5);
direc = random(2)
return man = [dest, speed, direc];
}
//function 2
function move{
man[1] yada yada yada
}
You get the point
any help happly recieved
(sorry about spelling was in bit of a rush)
GetTimer - > Scope
I am building a little pre-loader and I wish to use the getTimer() function. However, the file I am loading is loaded into a movie clip ("movieHolder") in my main movie which is the _root timeline. Please see the following code.
// Code in externally loaded movie
this.stop();
// preloading routine
this.onEnterFrame = function() {
fractionLoaded = this.getBytesLoaded()/this.getBytesTotal();
elapsedTime = (getTimer()-_root.movieHolder.startTimeDemo)/1000;
timeToLoad = elapsedTime/fractionLoaded;
timetoFinish = Math.ceil(timeToLoad-elapsedTime);
if(timetoFinish == "0") {
// move playhead to correct position
this.gotoAndPlay("demo");
}
};
_root.movieHolder.startTimeDemo = getTimer();
When I run the main movie, it picks up the "bytesLoaded" but does not trigger the timing function.
I have found that when I use the setInterval function, I can only get code to work if everything is referenced around the _root timeline. Is this a similar case / problem with getTimer() ?
I have tried some other referencing, but I am shooting in teh dark. Is there a definitive answer ?
Regards,
motorpilot
When Does TextHeight Come Into Scope?
I have code in a prototype defining a text field as so:
Code:
DraggerClip.createTextField("tf_draggerText", ++this.depthCounter, 0, 0, 0, 0);
DraggerClip.tf_draggerText._width = 160;
DraggerClip.tf_draggerText.multiline = true;
DraggerClip.tf_draggerText.wordWrap = true;
DraggerClip.tf_draggerText.autoSize = "left";
DraggerClip.tf_draggerText.html = true;
DraggerClip.tf_draggerText.leading = 0;
DraggerClip.tf_draggerText.htmlText = "<p align='center'>" + getDrag2Text()+ "</p>";
DraggerClip.tf_draggerText.embedFonts = true;
DraggerClip.tf_draggerText.setTextFormat(new TextFormat("Futura Md BT", 15));
DraggerClip.tf_draggerText._x = Drag2LeftMargin;
DraggerClip.tf_draggerText._y = DraggerClip.title_txt._y+DraggerClip.title_txt._height+50;
trace(DraggerClip.tf_draggerText.textHeight);
A couple problems...
It displays ok unless i comment out the autoSize. Then no text is rendered on the stage. I don't understand that behavior...i've tried with several different width values without any change.
But my main problem is returning the height of the text. I need to pull this value so I can play a clip that adjusts the background depending on how many lines the field wraps to.
I was under the impression that this value was immediately available...no need to let a frame or 2 elapse as we did in the days of Flash 5.
Object Scope Help
postObj = {};
postObj.me=this.postObj
postObj.page = 10;
postObj.lastPage=this.page/2
trace(postObj.lastpage)
how come it doesnt trace out the correct number. Is it got to do with scope? how do i solve this prob?
Rifle Scope Help
I am working on a site that uses the magnifying lense from this tutorial Real Time Magnifying Glass but I have altered it so that I have some t-shirts in the middle of a scope rather than the newspaper from the example tutorial. What I want to do is to make it so that once you aim the rifle over the shirt you want, and click the mouse, a larger example of the shirt shows up in the top right part of my flash window. Any help here would be appreciated. rifle.swf example<--copy link to clipboard, then paste in a new window for the link to work properly.
Path Or Scope?
Hi,
I have a very simple case to solve, but I can't figure out what's wrong. I guess that it has something to do with path or scope syntax.
Here's the scenario: I have 3 scenes (Scene 1, Scene 2 and Scene 3). Every scene has only 1 frame and a stop() instruction in frame 1.
My first example has a button in Scene 1 with the following script attached:
Quote:
on (release) { gotoAndPlay ("Scene 3",1); }
Things are working well, and as expected, when clicking it, the playhead jumps to first frame of Scene 3 and plays (in fact stops because I have a stop() there).
My second example, the one I can't solve, is slightly different. This time, in Scene 1, I have a movie clip and inside it there is my button with the same script attached. But this time the playhead doesn't jump where it was supposed to. Nothing happens.
So my questions are:
1. Why is that?
2. What is the correct syntax for the second case?
Thank you.
P.S. You can download these 2 examples from here:
working.fla and not_working.fla
Note: Macromedia Flash MX Professional 2004 needed.
Tracing Scope
hi.
i'm having some serious scope issues and want to know what the best way to troubleshoot this is.
i've traced as much as i can and couldn't figure it out, then i tried using targetPath() but that only works for finding movie clips and i'm looking for an array. any ideas?
thanks. fumeng.
Scope Within AS2 Classes
Hi,
See comment in class
Code:
class InstructionItem {
var mc:MovieClip;
var sndSound:Sound;
// CONSTRUCTOR
public function InstructionItem(clip,soundLinkageID):Void{
this.mc = clip;
this.mc.InstructionItem = this; // This is to be able to call the class methods from within this.mc.onEnterFrame haldlers for an example
this.sndSound = new Sound(this.mc._parent);
this.sndSound.attachSound(soundLinkageID);
}
// PUBLIC METHODS
public function playInstructions():Void{
this.sndSound.start();
this.sndSound.onSoundComplete = function(){
/*
I want to reach the class's methods & properties from here
like if I want the mc MovieCLip to play I would do maybe:
this.mc.play();
I know "this" refers to the Sound object so I can't do that. This
is a scope matter. But how to I do it then?
I suppose I could do the same as with mc - add a property to it
that I can then use within onEnterFrame and such to call the methods
but I have not been able to do it for the Sound object.
I always thought it was "a wrong way" anyway.
Please help me :)
*/
};
}
}
|