SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Preloading a specific graphic?

    How would you go about preloading a specific graphic in Flash. I don't want it to be a separate movie that's loaded in if possible. Had a quick search around and couldn't find anything. Just wanted to find out if it was possible.... and if it is, any links to tutorials.

    Thanks,

    G

  2. #2
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Short and sweet for clarification, any image in flash is loaded from the get-go. But if you're talkin about loading an external jpeg into a movie, here's the basics.

    loadMovie("myFile.jpg", "_root.my.movieClip");

    You can use _root.my.movieClip.getBytesLoaded() and _root.my.movieClip.getBytesTotal() to figure out the percent that has loaded

  3. #3
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh, that's pretty cool! You can bring JPGs in directly! Thanks.

    So, if my instance name is "reel":

    loadMovie("myFile.jpg", "_root.reel" );

    Would that be right?

    G

  4. #4
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    That would be right ONLY if the "reel" instance clip resides on your stage. Ie, when you boot flash, and in a new document, the white area is the stage. If you toss an object onto that area, it's on the ROOT level.

    This is called targeting. If it's on the stage, then yeah, it's _root.reel. If reel had a movieclip in it, you could reference it like this

    From the stage
    _root.reel.myMovieClip

    From reel
    _parent (refers to Stage)
    myMovieClip (refers to its child)

    From myMovieClip
    _parent (refers to reel)
    _parent._parent (refers to stage)

  5. #5
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see. Makes perfect sense! Thanks very much. "reel" is actually in a clip, so I need to give that clip an instance name, say "content", so that I can target "reel" I guess:

    _root.content.reel

    It's just like moving up and down a directory tree in MS DOS or Unix isn't it....

  6. #6
    SitePoint Wizard aaron.martone's Avatar
    Join Date
    Feb 2003
    Location
    Florida, USA
    Posts
    2,322
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Correct.

    I like the analogy of file folders. If you don't name one, you can't get to it's kids.

    You basically have _root, _parent. And you can use them in any manner you see (_root can only be used once per target)

    (1) _root.myClip1
    (2) _root.myClip2
    (3) _root.myClip1.myChild1;
    (4) _root.myClip2.myChild2;
    (5) _root.myClip2.myChild2.myBaby2;

    To get to _root.myClip1.myChild1, you can go

    (1) myChild1
    (2) _parent.myClip1.myChild1;
    (3) this;
    (4) _parent._parent.myClip1.myChild1;
    (5) _parent._parent._parent.myClip1.myChild1;

    Of course, you can just go right to _root and target the object from anywhere (that's known as an absolute path, because you can use it ANYWEHRE in the hierarchy to get to an object - since it all uses the same start point, root)

  7. #7
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cool. Got the hang of it completely now. So simple, and loading in JPGs directly is exactly what I wanted to do! Just never bothered to learn ActionScript properly... one step at a time, eh?

    If only someone had said before that _parent is like ../ and _root is like starting from C:\ and it all would've made sense sooner! Thanks.

    G

  8. #8
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm having trouble with this now.... I had this ActionScript:

    Code:
    loadMovie("test.jpg", "_root.mainContent.reel.photo1");
    setProperty("_root.mainContent.reel.photo1", _x, "800");
    setProperty("_root.mainContent.reel.photo1", _y, "-230");
    It worked fine. Then I went to put the movie in situ, so I changed it to:

    Code:
    loadMovie("../img/photos/runners.jpg", "_root.mainContent.reel.photo1");
    setProperty("_root.mainContent.reel.photo1", _x, "800");
    setProperty("_root.mainContent.reel.photo1", _y, "-230");
    It didn't work. Tried moving "runners.jpg" to the same location as my movie:

    Code:
    loadMovie("runners.jpg", "_root.mainContent.reel.photo1");
    setProperty("_root.mainContent.reel.photo1", _x, "800");
    setProperty("_root.mainContent.reel.photo1", _y, "-230");
    Still no joy.

    Any ideas? I don't see how it could actually be the graphic cos it was outputted for web.

    G

  9. #9
    Drupaler bronze trophy greg.harvey's Avatar
    Join Date
    Jul 2002
    Location
    London, UK
    Posts
    3,258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Figured out what this was. Flash player won't load progressive JPGs.


Bookmarks

Posting Permissions

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