Beginning Woes

  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

I'm tryign to peice together my own little photo album in flash. right now i'm just trying to get a variable ammount of thumbs to show up in a payne...

problem 1 : picHolder.loadMovie("/test.jpg");

test.jpg is a 88x88 video, but when it shows up it is considerably smaller, i dont know how to stop this resizing from happening


problem 2 :

I'm trying to use something similar to
for (i=1;i<num_pics;i++)
{
duplicateMovieClip("picHolder","pic" add i, i );

????????.loadmovie("/test.jpg");

}

I cannot for the life of me find out how to reference these created images i've tried pointes and loading them into arrays, but i dunnea, i'm must stumped


Thanks

Willy
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

test.jpg is an 88x88 video? Jpeg Video? :?:

Er well, no resizing should occur unless you manually resized the clip you are loading the file to.

As for the for loop problem. You have
Code: [ Select ]
duplicateMovieClip("picHolder","pic" add i, i );
, given that using "add" to tack on the value of a variable to a string was FLash 4 sintax, you can now replace that with a "+" sign and it will work just peachy :) Definitely makes the code cleaner too.
Code: [ Select ]
duplicateMovieClip("picHolder","pic"+i, i );


So uh, with that said, duplicateMovieClip() works like this...
Code: [ Select ]
duplicateMovieClip(clipToDuplicate, newlyCreatedClipsName, level);
So you can reference your duplicated clips by using "pic1", "pic2", "pic3", "pic4".

Often times people use associative array referencing to target the newly created clips (very useful when dealing with dynamically created items), that would go something like this...
Code: [ Select ]
duplicateMovieClip("picHolder","pic"+i, i );
this["pic"+i].loadMovie("/test.jpg");
  1. duplicateMovieClip("picHolder","pic"+i, i );
  2. this["pic"+i].loadMovie("/test.jpg");
Where "this" is the timeline the clip is contained in. But as you may see, typing 'this["pic"+i]' is just a hassle when you are trying to do more than one thing to a clip.

So what can you do instead?

Simple, give the newly created clip an ID.

How do you do that?

Well, a little something like this...
Code: [ Select ]
newMC = duplicateMovieClip("picHolder","pic"+i, i );
newMC.loadMovie("/test.jpg");
  1. newMC = duplicateMovieClip("picHolder","pic"+i, i );
  2. newMC.loadMovie("/test.jpg");
The value of the newMC variable will be the newly created clip, so you can use that value to adjust the properties of that clip :)


I hope this info helps :)
  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

Yes that was a nice response, i'm looking forward to tackling it when i get home from work.


I tried methods similar to what you said, but mostly guessing at the syntax.


needless to say i'm going to smuggle the actionscript bible home from work today, I'm sure you'll be hearing much more from me before i get this project done. :oops:


WILLY
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

If you are looking for any AS books, even though I have never read any, I can recommend Actionscript Definitive Guide by Colin Moock (preferably the MX version because it is newer, I hear he is working on an MX2004 version as well). I hear it is pretty much a must have for anyone planning on getting into Actionscript (heard from everyone I know who has it and uses Actionscript). I would buy it if I wasn't so poor at the moment :?

So yeah, I haven't heard much about AS Bible, so let me know how it is after you read it, i'm always interested in hearing what AS books are good.

I hope things work out for you :)
  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

Woooow flash is the most frustrating app i've ever tried to use.


I'm having a great deal of difficulty getting newer versions of my .fla to execute (meaning when either "test movie" or "publish preview" or save and upload to server I dont always see my current updates)

I was wondering what method is common practice for dealing with a.scripts?


-------

A second reoccurring problem i have is really having difficulty seeing where the bounds of my swf file are, as i re-run my script the location of it seems almost random.


-------

the tragedy can be seen at http://www.cashportals.net/justin/


CODE :::
Code: [ Select ]
function showContent(){
pic_side=88;
 
 for(i=0;i<5;i++){
    
    currentPic= duplicateMovieClip("picHolder","pic"+i,i);
    setProperty(currentPic, _x, 15 * i);
  currentPic.loadMovie("http://www.cashportals.net/justin/test.jpg");
    
 }

 picHolder.loadMovie("http://www.cashportals.net/justin/test.jpg");
 setProperty(picHolder, _x, 0);
 setProperty(picHolder, _y, 100);
 content.text = "recent"+c["n"]+"bye"+i+currentPic+"icount="+i;
}

var c = new LoadVars();
c.onLoad = showContent;
c.load("http://www.cashportals.net/justin/dbreturn.php","_self","POST");
  1. function showContent(){
  2. pic_side=88;
  3.  
  4.  for(i=0;i<5;i++){
  5.     
  6.     currentPic= duplicateMovieClip("picHolder","pic"+i,i);
  7.     setProperty(currentPic, _x, 15 * i);
  8.   currentPic.loadMovie("http://www.cashportals.net/justin/test.jpg");
  9.     
  10.  }
  11.  picHolder.loadMovie("http://www.cashportals.net/justin/test.jpg");
  12.  setProperty(picHolder, _x, 0);
  13.  setProperty(picHolder, _y, 100);
  14.  content.text = "recent"+c["n"]+"bye"+i+currentPic+"icount="+i;
  15. }
  16. var c = new LoadVars();
  17. c.onLoad = showContent;
  18. c.load("http://www.cashportals.net/justin/dbreturn.php","_self","POST");

