Jump to content

Recommended Posts

Posted

I encountered a weird problem when I doing my AS2 programming in Flash.

When I publish the .swf movie, and play it, it returns

A script in this movie is causing Flash Player to run slowly. If it continues to run, your computer may become unresponsive. Do you want to abort the script?

 

And after I search and test, I found out the main problem would be this loop which caused the problem.

function readXML()

{

photoNumArray = [];

firstchild = photoxml.firstChild;

thumbpath = firstchild.attributes.thumbpath;

fullpath = firstchild.attributes.fullpath;

for (secondchild = firstchild.firstChild; secondchild != null || secondchild != undefined; secondchild.nextSibling)

{

photoArray = new Array();

photoArray[1] = secondchild.attributes.thumbname;

photoArray[2] = secondchild.attributes.fullname;

photoArray[3] = secondchild.attributes.desc;

photoNumArray.push(photoArray);

delete photoArray;

}

}

 

photoxml = new XML();

photoxml.ignoreWhite = true;

photoxml.load("photos.xml");

photoxml.onLoad = readXML;

 

The FOR LOOP is causing this lagness. And the XML contents is as follows.

<gallery thumbpath="images/thumbnail/" fullpath="images/fullsize/">

<image thumbname="t01.jpg" fullname="f01.jpg" desc="First picture"></image>

<image thumbname="t02.jpg" fullname="f02.jpg" desc="Second picture"></image>

<image thumbname="t03.jpg" fullname="f03.jpg" desc="Third picture"></image>

<image thumbname="t04.jpg" fullname="f04.jpg" desc="Fourth picture"></image>

<image thumbname="t05.jpg" fullname="f05.jpg" desc="Fifth picture"></image>

<image thumbname="t06.jpg" fullname="f06.jpg" desc="Sixth picture"></image>

</gallery>

 

The weird thing is, I used the exactly same FOR LOOP in my another .swf movie, it returns no error.

But in this case, just the XML sheet is 2 lines longer than the working one, and the FOR LOOP creates 1 more array for each loop.

And it returns such error.

 

Anyone can help me? Thanks.

 

Earnest,

JcX

Posted

EDIT

Problems solved, by just simply rewrite the whole scripts and modify a little bit which I don't think will affect the loop

 

New problems:

I use another loop to help me create a few movieclips on the stage, and loads the picture URL from XML.

function loadPhoto()

{

for (p=0; p<=5; p++)

{

thumblist_mc = _root.photolist_mc.createEmptyMovieClip("thumb"+p, p);

thumblist_mc._y = 100 * p;

thumblist_mc.loadMovie(thumbpath + photoNumArray[p][1]);

 

thumb0.onRelease = function()

{

preview_mc.loadMovie(fullpath + photoNumArray[p-1][2]);

}

}

}

 

The problem is this part

thumb0.onRelease = function()

{

preview_mc.loadMovie(fullpath + photoNumArray[p-1][2]);

}

 

Can't I use onRelease function for movieclips I created by createEmptyMovieClip() function?

And if I use FOR LOOP to create movieclips, how can I set different loadMovie("URL") for each movieclips I've created?

Please help.... Million thanks to all.

Posted

Hi very nice to meet you.

I'm just an undergraduate engineer who obsessed with multimedia design, especially Flash.

I couldn't find any tutor who willing to teach me for FREE, so I learn it all by myself. ^^

Maybe we can exchange our experience sometimes though.

 

Again... It's my honour to meet you Karthi.

Posted

Nope, I from Malaysia, just few steps below you. :-p

 

Hmmmm.. Flash aren't so welcome just because of it size and loading speed.

but after AS 3.0, I believe the speed had immensely increased and that should be a problem though.

Although VB.Net, Java are very well accepted, but still I insisted to use Flash as my main web presentation.

Posted

Flash has its own incomparable uniqueness - attracting animation + interesting interaction with browsers.

The reason I like Flash is because it can makes me outstand from the crowd.

All my friends like my site because I'm based on Flash while they're based on blog.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...