Preloading Flash Libraries or individual items

Can Flash be used similar to Director?

Page 1 of 1

6 Replies - 17064 Views - Last Post: 26 January 2006 - 10:10 AM

#1 schiemer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-March 03

Preloading Flash Libraries or individual items

Posted 12 October 2005 - 04:18 PM

I have recently started studying Flash 8 and have greatly enjoyed the program so far. I've built several small sites in the past using Flash MX 2004 and now Flash 8, but I have noticed a huge difference between Flash and Director. Flash doesn't seem to have the ability to create external casts with multiple members in them that can be loaded only when a certain section of the site is entered.

I am a long time Director programer and have worked with numerous Director code guys to build very usesful Director behaviors to make programming easier. One behavior we have had created in the past is used to load External Casts of unlimited memebers applied in a single frame to a progress bar to show the load time of the cast. An example of one site we made using this behavior is http://www.frightflix.com (This site was made for a horror film company and is very graphic, so be warned!) The reason this behavior is invaluable to me is that I can apply it to a progress bar in one frame and quickly load an external cast of my choosing from a pulldown menu without writting any additional code. This can be applied the same way for every section of you site. This makes building huge, multiple section sites easy becasue you can load it as the viewer clicks on each section, thus making the site load quickly and easy to program. Here is the code for this behavior:
---

--#behavior
--Copyright 2003, MediaMacros, Inc.
--Version History
--1/22/03 - Created

property spriteNum
property pMember
property pId
property pWhatCast, pRect

