Skip navigation
Wozza12
Currently Being Moderated

Sharing graphics between multiple swfs (runtime sharing)

Dec 1, 2012 7:49 AM

Tags: #flash #swf #actionscript3.0

I am making a quiz application. I have a main .swf that makes requests to a server to obtain questions. The server then responds with a string of text which is parsed, and the containing question is drawn to the screen. For example, the server might respond with the question "Is the sky blue?; answer = true".

My application would then create a box containing the question and two buttons labelled 'true' and 'false'. Each of these elements are drawn using various nine-patch images that I embed into the .swf file.

My problem is this. I want to include custom question formats. Instead of simple text, I want to add a question such as 'Click the blue square in this picture'. I plan on making a bunch of these questions in Flash and exporting them as .swf files. The server could then send one of these .swfs as well as simple text questions.

Some of these separate questions will contain elements (e.g. buttons or text boxes) that I would like to be drawn in the same style as the questions that are created from scratch in the main application.

I'm not sure what's the best way of doing this. If I include the nine-patch images in each of the separate .swfs then surely I will run into problems if I ever want to change the images. I would have to recompile all the .swfs. I also want the user to be able to change themes. This is easily achieved if I swap out nine-patch images in the main application, but is going to be troublesome otherwise.

 
Replies
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 18, 2012 7:19 AM   in reply to Wozza12

    create one or more fla files that contain your (to be) shared symbol assets.  in the library of the fla(s), for each asset that is to be shared: right click>click properties>tick export for runtime sharing and assign a class and a url.  (at least, use a subdirectory of your main project directory because you can't leave this blank.)

     

    in all swfs that you want to use those shared assets, create symbols (graphics are irrelevant because they will be replaced by assets created in the above fla)>right click each library symbol you want replaced>click properties>tick import for runtime sharing, assign a matching class name from the above that should replace this symbol and in the url use the same subdirectory as above along with the swf name:

     

    export.png

     

    import.png

     

    in my swf that contains the orange oval, all on-stage instances will be replaced by the green square.  at some later time if i wanted to use red squares, i would just change the symbol with Symbol1 class in my exporting swf to a red square.

     
    |
    Mark as:
  • kglad
    72,235 posts
    Jul 21, 2002
    Currently Being Moderated
    Nov 20, 2012 8:12 AM   in reply to Wozza12

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points