OnEnterFrame Is Not Functioning As Expected
I have been trying to figure out what is wrong with this code that's on frame 1 of the main timeline since yesterday => code: loader_mc.onEnterFrame = function(){ var loadedPercent = Math.ceil(_parent.getBytesLoaded()*100/_parent.getBytesTotal()); trace("Percent loaded => "+loadedPercent); //Continue to load movie and move loader_mc frame according to percent loaded this.gotoAndStop(loadedPercent); //SWF has completed loading, fade preloader out and move playhead to "main" if(loadedPercent >= 100){ trace("Loading completed..."); _parent.gotoAndStop("transition"); delete this.onEnterFrame; } }
in my movie, i have a 100 frame preloader and the preloader instance(loader_mc) is supposed to play its corresponding frames while the main movie is loading. After loading has completed, the main timeline is supposed to go to the frame labeled "transition".
However, what's happening now is that the preloader "supposedly" plays through its 100 frame sequence and goes straight to the last frame (frame 5) where all the content are. The traces are also not showing up at all...
If the FLA is required to get a better understanding of the problem, i'll gladly provide it.
thanks
FlashKit > Flash Help > Flash ActionScript
Posted on: 06-17-2004, 11:36 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
OnEnterFrame Is Not Functioning As Expected
I have been trying to figure out what is wrong with this code that's on frame 1 of the main timeline since yesterday =>
ActionScript Code:
loader_mc.onEnterFrame = function(){
loaded = Math.round(getBytesLoaded() / 1024);
total = Math.round(getBytesTotal() / 1024);
percent = Math.round((loaded/total) * 100);
//_global.loadedPercent += Math.floor(_root.getBytesLoaded()*100/_root.getBytesTotal());
trace("Percent loaded => "+percent);
//Continue to load movie and move loader_mc frame according to percent loaded
this.gotoAndStop(percent);
//SWF has completed loading, fade preloader out and move playhead to "main"
if(percent >= 100){
gotoAndStop("transition");
trace("Loading completed...");
delete this.onEnterFrame;
}
}
in my movie, i have a 100 frame preloader and the preloader instance(loader_mc) is supposed to play its corresponding frames while the main movie is loading. After loading has completed, the main timeline is supposed to go to the frame labeled "transition".
However, what's happening now is that the preloader "supposedly" plays through its 100 frame sequence and goes straight to the last frame where all the content are. The traces are also not showing up at all...
If the FLA is required to get a better understanding of the problem, i'll gladly provide it.
thanks
OnEnterFrame Is Not Functioning As Expected
I have been trying to figure out what is wrong with this code that's on frame 1 of the main timeline since yesterday =>
ActionScript Code:
loader_mc.onEnterFrame = function(){
loaded = Math.round(getBytesLoaded() / 1024);
total = Math.round(getBytesTotal() / 1024);
percent = Math.round((loaded/total) * 100);
//_global.loadedPercent += Math.floor(_root.getBytesLoaded()*100/_root.getBytesTotal());
trace("Percent loaded => "+percent);
//Continue to load movie and move loader_mc frame according to percent loaded
this.gotoAndStop(percent);
//SWF has completed loading, fade preloader out and move playhead to "main"
if(percent >= 100){
gotoAndStop("transition");
trace("Loading completed...");
delete this.onEnterFrame;
}
}
in my movie, i have a 100 frame preloader and the preloader instance(loader_mc) is supposed to play its corresponding frames while the main movie is loading. After loading has completed, the main timeline is supposed to go to the frame labeled "transition".
However, what's happening now is that the preloader "supposedly" plays through its 100 frame sequence and goes straight to the last frame where all the content are. The traces are also not showing up at all...
If the FLA is required to get a better understanding of the problem, i'll gladly provide it.
thanks
OnEnterFrame=null, OnEnterFrame=undefined & Delete OnEnterFrame....
onEnterFrame=null, onEnterFrame=undefined & delete onEnterFrame....
Which one to use??? What are the performance considerations. If all my movieclips on-stage are running a MovieClip.prototype.onEnterFrame = function() {run initial stuff before setting onEnterFrame=null/undefined... }, will there be performance hits? It's sad that delete onEnterFrame doesn't work unless I delete the prototype enterFrame as well, which would make the clips reinitailise itself again once you declare the enterFrame prototype again (i need to do this since there's more movieclips that end up appearing on-stage, and they need to automatically initialises themselves the moment they appear).
It seems that setting enterFrame to null or undefined is the safest way to go about it, since dealing with multiple .swfs would mean using the same MovieClip.prototype, which means I can't afford to flush out one zone of enterFrames (by deleting both null enterframes and MovieClip.prototype.onEnterFrame) if it means the other zones still needs to initialise their clips first...it's just too troublesome and buggy a mechanism to implement! Once MovieClip.prototype.onEnterframe is declared, it should stay. Will there be performance hits as a result of this?
Is there anyway to do this without tricking the engine to call the onLoad function for MCs by typing "//" into each movieclip actionscript box --- or by troublesomingly creating linkage-ids for every movieclip library item!? NO! That's not what i want...they'll only add to the fiile size! How do i execute a certain "constructor/initilisation" function to all Movieclips without linking them to a class in a library? Something to think about.....
Problem With OnEnterFrame And Delete OnEnterFrame
Ok here is the nuts of the problem,
When I delete the onEnterFrame function programatically I can't reassign it later.
Here is what is happening:
I have a method that I call to build a box on the screen over time. I build it overtime using the onEnterFrame function.
When the application is done it delete the onEnterFrame just fine.
Everything works as expected until you try to assign the same method over again to say for instance make the box smaller. Once I try to call it again I can't assign the onEnterFrame again... I have no idea why it is totally strange.
Code:
//Create an interface
//mc:MovieClip, x:Number, y:Number, w:Number, h:Number
InterfaceBuilderClass.prototype.createInterface = function(mc,x,y,w,h)
{
mc.dy = (h/2)*-1
mc.dx = (w/2)*-1
mc.dy1 = h/2
mc.dx1 = w/2
mc.NFRAMES = 40;
mc.controller = this;
mc.t = 0;
mc.onEnterFrame = function()
{
if (this.t++ < this.NFRAMES) {
trace(this.t);
//DELETED DRAWING STUFF THAT IS NOT AFFECTING THE PROBLEM
}else
{
//redraw with rounded corner
//DELETED DRAWING STUFF THAT IS NOT AFFECTING THE PROBLEM
this.controller.executeCallBack()
delete this.onEnterFrame;
}
}
}
Try it for yourself and see if you can make it work.
If anyone else has run into this problem I'd love to know how you resolved it.
Thanks,
Mark
Re-initialising OnEnterFrame After Deleting OnEnterFrame
Hello to all the actionscript guru's!
I have this thing where when I click this other thing which is controlled by a different thing which gets deleted after I click the other thing and I would like to know if I can sort of undelete the different things thing????
Okay, now in English.
I have some movieclips that move using an onEnterFrame. When you click on a movieclip, I stop the movement by deleting the onEnterFrame. Is there a way to re-initialise the onEnterFrame to get the movieclips moving again?
A thanks in advance for everyone who reads this question
']' Expected?
I have the output window coming up with 2 errors saying,
**Error** Symbol=main_nav, layer=action, frame=1:Line 5: ']' expected
if (this["target" add i]<1)//OPTIMIZATION
what does this mean and how can I fix it?
Why Do I Get '{' Expected
Good Morning All. I am brand new to ActionScript so I KNOW this is a stupid question. I have been charged with creating flash banners for my boss. I have done one and added a URLRequest just fine. When I tried to add same script to next banner I keep getting a '{' expected error. I have worked on this for 2 hours now and simply cannot see any difference between the 2. Why would 1 work and the other not?
'(' Expected
I'm making a beat 'em up style game where you click a button and your character attacks..
heres my problem. on the button named 'punch' i want it so when you enter a certain frame on the 'ragebar' the enemy starts to go red.
i think i got the code right
on (release)
{_root.joe.gotoAndPlay(Punch);}
on {_root.ragebar.enterFrame('red1'); gotoAndPlay('gored');}
but it keeps saying '(' expected
and no matter what i do, it says the same thing OR says other things are wrong and the '(' expected again..
help would be greatly apprectiated.
Thanks.
';' Expected
can anyone tellme whats wrong with the script below I been tried
to figureit out but i don't see any problem ,:
on (press){
startDrag (this,true)
}
on (release){
stopDrag();
if (this._droptarget == "/2"){
_root.1S = 100;
}else{
_root.1S = 0;
}
}
';' Expected
Hello,
My project was going just fine, until suddenly i started to get this error everywhere: " ';' expected".
The strange thing is that the ";" is actually there.
One thing I did was to change instance names of some of the movie clips; then I wondered if that could have been the problem, so I started a new project from scratch, only to find that the ";" was still expected somewhere.
The following are the actions for one movie clip; for these lines I get errors in lines 3, 8, 9, 10, 14, and 15, always expecting a ";".
Code:
on (rollOver) {
gotoAndStop(2);
_root.01.gotoAndStop(2);
}
on (press) {
enabled = false;
_root.01.enabled = false;
_root.subquienes.1b.enabled = true;
_root.subquienes.1c.enabled = true;
}
on (release) {
_root.subquienes.1b.gotoAndStop(1);
_root.subquienes.1c.gotoAndStop(1);
}
on (rollOut) {
gotoAndStop(1);
}
As you can see, ";" is there. I am very disoriented about what steps to take. Does anyone have a clue on what could the error be?
Thanks,
Laura
')' Or ',' Expected -I'M STUMPED_
This works,
on (release) {tellTarget ("_level0.reciever")
{gotoAndStop(_level0.giver._currentframe);
}
}
But not this:
onClipEvent (load)
{tellTarget ("_level0.spinnerTop.110")
{gotoAndStop(_level0.faderTop.110._currentframe);
}
}
and I get this Output:
**Error** Scene=Scene 1, layer=Layer 5, frame=66:Line 4: ')' or ',' expected
{gotoAndStop(_level0.faderTop.110._currentframe);
**Error** Scene=Scene 1, layer=Layer 5, frame=66:Line 7: Unexpected '}' encountered
What's wrong with line 4?
What I am trying to do is pass _currentframe number from one MC to an identical one and stop there.
Identifier Expected
I get this Error message:
Error Scene=Scene!, layer=a, frame=19:Line 3 : Identifier expected
var myListener = new Object();
This was my code
var_myListener = new Object();
myListener.complete = function(eventObject) {
trace("media is Finished");
getUrl("main.htm");
};
myMediaDisplay.addEventListener("complete", myListener);
Try to add code so that when an FLV loaded with MediaDisplay and MediaController stop playing the view is taken to the URL"main.htm"
The URL does not load when tested, I also have getUrl on a button and that works...
Please help me
Patrick
Object Expected
When clicking index. And the link Ingelogd a login screens appears. When you click one of the buttons on the screen an error appears. Object expected and stuff.
Don't know what the problem is. maybe somebody can help.
See attachment.
Thx
**Error** ')' Or ',' Expected
I cant figure out why I am getting this message. Here is my code:
onClipEvent(load) {
if (_root.slider.hitTest (_root.bc_zone)){
_root.gotoAndStop (3);
} else if (_root.slider.hitTest (_root.FirstCent_zone)) {
_root.gotoAndStop (5);
} else if (_root.slider.hitTest (_root.Medieval_zone)) {
_root.gotoAndStop (7);
} else if (_root.slider.hitTest (_root.1600_zone)) {
_root.gotoAndStop (9);
} else if (_root.slider.hitTest (_root.1700_zone)) {
_root.gotoAndStop (11);
} else if (_root.slider.hitTest (_root.1800_zone)){
_root.gotoAndStop (13);
} else if (_root.slider.hitTest (_root.1900_zone)){
_root.gotoAndStop (15);
} else if (_root.slider.hitTest (_root.other_zone)){
_root.gotoAndStop (17);
}
}
And it give me this error:
**Error** Scene=Scene 1, layer=timeline, frame=1:Line 11: ')' or ',' expected
} else if (_root.slider.hitTest (_root.1600_zone)) {
**Error** Scene=Scene 1, layer=timeline, frame=1:Line 13: 'else' encountered without matching 'if'
} else if (_root.slider.hitTest (_root.1700_zone)) {
Total ActionScript Errors: 2 Reported Errors: 2
I cant figure it out... what am I doing wrong? Help! Thanks!
Error Msg - { Expected
Hi,
I have the following script, it is actionscript 2:
function skipAnim():Void {
i keep getting an error message that says '{ expected' when i export it as actionscript 1.
can anyone help?
thanks heaps in advance
Why Do I Get '{' Expected Error
Good Morning All. I am brand new to ActionScript so I KNOW this is a stupid question. I have been charged with creating flash banners for my boss. I have done one and added a URLRequest just fine. When I tried to add same script to next banner I keep getting a '{' expected error. I have worked on this for 2 hours now and simply cannot see any difference between the 2. Why would 1 work and the other not?
'{' Expected Encountered '{' - Why Is This?
HELLO
Im sure a lot of you have seen this script before. It is part of the swfobject1-4.zip which supposedly checks for the Flash Player version installed on the clients computer and upgrades it to the version needed to view the site if necessary.
PROBLEM
Every function of the other scripts in the pack seem to work apart from the ExpressInstall.as. When i check the code in flash it throws up an error on line 30 saying that '{' was expected encountered '{'. And it finds the '}' but doesn't anticipate it because the open wasn't found.
MY UNDERSTANDING
Seems mad, i have a small amount of experience with code and understand the principles of how action script works, but this seems strange to me and i don’t know why it wont read the '{'. i have tried moving it to different positions (below line 30 and changed the spacing between the end of line 30 and the bracket) and it still wont read the '{'.
The relevant line is highlighted in bold in the script below.
I hope this is clear and that someone has encountered this sort of error before, i would be grateful for your help. I have a client that is breathing down my neck. ;-)
Kind regards,
Paul Hudson
=====START=====
/**
* expressinstall.as v1.0 - http://blog.deconcept.com/swfobject/
*
* SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
* Updated: 12-20-2005
*
* Use this file to invoke the Macromedia Flash Player Express Install functionality
* This file is intended for use with the SWFObject embed script. You can download SWFObject
* and this file at the following URL: http://blog.deconcept.com/swfobject/
*
* * SWFObject is the embed script formerly known as FlashObject. The name changed
* due to legal reasons.
*
* Usage:
* var ExpressInstall = new ExpressInstall();
*
* // test to see if install is needed:
* if (ExpressInstall.needsUpdate) { // returns true if update is needed
* ExpressInstall.init(); // starts the update
* }
* // these actions can be placed on a button for extra
* // functionality (see fo_tester.fla), or can be invoked at the start of the movie
*
*NOTE: Your Flash movie must be at least 214px by 137px in order to use ExpressInstall.
* Please see http://blog.deconcept.com/swfobject/ for other notes.
*
*/
var ExpressInstall = function ():Void {
// does the user need to update?
this.needsUpdate = (_root.MMplayerType == undefined) ? false : true;
};
ExpressInstall.prototype = {init:function ():Boolean {
if (this.needsUpdate) {
this.loadUpdater();
return true;
} else {
return false;
}
}, loadUpdater:function ():Void {
System.security.allowDomain("fpdownload.macromedia .com");
// hope that nothing is at a depth of 10000000, you can change this depth if needed, but you want
// it to be on top of your content if you have any stuff on the first frame
this.updater = _root.createEmptyMovieClip("expressInstallHolder", 10000000);
// register the callback so we know if they cancel or there is an error
var _self = this;
this.updater.installStatus = _self.onInstallStatus;
this.hold = this.updater.createEmptyMovieClip("hold", 1);
// can't use movieClipLoader because it has to work in 6.0.65
this.updater.onEnterFrame = function():Void {
if (typeof this.hold.startUpdate == 'function') {
_self.initUpdater();
this.onEnterFrame = null;
}
};
var cacheBuster:Number = Math.random();
this.hold.loadMovie("http://fpdownload.macromedia.com/pub/flashplayer/update/current/swf/autoUpdater.swf?"+cacheBuster);
}, initUpdater:function ():Void {
this.hold.redirectURL = _root.MMredirectURL;
this.hold.MMplayerType = _root.MMplayerType;
this.hold.MMdoctitle = _root.MMdoctitle;
this.hold.startUpdate();
}, onInstallStatus:function (msg):Void {
if (msg == "Download.Complete") {
// Installation is complete. In most cases the browser window that this SWF
// is hosted in will be closed by the installer or manually by the end user
} else if (msg == "Download.Cancelled") {
// The end user chose "NO" when prompted to install the new player
// by default no User Interface is presented in this case. It is left up to
// the developer to provide an alternate experience in this case
// feel free to change this to whatever you want, js errors are sufficient for this example
getURL("javascript:alert('This content requires a more recent version of the Macromedia Flash Player.')");
} else if (msg == "Download.Failed") {
// The end user failed to download the installer due to a network failure
// by default no User Interface is presented in this case. It is left up to
// the developer to provide an alternate experience in this case
// feel free to change this to whatever you want, js errors are sufficient for this example
getURL("javascript:alert('There was an error downloading the Flash Player update. Please try again later, or visit macromedia.com to download the latest version of the Flash plugin.')");
}
}};
=====END=====
Expected Funtionality Of A Swf Within A Swf
So, what I have is a movie - my web site www.spaceear.co.uk
on the streams page I have knocked up a menu which uses actionscript, setting a variable to close a panel and then open up the panel again with the correct contents - this is just a case of playing after a click to close the panel and then once closed checking the variable to find out where to start playing from.
I have created this panel based menu as a seperate movie and then brought it into the main site as a library item. The panel works as expected when played as a stand alone movie but when inserted into the page of the main web site it just plays in a loop ignoring all action script in the sub movie - even simple stop commands.
Does flash not work like this or is this a case of making sure that the gotoandplay command is set to play the correct timeline within the menu movie using .movie instead of .root?
I have similar code in the movie which is used to select scenes after playing an outro sequence for the current scene (I don't care - I like scenes they are neat and make timelines easily change and readable).
TIA
Expected '{' Error
hello, very new to actionscript. trying to setup a mp3 player using some source code. I keep getting this error when I preview my movie.
mp3Player.as: Line 31: '{' expected
function playSong():Void
mp3Player.as: Line 47: '{' expected
function pauseIt():Void
:mp3Player.as: Line 54: '{' expected
function unPauseIt():Void
what ever shall i do?
; Expected Error
Im working on a flash based game on this one but for some reason when i test the movie i keep getting this error
Scene=Scene 1, Layer=Action Layer, Frame=290: Line 102: ';' expected
_root.cheat.1-name = "sonic-run 2";
i thought my syntax was correct. Is there something simple im missing here? Please somebody help me, maybe im tired but i cant see whats wrong here.
Thanks
Erica.R
Object Expected?
When I view my website I keep getting an error. Clicking on the error says, "Object expected"....the line it is referring to in the code is where the flash gets detected (i.e. the content that gets automatically put into the code). What's going on? I've uploaded the RunActiveContent file and the .swf file. How come the site doesn't work? That code is as follows:
AC_FL_RunContent( 'codebase','http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0','width','800','height','600','src','slideshow','quality','high','pluginspage','http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash','movie','slideshow' ); //end AC code
my website: www.theneverendingslideshow.comtheneverendingslideshow.com
Parameter Name Expected, Not Sure Why :(
I've searched the forum for answers to this particular problem and haven't found it, so I'm posting here.
I'm creating a small game w/ Actionscript 2.0 that works sort of like Minesweeper on Windows. Basically there is a 10x10 grid of squares with an "on" and "off" state. when you turn one "on" the adjacent squares also go "on" in a + pattern; likewise when you turn "off."
Here is an online example of the game: http://www.braingle.com/games/disco/index.php
Everything works so far but I get one "parameter name expected" error in the code. The error occurs on line 15. I've attached the file for you to see.
Thanks in advance to everyone who helps out!
Expected A Field Name After '.' Operator.
OK, I'm real 'green' on Action Script, but...
I've placed this script on an ending keyframe of one MC:
_root. 39qmc. gotoAndPlay ("go");
to play another MC (instance name: 39qmc).
A script identical to this one, except for the instance name, works great elsewhere, but, on the one above, I get this in my output window when I 'Test Movie':
"Expected a field name after '.' operator."
LoadMovie Background Not As Expected
I finally got the loadMovie script to work! Yippie! BUT, my movie is missing the background. It shows up white instead of green. It works though, and that's a big step! I must have done something on the publish side. I checked the "linkage" on the background movie clip and Export for actionsacript and export in first frame are checked. Ideas?-----Thanks, Kay
Actionscripting Error: ')' Expected?
Hi I'm making a little game with some actionscripting involved... and I have a movie clip that shoots lasers. This is the error I'm getting:
Scene=Scene 1, Layer=Layer 1, Frame=1: Line 13: ')' expected
if (Key.isDown(Key.CONTROL) { laserCounter=laserCounter+1;
and heres line 13 that the error is supposed to be in:
if (Key.isDown(Key.CONTROL) { laserCounter=laserCounter+1;
Oh wait... you already know that...
Anyways, what is wrong with that string?
Object Expected Error
Hello,
I am trying to open flash pop, but I get the error: Object expected.
Can you tell what is the reason for that?
The object code can be seen below:
================================================== ================
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="450" height="270" id="controller1_5" align="middle" VIEWASTEXT>
<param name="allowScriptAccess" value="always" />
<param name="movie" value="testmovie.swf?clickTag=http://www.walla.co.il" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<embed src="testmovie.swf" quality="high" bgcolor="#ffffff" width="450" height="270" name="controller1_5" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
</object>
_alpha Increment Not As Expected
Hi,
Attached is an .fla in which I'd like to increment _alpha by 1 for each tick of the framerate in onEnterFrame. The problem is that _alpha is incrementing by .78 for each tick. So instead of _alpha going from 0 to 100 in say 101 ticks, it takes 128 ticks. Have a look at the trace.
What's that all about?
Thanks much in advance.
[MX] Import Error: ';' Expected...? Help, Please.
Hello,
I am trying to import tweening classes in MX, and I get the following errors:
Scene=Scene 1, Layer=Scripting, Frame=1: Line 1: ';' expected import mx.transitions.Tween
Scene=Scene 1, Layer=Scripting, Frame=1: Line 2: ';' expected import mx.transitions.easing.*;
This is puzzling. In three ActionScript references in front of me, on Google and in this forum no one else seems to have had this issue, and I can't seem to find any information on what importing requires.
These imports are at the top of the first frame of the first scene of my entire Flash project on a layer dedicated to ActionScripting. They are the only classes I am currently importing.
Does anyone have any insight as to why this might be happening, or perhaps a tutorial or other information source for importing classes? I figured the rest of the code is probably pointless, especially since it's very much in the works, but if anyone needs the whole chunk of code let me know.
Thanks,
-MadMadchen
Why Do I Get '{' Expected On Good Code
Good Afternoon All. I am brand new to ActionScript in Flash CS3 so I KNOW this is a stupid question. I have been charged with creating flash banners for my boss. I have done one and added a URLRequest just fine. When I tried to add same script to next banner I keep getting a '{' expected error. I have worked on this for 2 hours now and simply cannot see any difference between the 2. Why would 1 work and the other not?
Expected A Field Name After '.' Operator
Hi! I´m going crazy over here! Im building a game (blocks-game) but I get a error all the time!
my code looks like this:
over.function endGame(0);
my code in the movieclip over looks like this
function endGame(){
_root.finalDisplay.text = "Spelet är slut! Försök igen!";
shadeActive=true;
}
and this is my error message:
**Error** Scene=Play, layer=actions, frame=1:Line 60: Expected a field name after '.' operator.
over.function endGame(0);
Total ActionScript Errors: 1 Reported Errors: 1
Anyone have a clue?
Thanks!!
Font Is Not Displayed As Expected
Hi,
I am not familiar with fonts in general and don't know what kind of problem it could be. So please give me a clue how to solve this problem.
I have a Doulos SIL font downloaded from here: http://scripts.sil.org/cms/scripts/p...osSIL_download
Attached picture shows 3 views where this font is used:
1. flash during presentation - generated by htmlText flash function or dynamic text (doesn't look ok).
2. firefox html page (looks ok)
3. flash stage during editing (static text or dynamic) (also looks ok)
Please help
IF Statement Not Working As Expected
Code:
for (i=0;i<12;i++){
if ( string1[i].MC._rotation==0 && ( _global.shootInstance != _root["sphere1"+i].sphereInstance ) ){
trace( _root["sphere1"+i].sphereInstance );
trace( _global.shootInstance );
trace( "different" );
}
The array string1 has 12 entries with each a different _rotation value. One of them is always zero.
sphereInstance and shootInstance are integers which can either be 1, 2 or 3.
When (string1[i].MC._rotation==0)==true the if script ALWAYS executes no matter what the second parameter gives. Many times the traces reveal that the two values are equal.
When I change the != to == the script never executes
This certainly got me puzzled :S
Flv Scrubber Not Responding As Expected
Hi,
I have built an flv player and it works fine, streaming video. One issue that I do have though is that the scrubber progress bar doesnt respond as expected when one tries to move to another part of the movie. it skips forward and doesnt even allow you to go to some points of the movie.
I cant figure out what im doing wrong at all.
The code effecting it is as follows:
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded:Number;
var duation:Number;
ns["onMetaData"] = function(obj){
duration = obj.duration;
mins = Math.floor(duration / 60);
secs = Math.floor(duration % 60);
total_time = mins + ":" + secs;
}
//track ammount of video loaded. call url when a certain level is hit (e.g. 50%)
var total_elapsed = 0;
function videoStatus(file_location){
var file_location = file_location;
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
loader.loadbar._width = amountLoaded * 290;
loader.scrub._x = (ns.time / duration )* 290;
elapsed = ns.time;
elapsed_mins = Math.floor(elapsed / 60);
elapsed_seconds = Math.floor(elapsed % 60);
_root.total_elapsed = elapsed_mins + ":" + elapsed_seconds;
if((ns.time > duration / 2) && (pay_already_fired != true))
{
_root.payment_status = "pay now!";
//make sure to add escape loop after it does it once.
trackingXML = new XML();
tracking_element = trackingXML.createElement("AssetHitThreshold");
tracking_element.attributes.asset_name = _root.file_location;
tracking_element.attributes.time_played = ns.time;
trackingXML.appendChild(tracking_element);
// C. Send the LOGIN element to the server,
//place the reply in loginReplyXML
trackingXML.sendAndLoad("http://10.37.0.21:3003/network/asset_played");
trace(trackingXML);
pay_already_fired = true;
}
}
var scrubInterval;
loader.scrub.onPress = function(){
clearInterval(videoInterval);
scrubInterval = setInterval(scrubit,10);
this.startDrag(false, 0, this._y, 326.4, this._y);
}
loader.scrub.onRelease = loader.scrub.onReleaseOutside = function (){
clearInterval(scrubInterval);
videoInterval = setInterval(videoStatus, 100);
this.stopDrag();
}
function scrubit(){
//returns correct number of seconds based on the scrubber. (math.floor takes a num and rounds down)
ns.seek(Math.floor((loader.scrub._x / 208) * duration));
}
the swf can be seen here: http://www.chris-gallagher.com/flash...ol_control.swf
the source flash is here: http://www.chris-gallagher.com/flash/ee.rar
any help on this at all would be mostly appreciated. I've already tried to rebuild that part of the movie twice to no avail
cheers in advance
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();
GotoAndPlay() Not Working As Expected
Hi everyone. Has something changed with gotoAndPlay()?
I am getting unexpected results. I have a simple 2 frame swf with nothing on the stage.
Frame 1 reads:
trace(currentFrame);
and Frame 2 reads:
trace(currentFrame);
gotoAndPlay(2);
The expected results are:
1
2
2
2
(etc.)
However I am getting:
1
2
1
2
1
2
(etc.)
Why is gotoAndPlay(2) actually going to frame 1 and looping from there? Has something changed in AS3?
Thanks!
Expected A Field Name After '.' Operator.
OK, so i havent used flash in about 6 or 7 years and I was assigned to design a website for my company to be published ASAP. I am using AS 2.0.
I'm on a tight deadline, and I am learning as i go. I understand the principles behind AS, but dont understand all the exact language rules. I've been copying and changing script from tutorials, and I even wrote a good amount of my own script... woot!
On part of the site called "capabilities" i have 5 buttons which you click to view a gallery with a description of each "capability".
The way i accomplished this was to create a movie clip called "cababilities gallery" which is a dynamic image gallery that loads from an .xml file.
To get a different gallery to load for each button, i made 5 key frames in tehr "capabilites gallery" movie clip. Each keyframe is basically the same, with the only difference being I changed the script to load a different xml file in a corresponding folder (frame1 loads an .xml from the folder "caps1" which tells the gallery to load images from the "caps1" folder, frame 2 loads an .xml from "caps2", etc...)
When i "test the movie" (ctrl+enter) everything works exactly as i want it to, but i get the error message: "Expected a field name after '.' operator." and I get 5 errors, one for each line with "capX.on (release){"
Can anyone tell me what the problem is? The code works, because each button does what i want and loads different pics/descriptions into the "capabilities gallery" mc. So if the code works, what is the error message trying to tell me?
THANKS IN ADVANCE FOR HELP !!!!!
My script for the buttons is as follows (cap1, cap2, etc are instance names of the buttons ---- capsGallery is instance name of the gallery)
ActionScript Code:
cap1.on (release) {
capsGallery.gotoAndStop(1);
}
cap2.on (release) {
capsGallery.gotoAndStop(2);
}
cap3.on (release) {
capsGallery.gotoAndStop(3);
}
cap4.on (release) {
capsGallery.gotoAndStop(4);
}
cap5.on (release) {
capsGallery.gotoAndStop(5);
}
Button Not Working As I Expected :(
Got two problems for ya'll:
1. I have a button that looks like a flaming letter.. pretty .. so I added a fire sound fx to the 'over' frame inside the button. I want it to immeadetly stop playing the sound fx when I mouse off the button. I've tried shorting the sound FX and looping it.. But then it keeps looping when I roll off the button. and doesn't seem to ever stop. I have set it to play once. but it also continues to play after I've rolled off. I really just want it to loop untill I am not hovering any more. It would be especially nice if it also faded out when I moused off. But I'm ok to settle on just it shutting up all togher when I'm not on it. ??? help!
and..
2. I have another button. It's cute.. :) looks like those old film strips of negatives you would get back in the day when you would take your photos in to get developed. and I have it as a button.. nested in it is a movie clip that unrolls the film strip when you mouse over it. And then voila... there are pictures to choose from. When you mouse out.. the film strip rolls back up and goes away. That all works fine and dandy but the little pics inside the film strip are buttons which at this point are nested in a movie clip which is nested in a button. And when i mouse on the thumb nails at the bottom of this nested chain they do something funny. I don't have the file up so you can see it but i can email you it if you would like to see. but basicly the film strip rolls back up and goes away because it thinks i'm off of it and that is what is controlling the movie clip from playing and stoping. even though the buttons are in the movie clip it .. well its hard to explain. so i don't know.
................ok.. I just got it up on a geocites account that.. didn't take that long.. hurray..
its at: http://www.geocities.com/acistephanie/FILM.html
when you mouse over the thumb nails the film wants to roll back up.. any ideas.
thanks in advance.
Stephanie
acistephanie@hotmail.com
Identifer Expected Error
Hi!
I'm updating a flash file that makes action script calls to two .as files. The only thing I'm doing is adding new names to the names.as file. But when I publish the flash file to an .exe, I keep getting an Identifier Expected error. I've tried in three versions of flash as well as published using as 1, 2 and 3, but still get the errors. Everything worked fine last year when we updated this file so I'm wondering if someone can help.
The flash file has this script in the opening frame:
fscommand("fullscreen", "true");
fscommand("allowscale", "false");
fscommand("showmenu", "false");
#include "names.as"
#include "hm.as"
The action script files are attached. hm.as is first, names.as is second.
Attach Code
Stage.scaleMode = "noScale";
Stage.align="LT";
var raindropNumber = 0;//total number of names
var raindropTemp = 0;//total number of raindrop objects
var currentRaindrop = null;
var rainText = new TextFormat();
rainText.font = "rainFont";
rainText.size = 38.4;
rainText.color = 0xffffff;
function startRain() {
this["rainDrop"+raindropTemp] = new rainDrop(this,this.rainPeople[this.raindropNumber],this.rainDropTemp,this.currentRaindrop.x,this.currentRaindrop.y,this.currentRaindrop.width);
this.currentRaindrop = this["rainDrop"+raindropTemp];
this.raindropNumber = (this.raindropNumber+1) % this.rainPeople.length;
this.raindropTemp = (this.raindropTemp+1) % 10;
}
var rainInterval = setInterval(this,"startRain",2000);
var rainDrop = function(parent,n,i,oldX,oldY,oldW) {
this.parent = parent;
this.body = parent.createEmptyMovieClip("rainDrop"+i,1500+i);
this.body.parent = this;
this.width = parent.getTextSize(n,parent.rainText,0,0,false).width;
this.height = parent.getTextSize(n,parent.rainText,0,0,false).height;
this.x = Math.round(Math.random() * (Stage.width - this.width));
this.y = Math.round(Math.random() * 470) + 40;
if(oldY && (Math.abs(this.y - oldY) < 50)) {//if the Y value might overlap...
if((this.x < oldX && oldX - this.x < this.width) || (oldX < this.x && this.x - oldX < oldW)) { // ... and if the X value overlaps...
if(oldY < Stage.height/2) {//if we are on the top half of the Stage...
this.y += 80;//move down
} else {
this.y -= 80;// if not, move up
}
}
}
this.body.createTextField("text",10,0,0,this.width,this.height);
this.body.text.multiline = false;
this.body.text.wordWrap = false;
this.body.text.embedFonts = true;
this.body.text.text = n;
this.body.text.setTextFormat(parent.rainText);
this.body._x = this.x;
this.body._y = this.y;
this.body._alpha = 0;
this.fadeInInterval = 25;//fade in interval
this.fadeWaitInterval = 1200;//wait between fadein and fadeout
this.fadeOutInterval = 35;//fade out interval
this.fadeRate = 4;//amount of alpha increase
this.fadeInterval = setInterval(this,"fadeIn",this.fadeInInterval);
}
rainDrop.prototype.fadeIn = function() {
if(this.body._alpha<100) {
this.body._alpha += this.fadeRate;
} else {
clearInterval(this.fadeInterval);
this.fadeInterval = setInterval(this,"wait",this.fadeWaitInterval);
}
}
rainDrop.prototype.wait = function() {
clearInterval(this.fadeInterval);
this.fadeInterval = setInterval(this,"fadeOut",this.fadeOutInterval);
}
rainDrop.prototype.fadeOut = function() {
if(this.body._alpha > 0) {
this.body._alpha -= this.fadeRate;
} else {
clearInterval(this.fadeInterval);
}
}
function getTextSize(theText,theFormat,theWidth,theHeight,multiline) {
var xw = (theWidth>0) ? theWidth : 0;
var xh = (theHeight>0) ? theHeight : 0;
this.createTextField("textFieldNamedBob",99000,-1000,-1000,xw,xh);
this["textFieldNamedBob"]._alpha = 0;
this["textFieldNamedBob"].multiline = multiline;
this["textFieldNamedBob"].wordWrap = multiline;
this["textFieldNamedBob"].embedFonts = true;
this["textFieldNamedBob"].text = theText;
this["textFieldNamedBob"].setTextFormat(theFormat);
if(multiline==false) {
this["textFieldNamedBob"].autoSize = "left";
} else {
this["textFieldNamedBob"].autoSize = "center";
}
var rs = {
width:Math.ceil(this["textFieldNamedBob"]._width),
height:Math.ceil(this["textFieldNamedBob"]._height)
};
delete this["textFieldNamedBob"];
return rs;
}
/* */
var rainPeople=[
"test name 1"
],
/*
All of the names need to be in quotes,
and all of them EXCEPT THE LAST ONE
need to be followed by commas( , ).
*/
OnDisconnect Not Working As Expected On IE7
I have an application for a poker game which works perfectly in Firefox 1.5 and 2.0, however in IE7 (not too sure about IE6 thou) there is a serious problem. I shall explain..
User logs in. Opens a popup of the game which is just a php script which loads in the SWF. SWF successfully connects the the FCS 1.5 and sits around waiting for another player... however at any time if the person closes the window and any other IE7 windows are open the "onDisconnect" rule on the server side does not execute, therefore since this game only allows you to play one game at any one time, if you try to open a window to start a new game it finds an existing instance of the player.
Only if *all* IE7 windows are closed does the onDisconnect finally recognise that the person has disconnected.
This is only happening in IE, wherehas FIrefox, Safari and Konq. all work as expected.
The browser flash plugin is version 9 on all the machines.
Anyone had or experience similar problems with the onDisconnect, and more importantly.. is there a fix? This is really urgent since this game should have gone out a while ago, and really just this problem is causing a hold-up.
If it helps, please check out the problem on PokerWars, login, open a game, close the popup window and re-open a new game... this is driving me *nuts*
Many thanks
Edited: 11/30/2006 at 12:07:16 AM by Wyldie
Syntax Error ? ')' Expected ?
I am trying to recreate the Falling Snow 2.0 tutorial, only instead of snow I have umbrellas, only am baffled by a small section of code...
snowflakes = 75;
do {
** duplicateMovieClip(snow, "snow" + k, k);
** k++;
} while (k != snowflakes);
this is the code provided in the tutorial. but i have changed a couple of the names so my code is this...
umbrellas = 75;
do {
** duplicateMovieClip(umbrella, "umbrella" + k, k);
** k++;
} while (k != umbrellas);
you'll notice i have merely changed SNOWFLAKES to UMBRELLAS and SNOW to UMBRELLA. However, while the first bit of code works fine, the second either crashes flash, or presents me with these two errors...
**Error** Symbol=umbrella_mc, layer=Actions, frame=1:Line 3: Syntax error.
** duplicateMovieClip(brolly, "brolly" + k, k);
**Error** Symbol=umbrella_mc, layer=Actions, frame=1:Line 4: ')' expected
** k++;
Can anyone help with why this is happening. Am using Flash MX 2004, if that makes any difference.
Thanks
Flash Keeps Telling Me A ';' Was Expected..but ITS THERE
Symbol=tablesMovie, Layer=T, Frame=1: Line 8: ';' expectedThis is the error that I get. This is the code associated with it:
I have bolded the troubled line of code
Code:
on(rollOver){
if (_root.menu2.tables.ablesMovie._currentframe == 10)
stop();
else{
_root.menu2.enabledIn(1);
_root.menu2.tables.lineMovie.lineMask.whichButtonIn(1);
_root.menu2.tables.ablesMovie.seatMovie.gotoAndPlay("in");
_root.menu2.tables.8seaterOptionsBox.gotoAndPlay("in");
_root.menu2.ptcPos(1);
_root.window.menuWindowContent("Tables");
}
}
why is it giving me this error?
SetInterval Not Working As Expected
I used setInterval to fade the main sequence of my page. It works, but for some reason no matter what I change setInterval to, it does it at the same speed of 30 frames per second. So if it has to set the Alpha level from 100% to 0% it will take 3.3 seconds. You can see it here: Http://www.dhicompany.com. Does anyone know why this is or how to fix it?
Quote:
stop();
function fadeOut(){
_root.loaderClip._alpha--;
_root.barLoad1._alpha--;
_root.barLoad2._alpha--;
updateAfterEvent();
if(_root.barLoad2._alpha<=0){
clearInterval(timer);
_root.gotoAndPlay("startTwo");
}
}
timer = setInterval(fadeOut,10);
MouseEnabled Not Working As Expected
Hello. I have a MovieClip on the stage that's operating as a button with ROLL_OVER, ROLL_OUT, and CLICK events established. In the CLICK event, I want to disable the button through: theMovie.mouseEnabled = false, but it's not working! The ROLL_OVER, ROLL_OUT and CLICK events continue to fire despite trace statements confirming that mouseEnabled = false! Here's the code:
private function clickHandler(evt:MouseEvent):void {
//do some stuff...
var selectedClip:MovieClip = MovieClip(evt.currentTarget);
selectedClip.mouseEnabled = false; //mouse events are still enabled after this runs!
selectedClip.buttonMode = false; //this works
}
private function rollOverHandler(evt:MouseEvent):void {
//now that mouseEnabled = false, this event shouldn't fire, but it does!
//what's worse - the trace below confirms that mouseEnabled = false! shenannigans!
trace("this shouldn't be displayed at all", evt.currentTarget.mouseEnabled);
}
If anyone has any insight as to what's happening here, I would be grateful for your help! Thanks!
Andy
[Flash8] Error - ':' Expected, But There's Already A :
Hello Kirupa! I'm hoping this is an easy fix, and that I just don't understand the syntax quite yet.
I'm trying to get an an eye (mcEyeAnim) to blink every 15 seconds.
The following code is giving me the following error.
Code:
var eyeInterval = 15;
while (eyeInterval = 15) ( {
countDown = function():Void {
eyeInterval--;
if (eyeInterval == 0) {
clearInterval(eyetimer);
trace("blink");
mcEyeAnim.play();
eyeInterval = 15;}
});
var eyetimer = setInterval(countDown, 1000)
**Error** Scene=Scene 1, layer=actions, frame=1:Line 4: ':' expected
countDown = function():Void {
I'd be very thankful for a bit of guidance. Thanks for looking.
FullScreen Scaling Not Quite As Expected
Hi All,
So i'm just making a very simple video player that can go full screen much like YouTube's.
Right now when i go to fullscreen mode, it takes up the entire screen and centers the video but my controls bar isn't properly located.
I have my stage set at 800 by 600, and when i go full screen I want the controls to sit at the bottom of the screen like they do in YouTube's player.
The problem is that because my monitor's aspect ratio (1280 by 1024) isn't the same as the stage's, there ends up being blank space in the bottom and top of the screen and my controls are hovering about 50 pixels above the bottom of the monitor.
Any way to get around this?
Thanks!
Syntax Error ? ')' Expected ?
I am trying to recreate the Falling Snow 2.0 tutorial, only instead of snow I have umbrellas, only am baffled by a small section of code...
snowflakes = 75;
do {
** duplicateMovieClip(snow, "snow" + k, k);
** k++;
} while (k != snowflakes);
this is the code provided in the tutorial. but i have changed a couple of the names so my code is this...
umbrellas = 75;
do {
** duplicateMovieClip(umbrella, "umbrella" + k, k);
** k++;
} while (k != umbrellas);
you'll notice i have merely changed SNOWFLAKES to UMBRELLAS and SNOW to UMBRELLA. However, while the first bit of code works fine, the second either crashes flash, or presents me with these two errors...
**Error** Symbol=umbrella_mc, layer=Actions, frame=1:Line 3: Syntax error.
** duplicateMovieClip(brolly, "brolly" + k, k);
**Error** Symbol=umbrella_mc, layer=Actions, frame=1:Line 4: ')' expected
** k++;
Can anyone help with why this is happening. Am using Flash MX 2004, if that makes any difference.
Thanks
|