TwelvestoneFlash

Compiled SWF ignores changes to your class file?


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
DontBogartMe
 
2007-11-07

Another entry for the 12S flash blog...

I've just spent a maddening 40 minutes trying to work out why the changes in my .AS file weren't showing up when I run a movie in the browser.

Cos they showed up when I tested it in Flash.

The situation is that I am creating an app that is a collection of SWF files that get loaded in as needed in a main app SWF. There's some nesting going on here: application.swf loads in interface.swf which in turn loads in screen_1.swf which loads in mediaplayer_video.swf

I'm modifying mediaplayer_video.swf by altering a class file that makes buttons. When I test it in Flash the changes are evident. When I compile the FLA and then run it in the app, it shows up other changes in the FLA (I drew a simple circle on the stage), but won't use the new class file.

Deleting the .ASO file for the class MAKES NO BLOODY DIFFERENCE.

SOLUTION: That button class file was also used by interface.swf - which is above mediaplayer_video.swf in the loading chain.

I had to recompile interface.swf so that the changes in mediaplayer_video.swf showed up.

goes balder

DontBogartMe
 
2007-11-07

in fact, testing shows that by altering the AS file then recompiling the parent SWF (interface.swf in my case), then reload the app in the browser you will notice the changes in both the parent SWF and the child SWF.

Here are instructions for a simple test:

Create a new class file, called Square.as: class Square {
public function Square(mc:MovieClip, x:Number, y:Number){ var col:Number = 0xff0000; var size:Number = 50;

    // Draw a square
    mc.lineStyle();
    mc.beginFill(col);
    mc.moveTo(x, y);
    mc.lineTo(x + size, y);
    mc.lineTo(x + size, y + size);
    mc.lineTo(x, y + size);
    mc.lineTo(x, y);
    mc.endFill();
}

}

Create compiled_class_test_parent.fla and paste this code into frame 1: // Make a simple text field to label this movie var tf:TextField = this.createTextField("tf", 1, 10, 10, 100, 22); tf.text = "Parent:";

// Create a new Square on the stage var a_square:Square = new Square(this, 50, 10);

// Load in the child movie and position it var mcChild:MovieClip = this.createEmptyMovieClip("child", 2); mcChild._y = 100; var mcl:MovieClipLoader = new MovieClipLoader(); mcl.loadClip("compiled_class_test_child.swf", mcChild);

Create compiled_class_test_child.fla and paste this code into frame 1: // Make a simple text field to label this movie var tf:TextField = this.createTextField("tf", 1, 10, 10, 100, 22); tf.text = "Child:";

// Create a new Square on the stage var a_square:Square = new Square(this, 50, 10);

Compile both movies, then open compiled_class_test_parent.html in a browser. You should see 2 red squares.

Now change the Square.as file to make the square blue: var col:Number = 0x0000ff;

Now ONLY recompile the child movie (compiled_class_test_child.fla) and refresh compiled_class_test_parent.html in the browser

What do you expect to see now? The parent showing the old red square, and the child showing the new blue square?

What do you get? Two red squares - no change at all.

Now recompile the parent movie and refresh the browser - now both squares will show the new blue square.

Now make the square green: var col:Number = 0x00ff00;

This time recompile ONLY the parent movie, and refresh the browser.

What would you expect this time? The parent movie to show the new green square, but the old, not updated child movie to still show the blue square?

What do you get? TWO GREEN SQUARES! The child updates its class, even without being recompiled.

I'm guessing that child SWFs get their class byte code from parent SWFs where possible. Which is a bit bloody confusing to me.

JLM
 
2007-11-08

Did you try giving the two squares different name spaces? I say this since I am fairly sure I have used different Delegates, but that was as2.

DontBogartMe
 
2007-11-08

they were meant to be two instances of the same class, so the namespace should be the same in both cases - unless I've misunderstood you?

JLM
 
2007-11-08

I guess what I am saying is that 'gets its byte code from the parent swf' is not how I would understand this, but I might be wrong with my understanding/guess... Instead I would think of adding namespaces to the player, I guess flash stops you overwriteing namespaces. I think this is an like the old behaviour of MovieClip.Prototype, let me give an example. In an elearn project we would have a main movie that delt with navigation, storing scores etc... and we would load template movies, now as you know there was a bad oop fashion for modifying MovieClip with prototypes, now in the project, we would load exercise templates and when they loaded they would modify the MovieClip prototype and then the next template could access the enhanced MovieClip prototype whether it liked it or not! Maybe if you declared your square as dynamic then when the child loaded in, it would be able to modify the namespace and draw a different color square. Now if this were true I suppose you could suggest that once a class is defined you should be able to use it in another class without declaring an import at the top of your class... maybe you can? but you would have to construct its namespace
new [('net')][('justinfront')]('mySquare');
to fool the compiler checks, but I am probably talking rubish just floating some ideas which I may bother to try one day.

DontBogartMe
 
2007-11-08

I'm not sure we're talking about the same thing to be honest J. I don't think that namespaces come into it - but I could be wrong, as I don't have any exp of using them.

I'll put it as simply as I can: it's 2 instances of the same class, one instance in a parent SWF and another in a child SWF that the parent loads. If you alter the code in the class, you have to recompile the parent SWF to see the changes - recompiling only the child makes no difference.

But frankly I've a whole forest of bigger fires to fight right now! :gasmask:

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Compiled SWF ignores changes to your class file?