END CODE

the fetch script dosent do mcuh it just sets up my DB fetches

note picHolder is an 88x88 movie file
  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

Ok, i figured out my jpeg resizing problem. Somehow the innards of my picholder movie clip were a diferent size than the clip itself ...


I still can't get this clip to duplicate itself and load the pics properly

current code:
Code: [ Select ]
for(i=1;i<5;i++){
    
    
    duplicateMovieClip("picHolder","pic"+i,i);
    setProperty("pic"+i, _x, (pic_side + 5)*i);
    this["pic"+i].loadMovie("http://www.cashportals.net/justin/test.jpg");
    
    
 }
  1. for(i=1;i<5;i++){
  2.     
  3.     
  4.     duplicateMovieClip("picHolder","pic"+i,i);
  5.     setProperty("pic"+i, _x, (pic_side + 5)*i);
  6.     this["pic"+i].loadMovie("http://www.cashportals.net/justin/test.jpg");
  7.     
  8.     
  9.  }


again, the pannels show up, but do not contain anything I think its the loadMovie method... when i do picHolder.loadmovie it works =(

WILLY
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Are you testing this locally or on your server?

Since you are using a full URL, Flash may not be able to load the image from a server that is not the same as the server the file you are testing is on. This is seen as a security risk.

Chances are, if the image isn't loading that either the addressing is wrong to the image, or the image is not a non-progressive .jpg image. These are the only images Flash can dynamically load in.
  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

Can i Get a definition of non - progressive jpg?


after i do my for loop on the dynamic array, if i just do picHolder.loadMovie(url) it displays correctly ....


thx

WIlly


i really think it is the this["pic"+i]. method ....

i did an output test by doing this["pic"+i]._width and got a null
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Non-Progressive:

Have you ever been to a webpage and you see image that load from top to bottom progressively and not all at once? This is a format called "proressive jpg", where the browser reads the information of the image and displays it as it loads instead of waiting for it to fully load before it is displayed. However, since this is a browser interpreted action, Flash does not support dynamically loading these images in, so in order to load an image into Flash you will need to save it as a "Non-Progressive jpg". This is typically an option in the "Save As..." feature of a graphics program when JPG is chosen as the file format.

As for your code, this is how I would write it...
Code: [ Select ]
for(i=1;i<5;i++){  
  newMC = picHolder.duplicateMovieClip("pic"+i, i);
  newMC._x = (pix_side+5)*i;
  newMC.loadMovie("test.jpg"); 
 }
  1. for(i=1;i<5;i++){  
  2.   newMC = picHolder.duplicateMovieClip("pic"+i, i);
  3.   newMC._x = (pix_side+5)*i;
  4.   newMC.loadMovie("test.jpg"); 
  5.  }
The dot syntax that started with Flash 5 means you don't need to suffer through setProperty and all that jazz. And as for how I wrote the duplicateMovieClip code, that is a secondary method, both methods will work, but I prefer the above method because it is more clear to me.

Keep in mind that picHolder must be the instance name of a clip already existant on the stage (which i'm pretty sure you already know and have done).

If you don't know what is up, then in the above for loop add this code
Code: [ Select ]
trace(newMC);
trace() is a feature of flash for sort of run-time debugging, you can use it to output the value of something and check if it exists of not. In this case, if newMC returns null then for some reason your clip is not getting duplicated, and the problem is then with your duplicateMovieClip() code (which I see no coding problem, so it must be a problem with the clip you are duplicating). If your clips are getting duplicated, the location/instance name of your clip will be returned (ex: _level0.pic1, _level0.pic2, _level0.pic3), if this does happen then there is something wrong with another aspect of your code, most likely the loadMovie(), but again, I see nothing wrong with that, so it might be the image you are loading in.
  • Willy
  • Graduate
  • Graduate
  • Willy
  • Posts: 199

Post 3+ Months Ago

My problem with the resizing was actually that the guts of my picHolder object was a different size than the outside ... weird and a pain in the butt, but i got it.

thx
  • lostinbeta
  • Guru
  • Guru
  • User avatar
  • Posts: 1402
  • Loc: Philadelphia, PA

Post 3+ Months Ago

Something to keep in mind when using loadMovie() to a clip is that...

1) The object you load in replaces the content of the clip you load it to.

2) The object you load in inherits the properties of the clip you load it to.

3) Even though it inherits those properties, things such as _alpha, _width, _height, etc reset to default when the clip is loaded to it, so you may have to re-adjust that as needed after the clip has been loaded in.

Post Information

  • Total Posts in this topic: 11 posts
  • Users browsing this forum: No registered users and 2 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.