on getPropertyDescriptionList me
  p = [:]
  l = []
  repeat with x = 1 to the number of castlibs
    if castlib(x).filename = the moviePath & the movieName then next repeat
    l.add(castlib(x).name)
  end repeat
  p[#pWhatCast] = [#format : #string, #comment : "What Cast", #default : "", #range : l]  
  return p
end

on beginSprite me
  pRect = sprite(spriteNum).rect
  pMember = new(#bitmap, castlib "temp")
  pMember.image = image(pRect.width, pRect.height, 32)
  --preload it
  
  pId = preloadNetThing(castlib(pWhatCast).filename)
  me.showProgress()
  sprite(spriteNum).member = pMember
  sprite(spriteNum).rect = pRect
end

on exitFrame me
  if netDone(pId) then
    --set it
    castlib(pWhatCast).filename = castlib(pWhatCast).filename
  else
    me.showProgress()
    go the frame
  end if
end

on endSprite me
  sprite(spriteNum).member = 0
  sprite(spriteNum).rect = 0
end

on showProgress me
  s = getStreamStatus(pId)
  per = float(s[#bytessofar]) / max(1, s[#bytestotal])
  pMember.image.fill(pMember.rect, rgb(0,0,0))
  a = pMember.image.extractAlpha()
  a.fill(a.rect, rgb(255,255,255))
  w = integer(pMember.width * .75)
  h = integer(min(20, max(5, pMember.height / 30.0)))
  r = MMI_CenterRect(rect(0,0,w,h), pMember.rect)
  pMember.image.fill(r + rect(-1,-1,1,1), rgb(200,200,200))
  a.fill(r + rect(-1,-1,1,1), rgb(0,0,0))
  rFill =  rect(r[1], r[2], r[1] + (w * per), r[4])
  pMember.image.fill(rFill, rgb(200,0,0))
  a.fill(rFill, rgb(0,0,0))
  pMember.image.setALpha(a)
  pMember.useALpha = 1
end

----




Now for my question. Can a behavior like this in Director MX 2004 be made to work in Flash 8 in a similar way? I have noticed that Flash 8 does not have external casts like Director, so that makes this a bit harder to concieve, but can a behavior be made to load multple library items in the same way? Or is there a way to make "external casts or libraries" in Flash 8?

The script above has proven it self time and again when building Director (Shockwave) sites and I really need the same ability in Flash 8. Can anyone help me??? Your help will be grealy appreciated and quite possibly rewarded.... within reason of course:)

Tom Schiemer
Creative Director
Switch Multimedia
tom@smmlv.com

Is This A Good Question/Topic? 0
  • +

Replies To: Preloading Flash Libraries or individual items

#2 schiemer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-March 03

Re: Preloading Flash Libraries or individual items

Posted 20 October 2005 - 06:33 PM

Hello again.

I was hoping to have some kind of answer by now. Does any one have any sugestions for me as to how I can accomplish preloading multiple flash memebers at once, or loading entire external libraries in Flash 8?

Any help or guidance is appreciated. If you have a solution, I'm even willing to pay for the assistance!
Was This Post Helpful? 0
  • +
  • -

#3 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Preloading Flash Libraries or individual items

Posted 22 October 2005 - 03:14 PM

I guess what you could do, is create movies with objects on stage. Each object having a unique name. You could then consider themas external libraries. Loading them into your main movie and dynamicly calling the objects needed.

Remember thought, that all these elements would be loaded into the main movie not just the one you're calling.

...

Another possibilitie is to create a fodler and have each member of the library in a seperate SWF and have a list of all the members/SWF files available for the main movie to read from. You could then load individual files from that folder. THIS is probably how I would do it, to be honest.

[ps] sorry for not answering earlier. have had a busy couple of weeks at work.
Was This Post Helpful? 0
  • +
  • -

#4 schiemer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-March 03

Re: Preloading Flash Libraries or individual items

Posted 22 October 2005 - 03:25 PM

Thanks for the post.

It sounds similar to Director where I would have several external casts on the root directory of the sever for the script to call and load when the section is entered, but you recommend putting all the art into a sepearte folder on the server.

Would you have any idea how you would script this action so I can load several .swf (or .jpg, .gif, etc) for each section from this folder on the server? And, can this script be attached to a loading bar to show the progress of the downloading content? all this occurs in my Director script I included in the first post. Since I'm more of a lingo programmer and I'm only now studying action scripting, there is a slight langauge gap for me right now. Your help is appreciated.
Was This Post Helpful? 0
  • +
  • -

#5 pioSko  Icon User is offline

  • still.dreaming
  • member icon

Reputation: 23
  • View blog
  • Posts: 1,888
  • Joined: 06-June 03

Re: Preloading Flash Libraries or individual items

Posted 22 October 2005 - 04:13 PM

I did very little lingo (regret i didn't continue), so it's a little ddificult to get a real picture of what exactly is going on.

The script would have to get a ilst of the movies needed to load, then, dependin on your needs, load them individualy one-after-another or all at once. You'd probably get better loading-error detection if you do it one-by-one. To load the movie, you'd need a movieclip on the stage to load it into. One movieclip for every member being loaded. You can do this using script. Something like:
var list:Array = new Array("apple", "pear", "orange", "pizza");

for(var i = 0; i < list.length; i++){
   // create a movieclip on the stage. parameters = (name, depth)
   this.createEmptyMovieClip(list[i], this.getNextHighestDepth());
}



The actual script that will load the movieclips can be done in a number of ways. Since, I've never done this and making it up off the top off my head, not being able to consult flash at the moment, I'm actually not sure which one would be more efficient. Experiments and tests would prove which method would give better results and less headaches.

Either tomorrow or day after I'll try some experiments and get back to you, but for the moment try something like this:

Create four SWF files named apple.swf, pear.swf, orange.swf and pizza.swf and main.swf. In your main movie add this code and test.
var list:Array = new Array("apple", "pear", "orange", "pizza");

for(var i = 0; i < list.length; i++){
   // create a movieclip on the stage. parameters = (name, depth)
   this.createEmptyMovieClip(list[i], this.getNextHighestDepth());
   eval(list[i]).loadMovie(list[i] + ".swf");
}



I probably won't be on tomorrow (we have elections here and I gotta go far to vote :/) so I'll probably do some stuff the day after. Sorry :/
Was This Post Helpful? 0
  • +
  • -

#6 schiemer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 04-March 03

Re: Preloading Flash Libraries or individual items

Posted 23 October 2005 - 11:15 AM

Thank you very much!

I'll try this out too and get back to you.
Was This Post Helpful? 0
  • +
  • -

#7 publiminal  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 27-June 03

Re: Preloading Flash Libraries or individual items

Posted 26 January 2006 - 10:10 AM

schiemer, on 23 Oct, 2005 - 12:12 PM, said:

Thank you very much!

I'll try this out too and get back to you.

hey... try to this page to get info about that

http://proto.layer51.com/d.aspx?f=771

bye
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1