A Flash Developer Resource Site

Page 4 of 7 FirstFirst 1234567 LastLast
Results 61 to 80 of 134

Thread: dynamically loading jpgs and sizing the movie appropriately

  1. #61
    Junior Member
    Join Date
    Jun 2001
    Location
    .: somewhere south of the place I left my brain :.
    Posts
    19
    Hey guys,

    I'm glad to see some interset picking up again, hopefully we can get the answers we're looking for...

    hiker, I have no clue about your images not loading. I tried to get the thumbnails to load and could never get the images to display or the variables to display, either. I thought maybe I could tackle my canvas problem first, then try to get the thumbs to work.

    Hopefully pelle will browse back in and help out. I'm sure for me it's as simple as not placing the AS in the right place.

    I'm watching closely for any suggestions.....
    40 Rocks Design Studio...
    how can we help?

  2. #62
    Junior Member
    Join Date
    Jun 2001
    Location
    .: somewhere south of the place I left my brain :.
    Posts
    19

    Surprise!

    I found out completely by accident that if I publish the swf in Player 6 with Actionscript 1.0 the images fade in AFTER the canvas resizes. But they fade in BEFORE the resize with Player 7 and AS 2.0...

    Anybody know why?
    40 Rocks Design Studio...
    how can we help?

  3. #63
    Senior Member
    Join Date
    Aug 2001
    Posts
    220
    that's ridiculous! It works for me as well, I had a similar problem on another project where something simple wasnt working but then for some reason I tried it published in FP6 and it worked.

    Things like this truly drive me insane..


    nice catch!

  4. #64
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    In MX 2004 a variable must be difined before it can be used. So if you have any......

    i++;

    ..... in there, i has to be defined with a value first before it can be altered.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  5. #65
    Junior Member
    Join Date
    Jun 2001
    Location
    .: somewhere south of the place I left my brain :.
    Posts
    19
    Hey pelle,

    Great to have your input again on this. Can you tell me what variable in this code isn't defined? This is the code on the canvas MC and it seems like it should work the same in MX or MX2004. What am I missing?


    onClipEvent (enterFrame) {
    // Make canvas dynamically resize to whatever is loaded in container clip and width and height matches (and only when tótally loaded )
    if(_root.container.getBytesLoaded()>=_root.contain er.getBytesTotal()&&_root.container.getBytesLoaded ()>1000){
    this._width += (_root.container._width-this._width+2)/7;
    this._height += (_root.container._height-this._height+2)/7;
    }
    // Show picholder only when something is loaded into it
    if (math.round(_root.container._width+2) == math.round(this._width) && _root.container.getBytesLoaded()>1000 ){
    //fade in the image slowly
    _root.container._alpha += 3;
    } else {
    _root.container._alpha = 0;
    }
    }

    Thanks for the help.
    40 Rocks Design Studio...
    how can we help?

  6. #66
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    I dont have CS at the moment, so its hard to tell what is going wrong.
    If you export as AS 2, dont, unless you have a good reason ( the same goes for exporting as Flash 7 if you dont need to ). The syntax in as2 ( as I understand it ), its vital that every action is declared what it is.

    Maybe try and add....

    onClipEvent (load) {
    _root.container._alpha = 0;
    }


    ..on top of the code.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  7. #67
    Senior Member
    Join Date
    Oct 2000
    Location
    Nashville, Tennessee, USA
    Posts
    134
    one last try for help....
    this is the code i'm using to try to preload a gallery...

    Code:
    for(i=1;i<=12;i++){
    	newmovie = "pica"+i;
    	movieCont.duplicateMovieClip(newmovie,i);
    	setProperty(newmovie,_visible,false);
    	setProperty(newmovie,_alpha,0);
    	loadMovie("gallery/people/people_"+i+".jpg",newmovie);
    	while(_root[newmovie].getBytesLoaded() < _root[newmovie].getBytesTotal()){
    		loop;
    	}
    }
    the 'while' loop is there just to slow down the script as images are loaded... however, it only seems to work intermittently...

    i've already discovered that even though flash reports a movie clip as "loaded", it's not actually-- you can't set properties for the new clip (such as position and size) until a few seconds *after* flash reports it as loaded....

    but it seems that even if that were the case for 'bytesLoaded', that the effect would be just to keep the loop rolling untill the clip truly *was* loaded.....

    so does anyone have any guesses as to why this is not working???

    TIA

  8. #68
    Junior Member
    Join Date
    Mar 2003
    Posts
    24

    greetings

    I'm having a bit of an issue.

    I started with only five images so that it would be easiest. I will try to provide alot of detail here so there won't be questions on my code.

    I'm stuck where the full size image won't load.

    Here's the text file:
    image_url1=images/image1.jpg
    &image_url2=images/image2.jpg
    &image_url3=images/image3.jpg
    &image_url4=images/image4.jpg
    &image_url5=images/image5.jpg

    There are 5 thumbnail movie clips on stage, as well as a container clip.

    The thumbnails are loading into their proper place with the following code:
    loadVariablesNum ("images.txt", 0);
    for(i=1;i<10;i++){
    this["thumbnailMovie"+i].loadMovie("images/x"+("image"+i+".jpg"))
    }

    I put the following code on thumbnailMovie1:
    on (release){
    thumbnailMovie1.container.loadMovie(image_url1);
    }

    I've also tried:
    on (release){
    loadMovie("image_url1", "container");

    }

    Now to the problem:
    I don't get the larger image. This may be something simple that I'm just not seeing....any clues?

  9. #69
    Senior Member
    Join Date
    Oct 2000
    Location
    Nashville, Tennessee, USA
    Posts
    134
    i believe if you're using a movie clip as a button, that the "onRelease" handler requires a function to be declared...

    like this.....

    movieClip.onRelease = function () {
    thumbnailMovie1.container.loadMovie(image_url1);
    };

  10. #70
    Junior Member
    Join Date
    Mar 2003
    Posts
    24

    Got an error

    **Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 2: Statement must appear within on/onClipEvent handler
    movieClip.onRelease = function () {

    Total ActionScript Errors: 1 Reported Errors: 1

    I also tried to add onClipEvent (enterFrame) { but no dice.

    Any ideas?
    -------------
    edited:
    I've even tried the following:
    loadMovie("/images/image1.jpg", "container");

    and that's not working either. That's really weird.
    Last edited by jason7655; 08-11-2004 at 11:02 PM.

  11. #71
    Senior Member
    Join Date
    Oct 2000
    Location
    Nashville, Tennessee, USA
    Posts
    134
    looking at the error msg, it looks like you dropped the code into the main timeline-- it needs to be attached to the movie clip....

  12. #72
    Junior Member
    Join Date
    Mar 2003
    Posts
    24
    I dropped the code on thumbnailMovie1 which is the movieclip that is supposed to load the image dynamically from the text file into the container movieclip.

    And I changed it to try it a different way (like in the edited part of the post above), but still no luck.

    Should I post a .zip that contains the files?
    Jason

    ----------------
    edited:
    Here's the only code in the main timeline:
    loadVariablesNum ("images.txt", 0);
    for(i=1;i<10;i++){
    this["thumbnailMovie"+i].loadMovie("images/x"+("image"+i+".jpg"))
    }

    -----------
    edited 2:
    I've created a completely new fla with a button instead of a movieclip and there does seem to be an issue with it being a movieclip.
    Last edited by jason7655; 08-11-2004 at 11:12 PM.

  13. #73
    Senior Member
    Join Date
    Oct 2000
    Location
    Nashville, Tennessee, USA
    Posts
    134
    could be.... my brain is fried at the moment anyway from the above problems i'm having...

    but on movie clips as buttons, i usually just put an invisible button on top of them and carry on as normal... seems to work well...

  14. #74
    Junior Member
    Join Date
    Mar 2003
    Posts
    24
    that might be a quick fix to it, but in the long run I would like to know what the deal with it is.

    Thanks for helping.

    Edited:
    Hope that didn't sound rude. I tried the button and still no luck. I guess I will build from scratch and see if I can catch a slip up.
    Last edited by jason7655; 08-11-2004 at 11:31 PM.

  15. #75
    Senior Member
    Join Date
    Oct 2000
    Location
    Nashville, Tennessee, USA
    Posts
    134
    ya.. .sounds like it could be something else...don't know how big your images are, but perhaps they're too big to be loaded by the handler like that... (that's the reason i put that 'while' loop in my code above- to slow processing down while the movie loads)...

    try loading your movies in advance, set alpha to "0" and just have the button change alpha to "100"....

  16. #76
    Junior Member
    Join Date
    Mar 2003
    Posts
    24
    they are less than 100k and I'm doing it locally.
    They just aren't liking it being loaded from a movieclip for some reaosn. They also don't like the code:

    on (release){
    thumbnailMovie2.container.loadMovie(image_url2);
    }

    even on a regular button. On a regular button I can get the following code to work fine:

    on (Release) {

    loadMovie("images/image1.jpg", "container");
    }

    I'm about to give up for the night, but I'm still pluggin away right now.

  17. #77
    Junior Member
    Join Date
    Jun 2001
    Location
    .: somewhere south of the place I left my brain :.
    Posts
    19

    could be a clue...

    I'm not sure, but look at the 2 codes you're using. The one on the movie clip calls for the variable image_url2 and the code on the button calls for the file by name.

    In my file, I tried it with the code on the movie clip but used the file name and it worked. I also can get the variables to read on the _root level, but when I place the dynamic text box inside my thumbnail movie clip, it doesn't display. So I'm sure that somehow the thumbnail MC isn't reading or handling variables which is why it won't respond to the call for image_url2.

    Hope that makes sense.


    -------------------------
    I also changed thumbnailMovie1 to _root. Here's the code that I placed on the thumbnail MC that finally worked. Hope it helps.

    on(release) {
    _root.container.loadMovie("images/1.jpg");
    }
    Last edited by the yapper 66; 08-12-2004 at 06:04 AM.
    40 Rocks Design Studio...
    how can we help?

  18. #78
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    Some thoughts. Maybe obvious but....

    If the varibles does not work, there may have a path problem.You have to reference the variables at the timeline they are set or loaded into.

    Also when loading from a textfile, you have to give the variables some frames ( time ) to load before referencing them.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

  19. #79
    Junior Member
    Join Date
    Jun 2001
    Location
    .: somewhere south of the place I left my brain :.
    Posts
    19
    You're right. I'm sure that I have the path wrong because I am loading the text file and can get the variable to display if it's on the main timeline. So when I put the variable text inside a MC that is on the main stage, what do I need to do? How do I load the variables into that embedded clip? Would it be something like

    _root.movieClipInstance.loadVariablesNum("file.tex t", 0)

    Thanks.
    40 Rocks Design Studio...
    how can we help?

  20. #80
    Senior Member pellepiano's Avatar
    Join Date
    Feb 2000
    Location
    Stockholm, Sweden
    Posts
    15,151
    this.loadVariables("file.text");

    ...will load the variables into the current timeline.

    -Pelle Piano
    // Image Gallery
    www.studiobild.com
    // Photo Blog
    http://talesofthepixel.blogspot.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center