Preloader Actionscript problem
As a relative newcomer to Actionscript, I came across a
preloader tutorial (from a trusted source) which reveals a cut out
photograph as the movie loads. I decided to use it, but although I
have checked and double-checked the Actionscript, Flash 2004 keeps
reporting an error and the preloader is not working.
The problem is obviously in line 6 and I just thought that
someone might be able to look at the Actionscript and see the
problem (which I can't!).
Here's the Actionscript;
stop();
mask_mc._height = 1;
this.onEnterFrame = function() :Void {
var loadedData:Number = this.getBytesLoaded();
var allData:Number = this.getBytesTotal();
var percent:Number = Math.round(loadedData/allData=100);
mask_mc._yscale = percent;
if (loadedData>=allData) {
gotoAndStop(10);
delete this.onEnterFrame;
Here's the error report from Flash;
**Error** Scene=Scene 1, layer=Actions, frame=1:
Line 6: Left side of assignment operator must be variable or
property.
var percent:Number = Math.round(loadedData/allData=100);
Total ActionScript Errors: 1 Reported Errors: 1
Many thanks for any help.
you have an assignment operator (=) where you should have a
multiplication operator (*) at the END of that line.
Similar Messages
-
Mapping ArrayList in java to Actionscript Problem
Hi Guys,
This is wrecking my head. Had this issue for the last two days and cannot for the life of me understand why. I have a service defined as with the following method;
public List getIngredients(){
List list = null;
List ingredientList = new ArrayList();
SandwichDAOFactory fac = SandwichDAOFactory.getDAOFactory(1);
IngredientDAO ingDao = fac.getIngredientDao();
IngredientDTO ingDTO = new IngredientDTO();
Ingredient ing = new Ingredient();
list = ingDao.getAllIngredients();
for (Iterator it=list.iterator(); it.hasNext();) {
ing = (Ingredient) it.next();
ingDTO.setIngredientID(ing.getIngredientID());
ingDTO.setName(ing.getName());
ingDTO.setPrice(ing.getPrice());
ingDTO.setDescription(ing.getDescription());
ingDTO.setType(ing.getDescription());
ingredientList.add(ingDTO);
System.out.println("Calling Service");
System.out.println(list.toString());
return list;
Now I have defined a remotes object in my flex app;
I call this service method when I first load the application;
retrievalService.getAllIngredients();
then handle the result as follows;
private function getAllIngredientsResultHandler(event:ResultEvent):void
ingredientsListData = event.result as ArrayCollection;
var arrList:Array = event.result as Array;
trace("event.result.toString = "+event.result);
trace("ingredientsListData = "+ingredientsListData);
trace("arrList = "+arrList);
I would expect to see the object references delimited in some way for all the trace methods. But when I run the example I get the following output;
event.result.toString = [object IngredientDTO],[object IngredientDTO],[object IngredientDTO],[object IngredientDTO],[object IngredientDTO]
ingredientsListData = null
arrList = null
I dont understand why this is happening. Surely the variables should contain the same info. I did some debugging and found that the event.result object did in fact contain the data as an ArrayCollection. In addition all the elements were objects of the type IngredientDTO and contained all the relevant fields and data. So again I don't understand for the life of me why its not working.
Can you not caste an ArrayList in java to an Array or an ArrayCollection?
Its like the data isn't being mapped or cast properlu from the ArrayList in java to either the Array or the ArrayCollection in actionscript.
This is driving me insane. Has anyone else had this problem and lived to tell the tale?I figured it out. Silly, silly mistake. I was using the wrong import declaration.
import flex.messaging.io.ArrayList;
instead of
import java.util.ArrayList;
Silly silly... -
Questions about this snippet of preloader ActionScript
I'm working on a flash template that uses the following code for its preloader.
onClipEvent (load) {
total = _root.getBytesTotal();
onClipEvent (enterFrame) {
loaded = _root.getBytesLoaded();
percent = int(loaded/total*100);
text = percent+"%";
gotoAndStop(percent);
if (loaded == total) {
_root.gotoAndPlay(2);
2 things about it that I can't figure out:
The variable 'total' was created inside the first block of code, yet how is it being accessed from the second block of code? Wouldn't there be a variable scope issue there?
Also, in the 2nd block of code, when viewing the actual script in Flash, the variable 'text' is highlighted in blue indicating that it is a keyword or something. And the dynamic text field that's supposed to be connected to the value of the variable 'text' [percent + "%"] is simply named 'z', not 'text'. Yet the whole thing still works fine. Don't understand how.
Thanks,
DavidYeah, weird stuff. Not sure why or how this worked, and I just don't care anymore. Sloppiest code I've ever seen :\. I decided to just publish the file in AS3 and whatever works I'll leave in and what doesn't I'll replace. I guess it's mostly any code that's attached to objects. I also got the following message in the output tab as well which points out exactly what I was talking about with this text field...
WARNING: Text field variable names are not supported in ActionScript 3.0. The variable 'text' used for the text field 'z' will not be exported.
Good riddance to this mess of code. -
CFGRID/CFSELECT/ActionScript problem
I have CFGRID "onchange" code below that allows me to click
on a CFGRID row and correctly display (in a separate CFFORMGROUP)
the correct column value in via a CFSELECT object. The field name
is
priority and the grid name is
tasks_grid.
Works fine, but my problem is that I've been unable to get
this to work on non-integer fields. If the field contains a text
string, no matter how small, the ActionScript "if" statements don't
seem to produce results. Could it be incorrect use of the ==
operator? I'm not an AS programmer, so I'm unfortunately on the low
end of the learning curve here.
I hope the above makes sense. Any thoughts would be greatly
appreciated.So far the best solution seems to be to create an array for
each such field that creates a new query column containing the text
data. I then reference the new "text" column ("priorityText", in
this instance) via CFGRIDCOLUMN and use the original "integer"
column (i.e., the actual field data) for the ActionScript matching
code in the child form. The array code is from another post, in the
Rich Forms forum, I believe. -
Hi everyone, my first post one here so i hope someone can be of assistance.
I have been using CS4 with no problems for a couple of months, but i suddenly encountered a problem that i can't get beyond now.
when i click on 'actions' my timeline collapses. This happens whether from right clicking on my timeline or selecting it from the top menu.
Since this has happened i can't find a way of bringing up the actionscript screen.
Has anyone had this problem before?
I hope this makes sense!
Thanks very much in advance.This forum is for suite specific issues only. I can only assume you're looking for Flash help.
If so, please post in the Flash forum.
Bob -
Preloader interruption problem
I am using the following script to preload external .swf's in
my sites. The problem is that when it is interrupted (another link
is clicked). It makes the parent .swf freak out (it plays
continuously through the entire file without paying attention to
stop commands or anything else). Anyone have an idea how to fix
this?
stop();
loadingBar._xscale = 1;
var loadingCall:Number = setInterval(preloadSite, 50);
function preloadSite():Void {
var siteLoaded:Number = getBytesLoaded();
var siteTotal:Number = getBytesTotal();
var percentage:Number = Math.round(siteLoaded/siteTotal*100);
loadingBar._xscale = percentage;
percentDisplay.text = percentage + "%";
if (siteLoaded >= siteTotal) {
clearInterval(loadingCall);
play();
Here is the site it's used in:
http://www.vanderhurdstudio.comYou need to clear out the Interval that loadingCall is
referencing to whenever another link is clicked. The loadingCall
variable is set locally and is only a refence to the global
Interval being set. What's happening when another link is clicked,
is the local loadingCall variable is getting deleted/reset, but the
global Interval still exists and is losing it's timeline reference.
When this happens, the Interval will apply whatever commands are in
the function passed to it (play() in this case) upon whatever
timeline the Interval can find - the parent .swf that still exists.
So when this preloader is interupted, the Interval is telling the
parent .swf to play() every .050 seconds and creating the effect of
playing continuously through the file without stopping - it is
stopping, but being told to play again faster than you can notice
the stop. -
I'm having a problem trying to position the preloader and the
external swf file. Everything seems to work when the preloader
finishes, the swf file loads but out of position. FYI, the swf is
built as a slide presentation. Please help!Thanks, the SWF went right into place. But now it seems the
navigational buttons don't work in the SWF that loaded. Everything
was working fine before I used the preloader. Here's the code:
stop();
// this will be called when the preloader finishes animating
out
function onPreloaderOut() {
preloader_mc.removeEventListener("onPreloaderOut", this);
preloader_mc.loadMovie("main_body.swf");
preloader_mc._x = 0;
preloader_mc._y = 0;
// add this timeline as a listener to listen for the
'onPreloaderOut' event
preloader_mc.addEventListener("onPreloaderOut", this);
// tell the preloader to start preloading this timeline
preloader_mc.startPreload(this); -
Actionscript Problems.... HELP
Ok so heres the thing. I am kind of new to actionscript 3.0
and I am trying to figure out what I am doing wrong with my coding.
I have used this code time and time again and up until I got CS3 it
worked just fine. If there is anyone that can take a look at this
code and tell me what I am missing or what I might have done wrong
I would greatly appreciate your help. below is my coding I am using
to call the outside swf files and also call text documents that
hold my info. Thank you so much for looking and helping if you can
figure out what I messed up.
this.rootcontainer.onLoad = function ()
heightscale = 270.45;
this.btn_news.onRelease = function ()
if (_root.currMovie == undefined)
_root.currMovie = "news";
rootcontainer.loadMovie("News.swf",
this.getNextHighestDepth());
else if (_root.currMovie != "news")
if (rootcontainer._currentframe >=
rootcontainer.midframe)
_root.currMovie = "news";
rootcontainer.play();
} // end if
} // end else if
this.btn_band.onRelease = function ()
if (_root.currMovie == undefined)
_root.currMovie = "band";
rootcontainer.loadMovie("Band.swf",
this.getNextHighestDepth());
else if (_root.currMovie != "band")
if (rootcontainer._currentframe >=
rootcontainer.midframe)
_root.currMovie = "band";
rootcontainer.play();
} // end if
} // end else if
_root.currMovie = "news";
rootcontainer.loadMovie(_root.currMovie + ".swf");
stop ();I tried using that code and it came up with Duplicate
function definition, function onPress_but(event:MouseEvent). do you
know why this might be showing up or did I just place this script
in the wrong spot? I have added a few more lines of code but I
didnt change anything till I added this to it and thats when it
came up with that error. -
Hello.
I've made a movie, and the scene1 timeline has only one
frame. There I have 4 different movieclips into different layers,
each one with is own timeline.
Now, how do I insert a preloader bar in my movie?
When I tried with tutorials, it doesn't work, and even if the
movie loads like before I entered the preloader, it seems to become
looping in the first frames.
Thanks for your help!1., move all the 1.st frame into the 2.nd frame
2., make sure frame1 is empty
3., place preloader bar movie clip in 1.st frame
4., to 1.st frame, write this code:
stop();
myPreloader.onEnterFrame = function():Void {
var loaded:Number = _root.getBytesLoaded();
var total:Number = _root.getBytesTotal();
var percentage = 100 * loaded / total;
trace(percentage);
if(percentage => 100) {
_root.nextFrame();
I bet it will work
couvegalega wrote:
> Hello.
>
> I've made a movie, and the scene1 timeline has only one
frame. There I have 4
> different movieclips into different layers, each one
with is own timeline.
>
> Now, how do I insert a preloader bar in my movie?
>
> When I tried with tutorials, it doesn't work, and even
if the movie loads like
> before I entered the preloader, it seems to become
looping in the first frames.
>
> Thanks for your help!
> -
have a simple preloader I'm using to go to a url
I keep getting 1087: Syntax error: extra characters found
after end of program.>>ifFrameLoaded("end") {
You might want to read up on the if statement. ifFrameLoaded
has been
deprecated for 4 player releases. You want something like:
if(this._framesloaded ...){
Dave -
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/ -
Hi, everyone!
I've made a preloader in Flash CS3 with AS2. It has the
following code
in theory it works, but if i test it, first it shows nothing,
and after a while it become visible and shows the preloader bar
loading from 90%.
the 'preloader' in the code is a movieclip. it contains a 100
frame shape tween.
Does anyone know, why it isn't visible at the beginning? How
can i fix it?You have to keep in mind what is actually going on when Flash
is checking the progress of the download. There are a whole lot of
processes going on. Flash has to spend most of its time and energy
in the actual download, not in the reporting. The amount of the
content that is reported at first and the size of each subsequent
chunk will not start at 1% and proceed at orderly intervals. The
result that you get when auditing the download process will depend
on the contents of the file that is downloaded, how large the file
is, the speed of the connection and the speed of the computer's
processor.
Remember, the purpose of showing a download progress is not
to show how long it takes, but to provide a visual que to the user
so that they will know that your site is not stalled. You really
want to design so that you don't need a loading screen. -
External preloader script problem
hi, i'm try to create an external preloader, i've made three layers (the script, one for a funky design of my logo and keep things simple i've also embedded the preloader text in this layer and finally the preloader bar beneath. i've created two frames for each layer, the script has two keyframes, the other layers only have a keyframe first then a standard frame. i can't get it work though, please help. here's the script i'm using on the second keyframe.
var loader:MovieClipLoader = new MovieClipLoader();
this.createEmptyMovieClip("Empty_movieclip",1);
loader.loadClip("Creative-Outrage.swf",Empty_movieclip);
var preload:Object = new Object();
loader.addListener(preload);
preload.onLoadProgress = function (target, loadedBytes, totalBytes){
if (_root.getBytesTotal() != _root.getBytesLoaded()){
gotoAndPlay(1);
else (loadMovie("Creative-Outrage.swf",Empty_movieclip));
removeMovieClip("Preloader_movieclip");
Bar_movieclip._xscale=(_root.getBytesLoaded()/_root.getBytesTotal())*100;
Preloader_movieclip.Loader_text.text=Math.round((_root.getBytesLoaded()/_root.getBytesTota l())*100)+"% Complete";try:
var loader:MovieClipLoader = new MovieClipLoader();
this.createEmptyMovieClip("Empty_movieclip",1);
// move the next line to the end of your code
loader.loadClip("Creative-Outrage.swf",Empty_movieclip);
var preload:Object = new Object();
loader.addListener(preload);
// the next two lines should be in preload.onLoadProgress
//Preloader_movieclip.Bar_movieclip._xscale=(loadedBytes/totalBytes)*100;
//Preloader_movieclip.Loader_text=Math.round((loadedBytes/totalBytes)*100)+"% Complete";
preload.onLoadProgress = function (target,loadedBytes,totalBytes){
if (loadedBytes = totalBytes){
// (loadMovie("Creative-Outrage.swf",Empty_movieclip)); <-- comment out or remove this line
removeMovieClip("Preloader_movieclip");
else {
gotoAndPlay(1);
it's still not displaying any gradual progress, it just displays the full progress bar immediately even when i simulate a download and it's not loading the external file either. -
Hi;
Please advise on this error:
Scene 1, Layer 'PreLoader', Frame 1, Line 1
1087: Syntax Error: extra characters found after end of program
onClipEvent (enterFrame) {
loading = _parent.getBytesLoaded();
total = _parent.getBytesTotal();
if (percent == undefined) percent = 0;
percent -= (percent-((loading/total)*100))*.25;
per = int(percent);
percentage = per+"%";
loadBar._width = per;
if (percent>99) {
_parent.gotoAndStop(2);
TIA,
benothat's as2 and in as2 that code would have to be attached to a movieclip, not a timeline.
in as3, no code can be attached to an object. as3 does have an enterframe event.
attached to your main timeline:
this.addEventListener(Event.ENTER_FRAME,f);
var percent:Number=0
function f(e:Event){
var loading:uint = loaderInfo.bytesLoaded;
var total:uint = loaderInfo.bytesTotal;
percent -= (percent-((loading/total)*100))*.25;
loadBar.width = percent;
if (percent>99) {
gotoAndStop(2); -
Just received my new CS3 Web Premium in the mail yesturday
and have been playing around with it, specially with flash. Do need
some help with it though while I my trying to learn it. I have C++,
VB, and PHP experience but have never really played around with
actionscript as far as programing (used it to do basic event
actions back in MX 2004). Anyways, to the point. I can't get this
code to work. I am assuming I need to change the string to an
integer, but not sure how.
Here is the code:
import fl.events.*;
import flash.events.*;
btnCalc.addEventListener(MouseEvent.CLICK, calculate);
function calculate(e:Event):void {
var Num1:Number = txtNum1.text;
var Num2:Number = txtNum2.text;
lblOutput.text = Num1 + Num2;
}int and uint (and void) are not object types, they are
primitive type
associations. Values with the type int in Flash are still
based around the
Number class (being capitalized, there is an actual Number
class in Flash),
but benefit from integer optimizations at a lower level.
"WebmastaDj" <[email protected]> wrote in
message
news:f0q66n$p2p$[email protected]..
>I have noticed that. Actionscript is very case sensitive
and not very
>consistent. But I am sure there is a reason why they do
that not sure what
>though. -
Hi,
My preloader only counts up to 40%, plays the first part of
the scene and hangs until it reaches 100% and then the main movie
clip plays. How can I modify my code so that it loads to a 100%
first and then play the movie fluidly?
In frame 1:
onEnterFrame = function() {
t = _root.getBytesTotal()
l = _root.getBytesLoaded()
p = int ( (l/t) * 100 )
_root.percentLoaded.text = p; //percentLoaded is the instance
name for my textbox
//_root.kilobytes.text = l+"kb of "+t+"kb"; //I DON'T USE
THIS
if ( t == l && t > 100 ) {
delete _root.onEnterFrame;
//gotoAndPlay("movie"); // I COMMENTED THIS OUT BECAUSE THE
MOVIE RELOADS AT THIS POINT FOR SOME REASON
Frame 2:
if (_parent.getBytesLoaded() == _parent.getBytesTotal()) {
_parent.gotoAndPlay("movie");
ThanksIf you're code is on root then placing an onEnterFrame on the
timeline like
that is pretty much pointless, as the code will run anyway
once you have it
right.
>> if ( t == l && t > 100 ) {
How can t equal 1 and be greater than 100? It can't. I'm not
sure what
you're going for here, but the if statement is not needed.
In frame 2, you're close except you want to gotoAndPlay(1) if
bytesLoaded is
less then bytesTotal.
On frame 1, try this:
t = this.getBytesTotal();
l = this.getBytesLoaded();
p = Math.round( l / t * 100 ); // int has been deprecated
since version5.
percentLoaded.text = p;
On frame 2:
if (this.getBytesLoaded() >= this.getBytesTotal()) {
gotoAndPlay("movie");
}else{
//loaded is less, keep looping
gotoAndPlay(1);
HTH
Dave -
Adobe Community Expert
www.blurredistinction.com
www.macromedia.com/support/forums/team_macromedia/
Maybe you are looking for
-
How can i remove my phone number off my macbook so it could not receive my messages
everytime i send a text message from my phone it randommly apears on my laptop i was wondering how that can be stoped. please need help.
-
Database 10.2.0 While doing export/import operation what are factors effecting the speed of operation..?
-
I have a requirement to render a screen on a thick-client that contains data from the server (that's the simple bit), however if the network connection to the server is unavailable the most recent image of the data should be used instead. I'm looking
-
HI everyone, I have a big problem. i wanna generate a Froms that wil have to be dynamic with the content of the table ALL_TAB_COLUMNS. I have to be able to select in this table in the POST_QUERY. My FORM will be based on a table defined in the Reposi
-
Performance problem on function-based index
Hi guys, I am having performance problems with the addition of new function-based indexes. alter session set nls_comp='ANSI'; alter session set nls_sort='BINARY_CI'; * have to run this because the of case-insensitivity requirements I have a view. for